diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-06-16 22:31:08 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-06-16 22:31:08 +0000 |
commit | 1a15dae8be2b28e02b6639aa92b832465c5be420 (patch) | |
tree | e0208461ea4e3d921f512bb2d2421ce2f983e7e0 /test/SemaTemplate | |
parent | 13927a431dd733336cfd664bf0840747a71b0a43 (diff) |
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
Diffstat (limited to 'test/SemaTemplate')
-rw-r--r-- | test/SemaTemplate/nested-name-spec-template.cpp | 2 | ||||
-rw-r--r-- | test/SemaTemplate/template-id-expr.cpp | 11 | ||||
-rw-r--r-- | test/SemaTemplate/typename-specifier-4.cpp | 3 | ||||
-rw-r--r-- | test/SemaTemplate/typename-specifier.cpp | 14 |
4 files changed, 16 insertions, 14 deletions
diff --git a/test/SemaTemplate/nested-name-spec-template.cpp b/test/SemaTemplate/nested-name-spec-template.cpp index e542507a2f..0251894f35 100644 --- a/test/SemaTemplate/nested-name-spec-template.cpp +++ b/test/SemaTemplate/nested-name-spec-template.cpp @@ -21,7 +21,7 @@ namespace N { } 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 e8974211b6..de8d7f6c91 100644 --- a/test/SemaTemplate/template-id-expr.cpp +++ b/test/SemaTemplate/template-id-expr.cpp @@ -62,12 +62,12 @@ struct Y0 { 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 @@ struct Y0 { 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 da11119e5b..5a313bf225 100644 --- a/test/SemaTemplate/typename-specifier-4.cpp +++ b/test/SemaTemplate/typename-specifier-4.cpp @@ -27,7 +27,8 @@ struct make_pair { 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 e066475be9..4c788f6a8a 100644 --- a/test/SemaTemplate/typename-specifier.cpp +++ b/test/SemaTemplate/typename-specifier.cpp @@ -15,20 +15,22 @@ namespace N { 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 { |