[PATCH] Sema: Disallow taking the address of a bitfield coming from preincrement
David Majnemer
david.majnemer at gmail.com
Wed Jul 30 22:01:10 PDT 2014
Closed by commit rL214386 (authored by @majnemer).
REPOSITORY
rL LLVM
http://reviews.llvm.org/D4733
Files:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CXX/drs/dr3xx.cpp
Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -8764,6 +8764,7 @@
/// 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 @@
} 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 @@
// operand.
if (IsPrefix && S.getLangOpts().CPlusPlus) {
VK = VK_LValue;
+ OK = Op->getObjectKind();
return ResType;
} else {
VK = VK_RValue;
@@ -9818,7 +9820,8 @@
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 ||
Index: cfe/trunk/test/CXX/drs/dr3xx.cpp
===================================================================
--- cfe/trunk/test/CXX/drs/dr3xx.cpp
+++ cfe/trunk/test/CXX/drs/dr3xx.cpp
@@ -322,6 +322,7 @@
int *f = &(true ? s.n : s.n); // expected-error {{address of bit-field}}
int &g = (void(), s.n); // expected-error {{non-const reference cannot bind to bit-field}}
int *h = &(void(), s.n); // expected-error {{address of bit-field}}
+ int *i = &++s.n; // expected-error {{address of bit-field}}
}
namespace dr326 { // dr326: yes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4733.12057.patch
Type: text/x-patch
Size: 2391 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140731/03f8c9d6/attachment.bin>
More information about the cfe-commits
mailing list