]> granicus.if.org Git - clang/commitdiff
When marking declarations referenced within an expression (e.g.,
authorDouglas Gregor <dgregor@apple.com>
Tue, 19 Oct 2010 17:17:35 +0000 (17:17 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 19 Oct 2010 17:17:35 +0000 (17:17 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116817 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/SemaTemplate/default-expr-arguments.cpp

index 031337d6fe2baf9423e16c66976a691addb6d9b7..f98aefcd562b527e3e65483fb052a05499500d85 100644 (file)
@@ -8019,6 +8019,10 @@ namespace {
     void VisitBlockDeclRefExpr(BlockDeclRefExpr *E) {
       S.MarkDeclarationReferenced(E->getLocation(), E->getDecl());
     }
+    
+    void VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
+      Visit(E->getExpr());
+    }
   };
 }
 
index eff59a84e30d71027dddfdc611b7df44368acee9..8d54926b965ce1e9628cd996dad4bae4a09032d6 100644 (file)
@@ -274,3 +274,21 @@ namespace rdar8427926 {
     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();
+  }
+}