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++/58965 (ICE with NSDMI in static union)


In the case of a static anonymous union we have a decl with no DECL_NAME (just a DECL_ASSEMBLER_NAME), and write_guarded_name shouldn't crash.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 0d626f236f9daf2891362c17db1220214ab0a64d
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jan 2 22:50:11 2014 -0500

    	PR c++/58965
    	* mangle.c (write_guarded_var_name): Handle null DECL_NAME.

diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index b3bcc12..d6650d3 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -3778,7 +3778,8 @@ mangle_conv_op_name_for_type (const tree type)
 static void
 write_guarded_var_name (const tree variable)
 {
-  if (strncmp (IDENTIFIER_POINTER (DECL_NAME (variable)), "_ZGR", 4) == 0)
+  if (DECL_NAME (variable)
+      && strncmp (IDENTIFIER_POINTER (DECL_NAME (variable)), "_ZGR", 4) == 0)
     /* The name of a guard variable for a reference temporary should refer
        to the reference, not the temporary.  */
     write_string (IDENTIFIER_POINTER (DECL_NAME (variable)) + 4);
diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-union3.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-union3.C
new file mode 100644
index 0000000..35f6509
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-union3.C
@@ -0,0 +1,10 @@
+// PR c++/58965
+// { dg-require-effective-target c++11 }
+
+void foo()
+{
+  static union
+  {
+    int i = i;
+  };
+}

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