r179080 - When checking for illegal expressions in a default-argument
John McCall
rjmccall at apple.com
Mon Apr 8 18:56:28 PDT 2013
Author: rjmccall
Date: Mon Apr 8 20:56:28 2013
New Revision: 179080
URL: http://llvm.org/viewvc/llvm-project?rev=179080&view=rev
Log:
When checking for illegal expressions in a default-argument
expression, look through pseudo-object expressions.
rdar://13602832
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaObjCXX/property-reference.mm
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=179080&r1=179079&r2=179080&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Apr 8 20:56:28 2013
@@ -65,6 +65,7 @@ namespace {
bool VisitDeclRefExpr(DeclRefExpr *DRE);
bool VisitCXXThisExpr(CXXThisExpr *ThisE);
bool VisitLambdaExpr(LambdaExpr *Lambda);
+ bool VisitPseudoObjectExpr(PseudoObjectExpr *POE);
};
/// VisitExpr - Visit all of the children of this expression.
@@ -115,6 +116,23 @@ namespace {
<< ThisE->getSourceRange();
}
+ bool CheckDefaultArgumentVisitor::VisitPseudoObjectExpr(PseudoObjectExpr *POE) {
+ bool Invalid = false;
+ for (PseudoObjectExpr::semantics_iterator
+ i = POE->semantics_begin(), e = POE->semantics_end(); i != e; ++i) {
+ Expr *E = *i;
+
+ // Look through bindings.
+ if (OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(E)) {
+ E = OVE->getSourceExpr();
+ assert(E && "pseudo-object binding without source expression?");
+ }
+
+ Invalid |= Visit(E);
+ }
+ return Invalid;
+ }
+
bool CheckDefaultArgumentVisitor::VisitLambdaExpr(LambdaExpr *Lambda) {
// C++11 [expr.lambda.prim]p13:
// A lambda-expression appearing in a default argument shall not
Modified: cfe/trunk/test/SemaObjCXX/property-reference.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/property-reference.mm?rev=179080&r1=179079&r2=179080&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/property-reference.mm (original)
+++ cfe/trunk/test/SemaObjCXX/property-reference.mm Mon Apr 8 20:56:28 2013
@@ -57,3 +57,21 @@ template<typename T> void f() {
}
template void f<int>();
+
+// rdar://13602832
+//
+// Make sure that the default-argument checker looks through
+// pseudo-object expressions correctly. The default argument
+// needs to force l2r to test this effectively because the checker
+// is syntactic and runs before placeholders are handled.
+ at interface Test13602832
+- (int) x;
+ at end
+namespace test13602832 {
+ template <int N> void foo(Test13602832 *a, int limit = a.x + N) {} // expected-error {{default argument references parameter 'a'}}
+
+ void test(Test13602832 *a) {
+ // FIXME: this is a useless cascade error.
+ foo<1024>(a); // expected-error {{no matching function}}
+ }
+}
More information about the cfe-commits
mailing list