diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-11-08 17:17:31 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-11-08 17:17:31 +0000 |
commit | ef6e647b8d3268a765c2c4dd7f8a73cad281a8e6 (patch) | |
tree | 7c2cf4ee0c7bb0ef71add2c96f621cdfd3f1ea2b /test/SemaCXX/nested-name-spec.cpp | |
parent | 751810234ffb45327f23c5f9fda0b944e480bd2b (diff) |
Implement Sema support for C++ nested-name-specifiers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58916 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/nested-name-spec.cpp')
-rw-r--r-- | test/SemaCXX/nested-name-spec.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test/SemaCXX/nested-name-spec.cpp b/test/SemaCXX/nested-name-spec.cpp new file mode 100644 index 0000000000..bbca04cd9a --- /dev/null +++ b/test/SemaCXX/nested-name-spec.cpp @@ -0,0 +1,56 @@ +// RUN: clang -fsyntax-only -verify %s +namespace A { + struct C { + static int cx; + }; + int ax; + void Af(); +} + +A:: ; // expected-error {{expected unqualified-id}} +::A::ax::undef ex3; // expected-error {{expected a class or namespace}} expected-error {{expected '=', ',', ';', 'asm', or '__attribute__' after declarator}} +A::undef1::undef2 ex4; // expected-error {{no member named 'undef1'}} expected-error {{expected '=', ',', ';', 'asm', or '__attribute__' after declarator}} + +class C2 { + void m(); + int x; +}; + +void C2::m() { + x = 0; +} + +namespace B { + void ::A::Af() {} // expected-error {{definition or redeclaration for 'Af' not in a namespace enclosing 'A'}} +} + +void f1() { + void A::Af(); // expected-error {{definition or redeclaration for 'Af' not allowed inside a function}} +} + +void f2() { + A:: ; // expected-error {{expected unqualified-id}} + A::C::undef = 0; // expected-error {{no member named 'undef'}} + ::A::C::cx = 0; + int x = ::A::ax = A::C::cx; + x = sizeof(A::C); + x = sizeof(::A::C::cx); +} + +A::C c1; +struct A::C c2; +struct S : public A::C {}; +struct A::undef; // expected-error {{'undef' does not name a tag member in the specified scope}} + +void f3() { + N::x = 0; // expected-error {{use of undeclared identifier 'N'}} + int N; + N::x = 0; // expected-error {{expected a class or namespace}} + { int A; A::ax = 0; } + { enum A {}; A::ax = 0; } + { enum A { A }; A::ax = 0; } + { typedef int A; A::ax = 0; } + { typedef int A(); A::ax = 0; } + { typedef A::C A; A::ax = 0; } // expected-error {{no member named 'ax'}} + { typedef A::C A; A::cx = 0; } +} |