diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/g++.dg/warn/forward-inner.C | |
download | cbb-gcc-4.6.4-upstream.tar.bz2 cbb-gcc-4.6.4-upstream.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/g++.dg/warn/forward-inner.C')
-rw-r--r-- | gcc/testsuite/g++.dg/warn/forward-inner.C | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/warn/forward-inner.C b/gcc/testsuite/g++.dg/warn/forward-inner.C new file mode 100644 index 000000000..dae99486a --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/forward-inner.C @@ -0,0 +1,81 @@ +// Check that the compiler warns about inner-style forward declarations in +// contexts where they're not actually illegal, but merely useless. + +// Verify warnings for and within classes, and by extension, struct and union. +class C1; +class C1::C2; // { dg-error "does not name a type" } +class C1::C2::C3; // { dg-error "has not been declared" } + +class C1 { + public: + class C2; + class C2::C3; // { dg-error "does not name a type" } + class C2 { + public: + class C3; + class C3 { }; + class C3; + }; + class C2; + class C2::C3; // { dg-warning "declaration 'class C1::C2::C3' does not declare anything" } +}; + +class C1; +class C1::C2; // { dg-warning "declaration 'class C1::C2' does not declare anything" } +class C1::C2::C3; // { dg-warning "declaration 'class C1::C2::C3' does not declare anything" } + + +// Verify warnings for namespace scopes. +class N1::C4; // { dg-error "has not been declared" } +class N1::N2::C5; // { dg-error "has not been declared" } + +namespace N1 { + class C4; + class C4 { }; + class C4; + + class N2::C5; // { dg-error "has not been declared" } + namespace N2 { + class C5; + class C5 { }; + class C5; + } + class N2::C5; // { dg-warning "declaration 'class N1::N2::C5' does not declare anything" } +} + +class N1::C4; // { dg-warning "declaration 'class N1::C4' does not declare anything" } +class N1::N2::C5; // { dg-warning "declaration 'class N1::N2::C5' does not declare anything" } + + +// Verify that using declarations related to namespaces don't generate a +// warning. +using namespace N1; +using namespace N1::N2; + +namespace N3 { + using N1::C4; // Valid using declaration, no warning + using N1::N2::C5; // Valid using declaration, no warning +} + + +// Verify that explicit template instantiations, easy to confuse with +// forward declarations, don't generate a warning. +template<class C> +class TC6 { + public: + class TC7 { }; +}; + +template class TC6<int>::TC7; // Valid explicit instantiation, no warning + + +// Verify that friend declarations, also easy to confuse with forward +// declrations, are similarly not warned about. +class C8 { + public: + class C9 { }; +}; +class C10 { + public: + friend class C8::C9; // Valid friend declaration, no warning +}; |