diff options
author | Seongbae Park <seongbae.park@gmail.com> | 2007-04-16 16:49:02 +0000 |
---|---|---|
committer | Seongbae Park <spark@gcc.gnu.org> | 2007-04-16 16:49:02 +0000 |
commit | 8fff206014983b3f02f42b442d4b7c94942fc1de (patch) | |
tree | a76fd122db7d411dbe53fb1858ea5a4f4db27197 /gcc | |
parent | de41203b65518a7a7a3ee16ae595b542021673b4 (diff) | |
download | gcc-8fff206014983b3f02f42b442d4b7c94942fc1de.zip gcc-8fff206014983b3f02f42b442d4b7c94942fc1de.tar.gz gcc-8fff206014983b3f02f42b442d4b7c94942fc1de.tar.bz2 |
re PR c++/29365 (Unnecessary anonymous namespace warnings)
gcc/ChangeLog:
2007-04-16 Seongbae Park <seongbae.park@gmail.com>
PR c++/29365
* cp/decl2.c (constrain_class_visibility):
Do not warn about the use of anonymous namespace in the main input file.
gcc/testsuite/ChangeLog:
2007-04-16 Seongbae Park <seongbae.park@gmail.com>
PR c++/29365
Testcase for c++ anonymous namespace warning
* g++.dg/warn/anonymous-namespace-1.C: New test
* g++.dg/warn/anonymous-namespace-1.h: New test
From-SVN: r123879
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/anonymous-namespace-1.C | 17 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/anonymous-namespace-1.h | 7 |
5 files changed, 51 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9a7c3cc..6448f7a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2007-04-16 Seongbae Park <seongbae.park@gmail.com> + + PR c++/29365 + + * cp/decl2.c (constrain_class_visibility): + Do not warn about the use of anonymous namespace in the main input file. + 2007-04-16 Kazu Hirata <kazu@codesourcery.com> * config/m68k/m68k.c (m68k_libcall_value, diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index bd07833..54d5aa2 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1860,9 +1860,13 @@ constrain_class_visibility (tree type) int subvis = type_visibility (ftype); if (subvis == VISIBILITY_ANON) - warning (0, "\ + { + if (strcmp (main_input_filename, + DECL_SOURCE_FILE (TYPE_MAIN_DECL (ftype)))) + warning (0, "\ %qT has a field %qD whose type uses the anonymous namespace", - type, t); + type, t); + } else if (IS_AGGR_TYPE (ftype) && vis < VISIBILITY_HIDDEN && subvis >= VISIBILITY_HIDDEN) @@ -1877,9 +1881,13 @@ constrain_class_visibility (tree type) int subvis = type_visibility (TREE_TYPE (t)); if (subvis == VISIBILITY_ANON) - warning (0, "\ + { + if (strcmp (main_input_filename, + DECL_SOURCE_FILE (TYPE_MAIN_DECL (TREE_TYPE (t))))) + warning (0, "\ %qT has a base %qT whose type uses the anonymous namespace", - type, TREE_TYPE (t)); + type, TREE_TYPE (t)); + } else if (vis < VISIBILITY_HIDDEN && subvis >= VISIBILITY_HIDDEN) warning (OPT_Wattributes, "\ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2e85f48..761a0ae 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2007-04-16 Seongbae Park <seongbae.park@gmail.com> + + PR c++/29365 + Testcase for c++ anonymous namespace warning + + * g++.dg/warn/anonymous-namespace-1.C: New test + * g++.dg/warn/anonymous-namespace-1.h: New test + 2007-04-14 Andrew Pinski <andrew_pinski@playstation.sony.com> PR testsuite/31578 diff --git a/gcc/testsuite/g++.dg/warn/anonymous-namespace-1.C b/gcc/testsuite/g++.dg/warn/anonymous-namespace-1.C new file mode 100644 index 0000000..6949f15 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/anonymous-namespace-1.C @@ -0,0 +1,17 @@ +// Test for the warning of exposing types from an anonymous namespace +// { dg-do compile } + +#include "anonymous-namespace-1.h" + +namespace { + class good { }; +} + +class foo::bar : public good { }; +class foobar1 +{ + good g; +}; + +class foobar : public bad { }; // { dg-warning "uses the anonymous namespace" } +class foobar2 { bad b; }; // { dg-warning "uses the anonymous namespace" } diff --git a/gcc/testsuite/g++.dg/warn/anonymous-namespace-1.h b/gcc/testsuite/g++.dg/warn/anonymous-namespace-1.h new file mode 100644 index 0000000..0d3e239 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/anonymous-namespace-1.h @@ -0,0 +1,7 @@ +class foo { + class bar; +}; + +namespace { + class bad { }; +} |