From: Douglas Gregor Date: Fri, 26 Feb 2010 00:01:57 +0000 (+0000) Subject: When we decide to re-use an existing CXXConstructExpr node, make sure X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c845aad6f7d012ab0cd0a040515ab512d1a93566;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97185 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index 2c6c615a11..0216621d1e 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -4906,8 +4906,10 @@ TreeTransform::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(), diff --git a/test/SemaTemplate/instantiate-expr-1.cpp b/test/SemaTemplate/instantiate-expr-1.cpp index d1b05f66a5..4594621103 100644 --- a/test/SemaTemplate/instantiate-expr-1.cpp +++ b/test/SemaTemplate/instantiate-expr-1.cpp @@ -137,3 +137,19 @@ void test_asm() { int b; test_asm(b); // expected-note {{in instantiation of function template specialization 'test_asm' requested here}} } + +namespace PR6424 { + template struct X { + X() { + int *ip = I; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}} + } + }; + + template struct Y { + typedef X<7> X7; + + void f() { X7(); } // expected-note{{instantiation}} + }; + + template void Y<3>::f(); +}