This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/43109 (ICE on class in unnamed namespace in std)


Can't assume DECL_NAME of a namespace is non-null.

Tested x86_64-pc-linux-gnu, applied to trunk.
commit 5e49b6327155e8c2bb3804eed9d395339d1df518
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Feb 17 18:02:09 2010 -0500

    	PR c++/43109
    	* semantics.c (begin_class_definition): Don't crash on unnamed ns.

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 90a76d9..24390d9 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2378,6 +2378,7 @@ begin_class_definition (tree t, tree attributes)
       tree ns = TYPE_CONTEXT (t);
       if (ns && TREE_CODE (ns) == NAMESPACE_DECL
 	  && DECL_CONTEXT (ns) == std_node
+	  && DECL_NAME (ns)
 	  && !strcmp (IDENTIFIER_POINTER (DECL_NAME (ns)), "decimal"))
 	{
 	  const char *n = TYPE_NAME_STRING (t);
diff --git a/gcc/testsuite/g++.dg/parse/namespace12.C b/gcc/testsuite/g++.dg/parse/namespace12.C
new file mode 100644
index 0000000..25d6ae0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/namespace12.C
@@ -0,0 +1,7 @@
+// PR c++/43109
+
+namespace std {
+ namespace {
+   struct S {};
+ }
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]