Implement template instantiation for template names, including both
template template parameters and dependent template names. For
example, the oft-mentioned
typename MetaFun::template apply<T1, T2>::type
can now be instantiated, with the appropriate name lookup for "apply".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68128 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaTemplate/metafun-apply.cpp b/test/SemaTemplate/metafun-apply.cpp
index 22be5ab..e81d142 100644
--- a/test/SemaTemplate/metafun-apply.cpp
+++ b/test/SemaTemplate/metafun-apply.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-cc -fsyntax-only %s
+// RUN: clang-cc -fsyntax-only -verify %s
struct add_pointer {
template<typename T>
@@ -10,20 +10,21 @@
struct add_reference {
template<typename T>
struct apply {
- typedef T& type;
+ typedef T& type; // expected-error{{cannot form a reference to 'void'}}
};
};
template<typename MetaFun, typename T>
struct apply1 {
- typedef typename MetaFun::template apply<T>::type type;
+ typedef typename MetaFun::template apply<T>::type type; // expected-note{{in instantiation of template class 'struct add_reference::apply<void>' requested here}}
};
-#if 0
-// FIXME: The code below requires template instantiation for dependent
-// template-names that occur within nested-name-specifiers.
int i;
-
apply1<add_pointer, int>::type ip = &i;
apply1<add_reference, int>::type ir = i;
-#endif
+apply1<add_reference, float>::type fr = i; // expected-error{{non-const lvalue reference to type 'float' cannot be initialized with a value of type 'int'}}
+
+void test() {
+ apply1<add_reference, void>::type t; // expected-note{{in instantiation of template class 'struct apply1<struct add_reference, void>' requested here}} \
+ // FIXME: expected-error{{unexpected type name 'type': expected expression}}
+}