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] Splice when giving an error (PR c++/58510)


The following testcase ICEd because complete_ctor_at_level_p got
a union with two initializers - and didn't like that.  I think we can
get away with splicing when sorting the initializers: we already gave
an error and the program isn't accepted.

Regtested/bootstrapped on x86_64-linux, ok for trunk?

2013-09-25  Marek Polacek  <polacek@redhat.com>

	PR c++/58510
cp/
	* init.c (sort_mem_initializers): Splice when giving an error.
testsuite/
	* g++.dg/cpp0x/pr58510.C: New test.

--- gcc/cp/init.c.mp	2013-09-25 11:50:18.246432664 +0200
+++ gcc/cp/init.c	2013-09-25 11:50:18.262432728 +0200
@@ -980,9 +980,12 @@ sort_mem_initializers (tree t, tree mem_
 	      else if (TREE_VALUE (*last_p) && !TREE_VALUE (init))
 		goto splice;
 	      else
-		error_at (DECL_SOURCE_LOCATION (current_function_decl),
-			  "initializations for multiple members of %qT",
-			  ctx);
+		{
+		  error_at (DECL_SOURCE_LOCATION (current_function_decl),
+			    "initializations for multiple members of %qT",
+			    ctx);
+		  goto splice;
+		}
 	    }
 
 	  last_p = p;
--- gcc/testsuite/g++.dg/cpp0x/pr58510.C.mp	2013-09-25 12:19:02.612137551 +0200
+++ gcc/testsuite/g++.dg/cpp0x/pr58510.C	2013-09-25 12:45:13.157119958 +0200
@@ -0,0 +1,11 @@
+// PR c++/58510
+// { dg-do compile { target c++11 } }
+
+void foo()
+{
+  union
+  {		// { dg-error "multiple" }
+    int i = 0;
+    char c = 0;
+  };
+}

	Marek


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