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
This commit is contained in:
Douglas Gregor 2010-04-24 18:20:53 +00:00
Родитель f643b9b338
Коммит 77c13e0731
2 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@ -2576,6 +2576,7 @@ CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S,
// Create the template argument.
Converted = TemplateArgument(Entity->getCanonicalDecl());
S.MarkDeclarationReferenced(Arg->getLocStart(), Entity);
return false;
}

Просмотреть файл

@ -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}}
}
}