]> granicus.if.org Git - clang/commitdiff
When we decide to re-use an existing CXXConstructExpr node, make sure
authorDouglas Gregor <dgregor@apple.com>
Fri, 26 Feb 2010 00:01:57 +0000 (00:01 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 26 Feb 2010 00:01:57 +0000 (00:01 +0000)
to mark the constructor as referenced. Fixes the narrow issue reported
in PR6424, but there are a few other places that I'll fix before
closing out that PR.

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

lib/Sema/TreeTransform.h
test/SemaTemplate/instantiate-expr-1.cpp

index 2c6c615a1146ed58813e5a92a1c4a9ae90cf2bf5..0216621d1e8fbda6693f6c2ec8f547d1061f11df 100644 (file)
@@ -4906,8 +4906,10 @@ TreeTransform<Derived>::TransformCXXConstructExpr(CXXConstructExpr *E) {
   if (!getDerived().AlwaysRebuild() &&
       T == E->getType() &&
       Constructor == E->getConstructor() &&
-      !ArgumentChanged)
+      !ArgumentChanged) {
+    SemaRef.MarkDeclarationReferenced(E->getLocStart(), Constructor);
     return SemaRef.Owned(E->Retain());
+  }
 
   return getDerived().RebuildCXXConstructExpr(T, /*FIXME:*/E->getLocStart(),
                                               Constructor, E->isElidable(),
index d1b05f66a5863fae1ed597143787d45e9a02d6ff..4594621103f650827c8c0e5ac57f38b0f39b8e43 100644 (file)
@@ -137,3 +137,19 @@ void test_asm() {
   int b;
   test_asm(b); // expected-note {{in instantiation of function template specialization 'test_asm<int>' requested here}}
 }
+
+namespace PR6424 {
+  template<int I> struct X { 
+    X() { 
+      int *ip = I; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}}
+    }
+  };
+  
+  template<int> struct Y {
+    typedef X<7> X7;
+    
+    void f() { X7(); } // expected-note{{instantiation}}
+  };
+  
+  template void Y<3>::f(); 
+}