aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2001-06-07 16:15:45 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2001-06-07 16:15:45 +0000
commitfcebb2ddda6b7ed8726b6a04348b3f8d99eb580f (patch)
tree91c75aac457506aea43d77e9794ceba61ae50e63
parentd7e5d7feae8162262948978355a6a1c8aebb9b9d (diff)
downloadgcc-fcebb2ddda6b7ed8726b6a04348b3f8d99eb580f.zip
gcc-fcebb2ddda6b7ed8726b6a04348b3f8d99eb580f.tar.gz
gcc-fcebb2ddda6b7ed8726b6a04348b3f8d99eb580f.tar.bz2
re PR c++/2914 (gcc 3.0 crashes on xalan DoubleSupport.cpp)
cp: PR c++/2914 * decl.c (pushtag): Don't push into a complete type's scope. testsuite: * g++.old-deja/g++.ext/anon3.C: New test. From-SVN: r42962
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl.c8
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.ext/anon3.C36
4 files changed, 52 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 8ba7f9f..39ff339 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2001-06-07 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/2914
+ * decl.c (pushtag): Don't push into a complete type's scope.
+
2001-06-06 Jason Merrill <jason_merrill@redhat.com>
* cp-tree.h (THUNK_GENERATE_WITH_VTABLE_P): Lose.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index ed5686c..22fb9ef 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -2812,7 +2812,13 @@ pushtag (name, type, globalize)
b = current_binding_level;
while (b->tag_transparent
- || (globalize && b->parm_flag == 2))
+ || (b->parm_flag == 2
+ && (globalize
+ /* We may be defining a new type in the initializer
+ of a static member variable. We allow this when
+ not pedantic, and it is particularly useful for
+ type punning via an anonymous union. */
+ || COMPLETE_TYPE_P (b->this_class))))
b = b->level_chain;
b->tags = tree_cons (name, type, b->tags);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0732fb3..4a77568 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2001-06-07 Nathan Sidwell <nathan@codesourcery.com>
+
+ * g++.old-deja/g++.ext/anon3.C: New test.
+
2001-06-05 Nathan Sidwell <nathan@codesourcery.com>
* g++.old-deja/g++.other/conv7.C: New test.
diff --git a/gcc/testsuite/g++.old-deja/g++.ext/anon3.C b/gcc/testsuite/g++.old-deja/g++.ext/anon3.C
new file mode 100644
index 0000000..f4b9903
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.ext/anon3.C
@@ -0,0 +1,36 @@
+// Build don't link:
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 6 Jun 2001 <nathan@codesourcery.com>
+
+// Bug 2914. New types can be created in a static member
+// initializer. These should not be injected into the member's class's
+// scope.
+
+class DoubleSupport
+{
+ public:
+ static void toDouble();
+
+ static const double s_NaN;
+ static const double s_positiveInfinity;
+ static const double s_negativeInfinity;
+ static const double s_positiveZero;
+ static const double s_negativeZero;
+ static const unsigned long* s_NaNFirstDWORD;
+ static const unsigned long* s_NaNSecondDWORD;
+};
+
+const double DoubleSupport::s_positiveInfinity =
+(__extension__ ((union { unsigned char __c[8]; double __d; })
+ { __c: { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } }).__d);
+
+struct other
+{
+};
+
+
+void
+DoubleSupport::toDouble()
+{
+}