This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: PR 24302
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 10 Oct 2005 23:30:00 -0700
- Subject: C++ PATCH: PR 24302
- Reply-to: mark at codesourcery dot com
This patch fixes a crash with anonymous unions, probably introduced
during one or another of the various reworkings of the C front end,
C++ front end, or global variable processing.
Tested on x86_64-unknown-linux-gnu, applied on the mainline and on the
4.0 branch.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
2005-10-10 Mark Mitchell <mark@codesourcery.com>
PR c++/24302
* toplev.c (check_global_declaration_1): Robustify.
2005-10-10 Mark Mitchell <mark@codesourcery.com>
PR c++/24302
* g++.dg/warn/Wunused-12.C: New test.
Index: gcc/toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.976
diff -c -5 -p -r1.976 toplev.c
*** gcc/toplev.c 5 Oct 2005 18:19:25 -0000 1.976
--- gcc/toplev.c 11 Oct 2005 06:15:53 -0000
*************** check_global_declaration_1 (tree decl)
*** 834,844 ****
&& TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
&& ! DECL_IN_SYSTEM_HEADER (decl)
&& ! TREE_USED (decl)
/* The TREE_USED bit for file-scope decls is kept in the identifier,
to handle multiple external decls in different scopes. */
! && ! TREE_USED (DECL_NAME (decl))
&& ! DECL_EXTERNAL (decl)
&& ! TREE_PUBLIC (decl)
/* A volatile variable might be used in some non-obvious way. */
&& ! TREE_THIS_VOLATILE (decl)
/* Global register variables must be declared to reserve them. */
--- 834,844 ----
&& TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
&& ! DECL_IN_SYSTEM_HEADER (decl)
&& ! TREE_USED (decl)
/* The TREE_USED bit for file-scope decls is kept in the identifier,
to handle multiple external decls in different scopes. */
! && ! (DECL_NAME (decl) && TREE_USED (DECL_NAME (decl)))
&& ! DECL_EXTERNAL (decl)
&& ! TREE_PUBLIC (decl)
/* A volatile variable might be used in some non-obvious way. */
&& ! TREE_THIS_VOLATILE (decl)
/* Global register variables must be declared to reserve them. */
Index: gcc/testsuite/g++.dg/warn/Wunused-12.C
===================================================================
RCS file: gcc/testsuite/g++.dg/warn/Wunused-12.C
diff -N gcc/testsuite/g++.dg/warn/Wunused-12.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/g++.dg/warn/Wunused-12.C 11 Oct 2005 06:15:53 -0000
***************
*** 0 ****
--- 1,8 ----
+ // PR c++/24302
+ // { dg-options "-Wunused" }
+
+ static union
+ {
+ unsigned char FLT4ARR[4];
+ float FLT4;
+ }; // { dg-warning "used" }