[cfe-commits] r116817 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaTemplate/default-expr-arguments.cpp

Douglas Gregor dgregor at apple.com
Tue Oct 19 10:17:35 PDT 2010


Author: dgregor
Date: Tue Oct 19 12:17:35 2010
New Revision: 116817

URL: http://llvm.org/viewvc/llvm-project?rev=116817&view=rev
Log:
When marking declarations referenced within an expression (e.g.,
within a default argument), recurse into default arguments. Fixes
PR8401, a regression I introduced in r113700 while refactoring our
handling of "used" declarations in default arguments.

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=116817&r1=116816&r2=116817&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Oct 19 12:17:35 2010
@@ -8019,6 +8019,10 @@
     void VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
       S.MarkDeclarationReferenced(E->getLocation(), E->getDecl());
     }
+    
+    void VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
+      Visit(E->getExpr());
+    }
   };
 }
 

Modified: cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp?rev=116817&r1=116816&r2=116817&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp (original)
+++ cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp Tue Oct 19 12:17:35 2010
@@ -274,3 +274,21 @@
     x->g();
   }
 }
+
+namespace PR8401 {
+  template<typename T> 
+  struct A { 
+    A() { T* x = 1; } // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}}
+  };
+
+  template<typename T>
+  struct B {
+    B(const A<T>& a = A<T>()); // expected-note{{in instantiation of}}
+  };
+
+  void f(B<int> b = B<int>());
+
+  void g() {
+    f();
+  }
+}





More information about the cfe-commits mailing list