diff options
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 1 | ||||
-rw-r--r-- | test/SemaTemplate/temp_arg_nontype.cpp | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 7e7413f296..958ed4498e 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -2576,6 +2576,7 @@ CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, // Create the template argument. Converted = TemplateArgument(Entity->getCanonicalDecl()); + S.MarkDeclarationReferenced(Arg->getLocStart(), Entity); return false; } diff --git a/test/SemaTemplate/temp_arg_nontype.cpp b/test/SemaTemplate/temp_arg_nontype.cpp index 1d23c3df08..7b83ff9194 100644 --- a/test/SemaTemplate/temp_arg_nontype.cpp +++ b/test/SemaTemplate/temp_arg_nontype.cpp @@ -176,3 +176,20 @@ namespace PR6723 { f<512>(arr512); // expected-error{{no matching function for call}} } } + +// Check that we instantiate declarations whose addresses are taken +// for non-type template arguments. +namespace EntityReferenced { + template<typename T, void (*)(T)> struct X { }; + + template<typename T> + struct Y { + static void f(T x) { + x = 1; // expected-error{{assigning to 'int *' from incompatible type 'int'}} + } + }; + + void g() { + typedef X<int*, Y<int*>::f> x; // expected-note{{in instantiation of}} + } +} |