aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeongbae Park <seongbae.park@gmail.com>2007-05-02 23:11:13 +0000
committerSeongbae Park <spark@gcc.gnu.org>2007-05-02 23:11:13 +0000
commitba99296704bd337a302e5dee43dc57f013d1177b (patch)
tree607c7af016a22b560e2c1a42510cf7ce4d505d96
parente0310afb08cc322a877a51e232bda6efe59d92ed (diff)
downloadgcc-ba99296704bd337a302e5dee43dc57f013d1177b.zip
gcc-ba99296704bd337a302e5dee43dc57f013d1177b.tar.gz
gcc-ba99296704bd337a302e5dee43dc57f013d1177b.tar.bz2
re PR c++/31663 (Segfault in constrain_class_visibility with anonymous namespace)
gcc/ChangeLog: 2007-05-02 Seongbae Park <seongbae.park@gmail.com> PR c++/31663 * c-common.c (strip_pointer_or_array_types): New function. * c-common.h (strip_pointer_or_array_types): New function declaration. gcc/cp/ChangeLog: 2007-05-02 Seongbae Park <seongbae.park@gmail.com> PR c++/31663 * decl2.c (constrain_class_visibility): Use strip_pointer_or_array_types instead of strip_array_types. gcc/testsuite/ChangeLog: 2007-05-02 Seongbae Park <seongbae.park@gmail.com> PR C++/31663 * g++.dg/warn/anonymous-namespace-2.C: New. * g++.dg/warn/anonymous-namespace-2.h: New. From-SVN: r124363
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/c-common.c9
-rw-r--r--gcc/c-common.h1
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl2.c2
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/warn/anonymous-namespace-2.C29
-rw-r--r--gcc/testsuite/g++.dg/warn/anonymous-namespace-2.h3
8 files changed, 61 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 49dcdb3..01aa44e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2007-05-02 Seongbae Park <seongbae.park@gmail.com>
+
+ PR c++/31663
+ * c-common.c (strip_pointer_or_array_types): New function.
+ * c-common.h (strip_pointer_or_array_types): New function declaration.
+
2007-05-03 Zdenek Dvorak <dvorakz@suse.cz>
PR tree-optimization/31771
diff --git a/gcc/c-common.c b/gcc/c-common.c
index d60b5a4..4e92ae6 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -3894,6 +3894,15 @@ strip_pointer_operator (tree t)
return t;
}
+/* Recursively remove pointer or array type from TYPE. */
+tree
+strip_pointer_or_array_types (tree t)
+{
+ while (TREE_CODE (t) == ARRAY_TYPE || POINTER_TYPE_P (t))
+ t = TREE_TYPE (t);
+ return t;
+}
+
/* Used to compare case labels. K1 and K2 are actually tree nodes
representing case labels, or NULL_TREE for a `default' label.
Returns -1 if K1 is ordered before K2, -1 if K1 is ordered after
diff --git a/gcc/c-common.h b/gcc/c-common.h
index b128e31..d4afaec 100644
--- a/gcc/c-common.h
+++ b/gcc/c-common.h
@@ -727,6 +727,7 @@ extern bool c_promoting_integer_type_p (tree);
extern int self_promoting_args_p (tree);
extern tree strip_array_types (tree);
extern tree strip_pointer_operator (tree);
+extern tree strip_pointer_or_array_types (tree);
extern HOST_WIDE_INT c_common_to_target_charset (HOST_WIDE_INT);
/* This is the basic parsing function. */
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 2a363c4..b2f34a3 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2007-05-02 Seongbae Park <seongbae.park@gmail.com>
+
+ PR c++/31663
+ * decl2.c (constrain_class_visibility):
+ Use strip_pointer_or_array_types instead of strip_array_types.
+
2007-04-28 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR C++/30221
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 4177828..5788f94 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -1856,7 +1856,7 @@ constrain_class_visibility (tree type)
for (t = TYPE_FIELDS (type); t; t = TREE_CHAIN (t))
if (TREE_CODE (t) == FIELD_DECL && TREE_TYPE (t) != error_mark_node)
{
- tree ftype = strip_array_types (TREE_TYPE (t));
+ tree ftype = strip_pointer_or_array_types (TREE_TYPE (t));
int subvis = type_visibility (ftype);
if (subvis == VISIBILITY_ANON)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ce5e78c..1ecf013 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2007-05-02 Seongbae Park <seongbae.park@gmail.com>
+
+ PR C++/31663
+ * g++.dg/warn/anonymous-namespace-2.C: New.
+ * g++.dg/warn/anonymous-namespace-2.h: New.
+
2007-05-02 Paul Brook <paul@codesourcery.com>
* gcc.dg/arm-eabi1.c: Move debug output. Augment lcmp/ulcmp tests.
diff --git a/gcc/testsuite/g++.dg/warn/anonymous-namespace-2.C b/gcc/testsuite/g++.dg/warn/anonymous-namespace-2.C
new file mode 100644
index 0000000..4d87b69
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/anonymous-namespace-2.C
@@ -0,0 +1,29 @@
+// Test for the warning of exposing types from an anonymous namespace
+// { dg-do compile }
+//
+#include "anonymous-namespace-2.h"
+
+namespace {
+ struct good { };
+}
+
+struct g1 {
+ good * A;
+};
+struct b1 { // { dg-warning "uses the anonymous namespace" }
+ bad * B;
+};
+
+struct g2 {
+ good * A[1];
+};
+struct b2 { // { dg-warning "uses the anonymous namespace" }
+ bad * B[1];
+};
+
+struct g3 {
+ good (*A)[1];
+};
+struct b3 { // { dg-warning "uses the anonymous namespace" }
+ bad (*B)[1];
+};
diff --git a/gcc/testsuite/g++.dg/warn/anonymous-namespace-2.h b/gcc/testsuite/g++.dg/warn/anonymous-namespace-2.h
new file mode 100644
index 0000000..ce5d05c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/anonymous-namespace-2.h
@@ -0,0 +1,3 @@
+namespace {
+ struct bad { };
+}