From: Nathan Sidwell Date: Thu, 7 Jun 2001 16:15:45 +0000 (+0000) Subject: re PR c++/2914 (gcc 3.0 crashes on xalan DoubleSupport.cpp) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fcebb2ddda6b7ed8726b6a04348b3f8d99eb580f;p=gcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8ba7f9f1966..39ff3399c08 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2001-06-07 Nathan Sidwell + + PR c++/2914 + * decl.c (pushtag): Don't push into a complete type's scope. + 2001-06-06 Jason Merrill * cp-tree.h (THUNK_GENERATE_WITH_VTABLE_P): Lose. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index ed5686c501f..22fb9ef7974 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 0732fb38b07..4a775683024 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2001-06-07 Nathan Sidwell + + * g++.old-deja/g++.ext/anon3.C: New test. + 2001-06-05 Nathan Sidwell * 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 00000000000..f4b99036629 --- /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 + +// 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() +{ +}