Fix the recently-added warning about 'typename' and 'template'
disambiguation keywords outside of templates in C++98/03. Previously,
the warning would fire when the associated nested-name-specifier was
not dependent, but that was a misreading of the C++98/03 standard:
now, we complain only when we're outside of any template.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106161 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaObjCXX/message.mm b/test/SemaObjCXX/message.mm
index 10b886b..76bde6f 100644
--- a/test/SemaObjCXX/message.mm
+++ b/test/SemaObjCXX/message.mm
@@ -62,15 +62,15 @@
// or typename-specifiers.
if (false) {
if (true)
- return [typename identity<I3>::type method]; // expected-warning{{'typename' refers to a non-dependent type name; accepted as a C++0x extension}}
+ return [typename identity<I3>::type method]; // expected-warning{{occurs outside of a template}}
return [::I3 method];
}
int* ip1 = {[super method]};
int* ip2 = {[::I3 method]};
- int* ip3 = {[typename identity<I3>::type method]}; // expected-warning{{'typename' refers to a non-dependent type name; accepted as a C++0x extension}}
- int* ip4 = {[typename identity<I2_holder>::type().get() method]}; // expected-warning{{'typename' refers to a non-dependent type name; accepted as a C++0x extension}}
+ int* ip3 = {[typename identity<I3>::type method]}; // expected-warning{{occurs outside of a template}}
+ int* ip4 = {[typename identity<I2_holder>::type().get() method]}; // expected-warning{{occurs outside of a template}}
int array[5] = {[3] = 2};
return [super method];
}
diff --git a/test/SemaTemplate/nested-name-spec-template.cpp b/test/SemaTemplate/nested-name-spec-template.cpp
index e542507..0251894 100644
--- a/test/SemaTemplate/nested-name-spec-template.cpp
+++ b/test/SemaTemplate/nested-name-spec-template.cpp
@@ -21,7 +21,7 @@
}
M::Promote<int>::type *ret_intptr3(int* ip) { return ip; }
- M::template Promote<int>::type *ret_intptr4(int* ip) { return ip; } // expected-warning{{'template' refers to a non-dependent template name; accepted as a C++0x extension}}
+ M::template Promote<int>::type *ret_intptr4(int* ip) { return ip; } // expected-warning{{'template' keyword outside of a template}}
}
N::M::Promote<int>::type *ret_intptr5(int* ip) { return ip; }
diff --git a/test/SemaTemplate/template-id-expr.cpp b/test/SemaTemplate/template-id-expr.cpp
index e897421..de8d7f6 100644
--- a/test/SemaTemplate/template-id-expr.cpp
+++ b/test/SemaTemplate/template-id-expr.cpp
@@ -62,12 +62,12 @@
template<typename U>
void f() {
- Y0::template f1<U>(0); // expected-warning{{'template' refers to a non-dependent template name}}
- Y0::template f1(0); // expected-warning{{'template' refers to a non-dependent template name}}
+ Y0::template f1<U>(0);
+ Y0::template f1(0);
this->template f1(0);
- Y0::template f2<U>(0); // expected-warning{{'template' refers to a non-dependent template name}}
- Y0::template f2(0);// expected-warning{{'template' refers to a non-dependent template name}}
+ Y0::template f2<U>(0);
+ Y0::template f2(0);
Y0::template f3(0); // expected-error {{'f3' following the 'template' keyword does not refer to a template}}
Y0::template f3(); // expected-error {{'f3' following the 'template' keyword does not refer to a template}}
@@ -75,8 +75,7 @@
int x;
x = Y0::f4(0);
x = Y0::f4<int>(0); // expected-error {{assigning to 'int' from incompatible type 'void'}}
- x = Y0::template f4(0); // expected-error {{assigning to 'int' from incompatible type 'void'}} \
- // expected-warning{{'template' refers to a non-dependent template name}}
+ x = Y0::template f4(0); // expected-error {{assigning to 'int' from incompatible type 'void'}}
x = this->f4(0);
x = this->f4<int>(0); // expected-error {{assigning to 'int' from incompatible type 'void'}}
diff --git a/test/SemaTemplate/typename-specifier-4.cpp b/test/SemaTemplate/typename-specifier-4.cpp
index da11119..5a313bf 100644
--- a/test/SemaTemplate/typename-specifier-4.cpp
+++ b/test/SemaTemplate/typename-specifier-4.cpp
@@ -27,7 +27,8 @@
int a0[is_same<metafun_apply2<make_pair, int, float>::type,
pair<int, float> >::value? 1 : -1];
int a1[is_same<
- typename make_pair::template apply<int, float>, // expected-warning{{'template' refers to a non-dependent template name}}
+ typename make_pair::template apply<int, float>, // expected-warning{{'template' keyword outside of a template}} \
+ // expected-warning{{'typename' occurs outside of a template}}
make_pair::apply<int, float>
>::value? 1 : -1];
diff --git a/test/SemaTemplate/typename-specifier.cpp b/test/SemaTemplate/typename-specifier.cpp
index e066475..4c788f6 100644
--- a/test/SemaTemplate/typename-specifier.cpp
+++ b/test/SemaTemplate/typename-specifier.cpp
@@ -15,20 +15,22 @@
int i;
-typename N::A::type *ip1 = &i; // expected-warning{{'typename' refers to a non-dependent type name}}
-typename N::B::type *ip2 = &i; // expected-error{{no type named 'type' in 'N::B'}}
-typename N::C::type *ip3 = &i; // expected-error{{typename specifier refers to non-type member 'type'}}
+typename N::A::type *ip1 = &i; // expected-warning{{'typename' occurs outside of a template}}
+typename N::B::type *ip2 = &i; // expected-error{{no type named 'type' in 'N::B'}} \
+// expected-warning{{'typename' occurs outside of a template}}
+typename N::C::type *ip3 = &i; // expected-error{{typename specifier refers to non-type member 'type'}} \
+// expected-warning{{'typename' occurs outside of a template}}
void test(double d) {
typename N::A::type f(typename N::A::type(a)); // expected-warning{{parentheses were disambiguated as a function declarator}} \
- // expected-warning 2{{'typename' refers to a non-dependent type name}}
+ // expected-warning 2{{'typename' occurs outside of a template}}
int five = f(5);
using namespace N;
- for (typename A::type i = 0; i < 10; ++i) // expected-warning{{'typename' refers to a non-dependent type name}}
+ for (typename A::type i = 0; i < 10; ++i) // expected-warning{{'typename' occurs outside of a template}}
five += 1;
- const typename N::A::type f2(d); // expected-warning{{'typename' refers to a non-dependent type name}}
+ const typename N::A::type f2(d); // expected-warning{{'typename' occurs outside of a template}}
}
namespace N {