diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-04-22 22:31:13 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-04-22 22:31:13 +0000 |
commit | 47a1285a693b7286813f759aa4feae84d841c282 (patch) | |
tree | c8b8b2da3729d3f4424cf34a2af10b4ff50617d6 /clang/lib/Sema/SemaCXXCast.cpp | |
parent | 975096917843e32ad4d27e8c52204c94b864689e (diff) | |
download | bcm5719-llvm-47a1285a693b7286813f759aa4feae84d841c282.tar.gz bcm5719-llvm-47a1285a693b7286813f759aa4feae84d841c282.zip |
reinterpret_cast to reference of a bit-field is not allowed.
Fixes rdar://9202628 & http://llvm.org/PR9564.
llvm-svn: 130024
Diffstat (limited to 'clang/lib/Sema/SemaCXXCast.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCXXCast.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaCXXCast.cpp b/clang/lib/Sema/SemaCXXCast.cpp index a0d1514bd0b..29475539d71 100644 --- a/clang/lib/Sema/SemaCXXCast.cpp +++ b/clang/lib/Sema/SemaCXXCast.cpp @@ -1326,6 +1326,13 @@ static TryCastResult TryReinterpretCast(Sema &Self, ExprResult &SrcExpr, // C++ 5.2.10p10: [...] a reference cast reinterpret_cast<T&>(x) has the // same effect as the conversion *reinterpret_cast<T*>(&x) with the // built-in & and * operators. + + // Cannot get address of a bitfield. + if (SrcExpr.get()->getObjectKind() == OK_BitField) { + msg = diag::err_bad_reinterpret_cast_bitfield; + return TC_NotApplicable; + } + // This code does this transformation for the checked types. DestType = Self.Context.getPointerType(DestTypeTmp->getPointeeType()); SrcType = Self.Context.getPointerType(SrcType); |