aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-04-24 18:20:53 +0000
committerDouglas Gregor <dgregor@apple.com>2010-04-24 18:20:53 +0000
commit77c13e07314422c6e76eda1bd1c7d83181b7e526 (patch)
tree752c84324588516af6006b74a05adca9bcb155af
parentf643b9b338b797a824447207d7eab5f1187f4f34 (diff)
When we take the address of a declaration to bind it to a non-type
template parameter, by sure to mark that declaration as "referenced". The Boost.Iterator library now passes all tests. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102256 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaTemplate.cpp1
-rw-r--r--test/SemaTemplate/temp_arg_nontype.cpp17
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}}
+ }
+}