summaryrefslogtreecommitdiffstats
path: root/test/SemaTemplate
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-01-19 21:00:13 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-01-19 21:00:13 +0000
commita669043d2b89421b00d32aa819cb4e93e23560d6 (patch)
tree774828ed8bbb439941ecd8bb54f8c3496aca0303 /test/SemaTemplate
parent103c86b73b9b22adf7932a7e67ba645e38800c0d (diff)
PR13403 (+duplicates): implement C++ DR1310 (http://wg21.link/cwg1310).
Under this defect resolution, the injected-class-name of a class or class template cannot be used except in very limited circumstances (when declaring a constructor, in a nested-name-specifier, in a base-specifier, or in an elaborated-type-specifier). This is apparently done to make parsing easier, but it's a pain for us since we don't know whether a template-id using the injected-class-name is valid at the point when we annotate it (we don't yet know whether the template-id will become part of an elaborated-type-specifier). As a tentative resolution to a perceived language defect, mem-initializer-ids are added to the list of exceptions here (they generally follow the same rules as base-specifiers). When the reference to the injected-class-name uses the 'typename' or 'template' keywords, we permit it to be used to name a type or template as an extension; other compilers also accept some cases in this area. There are also a couple of corner cases with dependent template names that we do not yet diagnose, but which will also get this treatment. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@292518 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaTemplate')
-rw-r--r--test/SemaTemplate/injected-class-name.cpp5
-rw-r--r--test/SemaTemplate/instantiate-enum.cpp5
-rw-r--r--test/SemaTemplate/instantiate-member-class.cpp4
-rw-r--r--test/SemaTemplate/ms-sizeof-missing-typename.cpp2
4 files changed, 10 insertions, 6 deletions
diff --git a/test/SemaTemplate/injected-class-name.cpp b/test/SemaTemplate/injected-class-name.cpp
index 7349fdf392..93a7231b8c 100644
--- a/test/SemaTemplate/injected-class-name.cpp
+++ b/test/SemaTemplate/injected-class-name.cpp
@@ -11,7 +11,10 @@ struct X<int***> {
typedef X<int***> *ptr;
};
-X<float>::X<int> xi = x; // expected-error{{qualified reference to 'X' is a constructor name rather than a template name wherever a constructor can be declared}}
+X<float>::X<int> xi = x; // expected-error{{qualified reference to 'X' is a constructor name rather than a template name}}
+void f() {
+ X<float>::X<int> xi = x; // expected-error{{qualified reference to 'X' is a constructor name rather than a template name}}
+}
// [temp.local]p1:
diff --git a/test/SemaTemplate/instantiate-enum.cpp b/test/SemaTemplate/instantiate-enum.cpp
index 3da8eb4a6c..701d1919b2 100644
--- a/test/SemaTemplate/instantiate-enum.cpp
+++ b/test/SemaTemplate/instantiate-enum.cpp
@@ -29,13 +29,14 @@ namespace PR6375 {
namespace EnumScoping {
template <typename T>
-class C {
+struct C {
+ struct X {};
enum {
value = 42
};
};
-void f(int i, C<int>::C c) {
+void f(int i, C<int>::X c) {
int value;
}
diff --git a/test/SemaTemplate/instantiate-member-class.cpp b/test/SemaTemplate/instantiate-member-class.cpp
index 159bccb2c9..5a9e2e30e8 100644
--- a/test/SemaTemplate/instantiate-member-class.cpp
+++ b/test/SemaTemplate/instantiate-member-class.cpp
@@ -39,8 +39,8 @@ public:
X<int>::C *c1;
X<float>::C *c2;
-X<int>::X *xi; // expected-error{{qualified reference to 'X' is a constructor name rather than a type wherever a constructor can be declared}}
-X<float>::X *xf; // expected-error{{qualified reference to 'X' is a constructor name rather than a type wherever a constructor can be declared}}
+X<int>::X *xi; // expected-error{{qualified reference to 'X' is a constructor name rather than a type}}
+X<float>::X *xf; // expected-error{{qualified reference to 'X' is a constructor name rather than a type}}
void test_naming() {
c1 = c2; // expected-error{{assigning to 'X<int>::C *' from incompatible type 'X<float>::C *'}}
diff --git a/test/SemaTemplate/ms-sizeof-missing-typename.cpp b/test/SemaTemplate/ms-sizeof-missing-typename.cpp
index ff8984feb7..9bafe6c98c 100644
--- a/test/SemaTemplate/ms-sizeof-missing-typename.cpp
+++ b/test/SemaTemplate/ms-sizeof-missing-typename.cpp
@@ -53,7 +53,7 @@ namespace ambiguous_missing_parens {
// expected-error@+1 {{'Q::U' instantiated to a class template, not a function template}}
template <typename T> void f() { int a = sizeof T::template U<0> + 4; }
struct Q {
- // expected-error@+1 {{class template declared here}}
+ // expected-note@+1 {{class template declared here}}
template <int> struct U {};
};
// expected-note-re@+1 {{in instantiation {{.*}} requested here}}