diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-07-31 04:52:13 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-07-31 04:52:13 +0000 |
commit | 742424339afa29b52c55e40289c735cf7030aeaf (patch) | |
tree | 698f1b9ee76ddf5b60f0ac22024e284f4d5a35e1 /clang/lib | |
parent | a92687d6365f3bef67f23929c568262045f5b45b (diff) | |
download | bcm5719-llvm-742424339afa29b52c55e40289c735cf7030aeaf.tar.gz bcm5719-llvm-742424339afa29b52c55e40289c735cf7030aeaf.zip |
Sema: Disallow taking the address of a bitfield coming from preincrement
Clang forgot that '++s.m' was a bitfield l-value and permit it's address
to be taken; this would crash at CodeGen-time.
Instead, propagate the object-kind when we see the prefix
increment/decrement.
This fixes PR20496.
Differential Revision: http://reviews.llvm.org/D4733
llvm-svn: 214386
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 4675c45f2f8..2041132f4bf 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -8764,6 +8764,7 @@ static QualType CheckCommaOperands(Sema &S, ExprResult &LHS, ExprResult &RHS, /// doesn't need to call UsualUnaryConversions or UsualArithmeticConversions. static QualType CheckIncrementDecrementOperand(Sema &S, Expr *Op, ExprValueKind &VK, + ExprObjectKind &OK, SourceLocation OpLoc, bool IsInc, bool IsPrefix) { if (Op->isTypeDependent()) @@ -8809,7 +8810,7 @@ static QualType CheckIncrementDecrementOperand(Sema &S, Expr *Op, } else if (ResType->isPlaceholderType()) { ExprResult PR = S.CheckPlaceholderExpr(Op); if (PR.isInvalid()) return QualType(); - return CheckIncrementDecrementOperand(S, PR.get(), VK, OpLoc, + return CheckIncrementDecrementOperand(S, PR.get(), VK, OK, OpLoc, IsInc, IsPrefix); } else if (S.getLangOpts().AltiVec && ResType->isVectorType()) { // OK! ( C/C++ Language Extensions for CBEA(Version 2.6) 10.3 ) @@ -8830,6 +8831,7 @@ static QualType CheckIncrementDecrementOperand(Sema &S, Expr *Op, // operand. if (IsPrefix && S.getLangOpts().CPlusPlus) { VK = VK_LValue; + OK = Op->getObjectKind(); return ResType; } else { VK = VK_RValue; @@ -9818,7 +9820,8 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc, case UO_PreDec: case UO_PostInc: case UO_PostDec: - resultType = CheckIncrementDecrementOperand(*this, Input.get(), VK, OpLoc, + resultType = CheckIncrementDecrementOperand(*this, Input.get(), VK, OK, + OpLoc, Opc == UO_PreInc || Opc == UO_PostInc, Opc == UO_PreInc || |