aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaCXXCast.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-04-22 22:31:13 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-04-22 22:31:13 +0000
commitb464a5b18916b467ed884d07f9e34295d39cec0a (patch)
tree00228ab7ffd4fc268fe164fcd7328f000ca15339 /lib/Sema/SemaCXXCast.cpp
parent788440378c442562497c09610939cbe6218ab43d (diff)
reinterpret_cast to reference of a bit-field is not allowed.
Fixes rdar://9202628 & http://llvm.org/PR9564. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130024 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCXXCast.cpp')
-rw-r--r--lib/Sema/SemaCXXCast.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Sema/SemaCXXCast.cpp b/lib/Sema/SemaCXXCast.cpp
index a0d1514bd0..29475539d7 100644
--- a/lib/Sema/SemaCXXCast.cpp
+++ b/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);