This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
fix assert fail in C++ -g2 with #pragma interface typedef in namespace
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 13 Feb 2007 02:57:17 -0200
- Subject: fix assert fail in C++ -g2 with #pragma interface typedef in namespace
If a dwarf2 die node in limbo has a context that's a namespace, as
opposed to a function, the assertion patched below fails, even though
it ought to be perfectly acceptable to have a namespace as the context
in this case.
Tested on x86_64-linux-gnu. Ok to install?
:ADDPATCH dwarf2:
for gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* dwarf2out.c (dwarf2out_finish): Accept namespaces as context of
limbo die nodes.
for gcc/testsuite/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* g++.dg/ext/interface4.C, g++.dg/ext/interface4.h: New.
Index: trunk/gcc/dwarf2out.c
===================================================================
--- trunk.orig/gcc/dwarf2out.c 2007-02-11 21:10:26.000000000 -0200
+++ trunk/gcc/dwarf2out.c 2007-02-13 02:30:22.000000000 -0200
@@ -14359,7 +14359,9 @@ dwarf2out_finish (const char *filename)
else if (TYPE_P (node->created_for))
context = TYPE_CONTEXT (node->created_for);
- gcc_assert (context && TREE_CODE (context) == FUNCTION_DECL);
+ gcc_assert (context
+ && (TREE_CODE (context) == FUNCTION_DECL
+ || TREE_CODE (context) == NAMESPACE_DECL));
origin = lookup_decl_die (context);
if (origin)
Index: trunk/gcc/testsuite/g++.dg/ext/interface4.C
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ trunk/gcc/testsuite/g++.dg/ext/interface4.C 2007-02-13 02:51:51.000000000 -0200
@@ -0,0 +1,13 @@
+/* https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=227376 */
+
+/* { dg-do compile } */
+/* { dg-options "-g2" } */
+
+/* We used to crash when emitting debug info for type N::A because its
+ context was a namespace, not a function. */
+
+#include "interface4.h"
+
+void f ( ) {
+ g ( );
+}
Index: trunk/gcc/testsuite/g++.dg/ext/interface4.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ trunk/gcc/testsuite/g++.dg/ext/interface4.h 2007-02-13 02:12:39.000000000 -0200
@@ -0,0 +1,8 @@
+#pragma interface
+namespace N {
+ typedef int A;
+}
+inline void g ( ) {
+ static N :: A a = 0;
+ a = a;
+}
--
Alexandre Oliva http://www.lsd.ic.unicamp.br/~oliva/
FSF Latin America Board Member http://www.fsfla.org/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}