[cfe-commits] r134170 - in /cfe/trunk: lib/Sema/SemaExprCXX.cpp test/SemaCXX/member-pointer.cpp
John McCall
rjmccall at apple.com
Thu Jun 30 10:15:34 PDT 2011
Author: rjmccall
Date: Thu Jun 30 12:15:34 2011
New Revision: 134170
URL: http://llvm.org/viewvc/llvm-project?rev=134170&view=rev
Log:
Perform lvalue-to-rvalue conversions on both operands of ->*
and the RHS of .*. Noticed by Enea Zaffanella!
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/SemaCXX/member-pointer.cpp
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=134170&r1=134169&r2=134170&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Jun 30 12:15:34 2011
@@ -3168,6 +3168,20 @@
ExprValueKind &VK,
SourceLocation Loc,
bool isIndirect) {
+ assert(!lex.get()->getType()->isPlaceholderType() &&
+ !rex.get()->getType()->isPlaceholderType() &&
+ "placeholders should have been weeded out by now");
+
+ // The LHS undergoes lvalue conversions if this is ->*.
+ if (isIndirect) {
+ lex = DefaultLvalueConversion(lex.take());
+ if (lex.isInvalid()) return QualType();
+ }
+
+ // The RHS always undergoes lvalue conversions.
+ rex = DefaultLvalueConversion(rex.take());
+ if (rex.isInvalid()) return QualType();
+
const char *OpSpelling = isIndirect ? "->*" : ".*";
// C++ 5.5p2
// The binary operator .* [p3: ->*] binds its second operand, which shall
Modified: cfe/trunk/test/SemaCXX/member-pointer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/member-pointer.cpp?rev=134170&r1=134169&r2=134170&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/member-pointer.cpp (original)
+++ cfe/trunk/test/SemaCXX/member-pointer.cpp Thu Jun 30 12:15:34 2011
@@ -296,3 +296,19 @@
mem_fn(&test::nullary_v)(t); // expected-note{{in instantiation of}}
}
}
+
+namespace test8 {
+ struct A { int foo; };
+ int test1() {
+ // Verify that we perform (and check) an lvalue conversion on the operands here.
+ return (*((A**) 0)) // expected-warning {{indirection of non-volatile null pointer will be deleted}} expected-note {{consider}}
+ ->**(int A::**) 0; // expected-warning {{indirection of non-volatile null pointer will be deleted}} expected-note {{consider}}
+ }
+
+ int test2() {
+ // Verify that we perform (and check) an lvalue conversion on the operands here.
+ // TODO: the .* should itself warn about being a dereference of null.
+ return (*((A*) 0))
+ .**(int A::**) 0; // expected-warning {{indirection of non-volatile null pointer will be deleted}} expected-note {{consider}}
+ }
+}
More information about the cfe-commits
mailing list