[cfe-commits] r97185 - in /cfe/trunk: lib/Sema/TreeTransform.h test/SemaTemplate/instantiate-expr-1.cpp

Douglas Gregor dgregor at apple.com
Thu Feb 25 16:01:57 PST 2010


Author: dgregor
Date: Thu Feb 25 18:01:57 2010
New Revision: 97185

URL: http://llvm.org/viewvc/llvm-project?rev=97185&view=rev
Log:
When we decide to re-use an existing CXXConstructExpr node, make sure
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.

Modified:
    cfe/trunk/lib/Sema/TreeTransform.h
    cfe/trunk/test/SemaTemplate/instantiate-expr-1.cpp

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=97185&r1=97184&r2=97185&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Thu Feb 25 18:01:57 2010
@@ -4906,8 +4906,10 @@
   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(),

Modified: cfe/trunk/test/SemaTemplate/instantiate-expr-1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-expr-1.cpp?rev=97185&r1=97184&r2=97185&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-expr-1.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-expr-1.cpp Thu Feb 25 18:01:57 2010
@@ -137,3 +137,19 @@
   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(); 
+}





More information about the cfe-commits mailing list