diff options
author | John McCall <rjmccall@apple.com> | 2009-09-11 04:59:25 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2009-09-11 04:59:25 +0000 |
commit | c4e7019d5c9034a2d84ee4695f8e98dc025ac131 (patch) | |
tree | da8b19b3e6e6f62ddc50db7209b8dd0421fd15a8 /test | |
parent | 66847a2826c97b8e09aec304a0a7b4fe1dc35969 (diff) |
Support elaborated dependent types and diagnose tag mismatches.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81504 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp | 4 | ||||
-rw-r--r-- | test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp | 61 |
2 files changed, 64 insertions, 1 deletions
diff --git a/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp b/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp index 4dc1cc7d7a..5346f36739 100644 --- a/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp +++ b/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp @@ -11,7 +11,9 @@ namespace A { template <typename> void Ident(); class Ident<int> AIdent; // expected-error {{refers to a function template}} - class ::Ident<int> AnotherIdent; + + // FIXME: this note should be on the template declaration, not the point of instantiation + class ::Ident<int> AnotherIdent; // expected-note {{previous use is here}} } class Ident<int> GlobalIdent; diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp new file mode 100644 index 0000000000..0c9f294d2b --- /dev/null +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp @@ -0,0 +1,61 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +class A {}; // expected-note 3 {{previous use is here}} + +void a1(struct A); +void a2(class A); +void a3(union A); // expected-error {{use of 'A' with tag type that does not match previous declaration}} +void a4(enum A); // expected-error {{use of 'A' with tag type that does not match previous declaration}} + +class A1 { + friend struct A; + friend class A; + friend union A; // expected-error {{use of 'A' with tag type that does not match previous declaration}} + + // FIXME: a better error would be something like 'enum types cannot be friends' + friend enum A; // expected-error {{ISO C++ forbids forward references to 'enum' types}} +}; + +template <class T> struct B { + class Member {}; // expected-note 2 {{previous use is here}} +}; + +template <> class B<int> { + // no type Member +}; + +template <> struct B<A> { + // FIXME: the error here should be associated with the use at "void foo..." + union Member { // expected-note 4 {{previous use is here}} expected-error {{tag type that does not match previous declaration}} + void* a; + }; +}; + +// FIXME: this note should be on the template declaration, not the point of instantiation +void b1(struct B<float>); // expected-note {{previous use is here}} +void b2(class B<float>); +void b3(union B<float>); // expected-error {{use of 'B<float>' with tag type that does not match previous declaration}} +//void b4(enum B<float>); // this just doesn't parse; you can't template an enum directly + +void c1(struct B<float>::Member); +void c2(class B<float>::Member); +void c3(union B<float>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}} +void c4(enum B<float>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}} + +void d1(struct B<int>::Member); // expected-error {{'Member' does not name a tag member in the specified scope}} +void d2(class B<int>::Member); // expected-error {{'Member' does not name a tag member in the specified scope}} +void d3(union B<int>::Member); // expected-error {{'Member' does not name a tag member in the specified scope}} +void d4(enum B<int>::Member); // expected-error {{'Member' does not name a tag member in the specified scope}} + +void e1(struct B<A>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}} +void e2(class B<A>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}} +void e3(union B<A>::Member); +void e4(enum B<A>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}} + +template <class T> struct C { + void foo(class B<T>::Member); // expected-error{{no type named 'Member' in 'B'}} +}; + +C<float> f1; +C<int> f2; // expected-note {{in instantiation of template class}} +C<A> f3; // expected-note {{in instantiation of template class}} |