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] Fix finish_compound_literal (PR c++/27491, 4.1/4.2 regression)


Hi!

We ICE on the following testcase, because reshape_init changes a CONSTRUCTOR
into some other tree node (on the first line into INTEGER_CST, on the latter
two VAR_DECL) and TREE_HAS_CONSTRUCTOR is only valid for CONSTRUCTOR, while
e.g. on VAR_DECL it means DECL_TINFO_P and the ICE is when the FE expects
DECL_TINFO_P VAR_DECLs to have TREE_TYPE (DECL_NAME (decl)).

Bootstrapped/regtested on i686-linux, ok for trunk/4.1?

2006-05-16  Jakub Jelinek  <jakub@redhat.com>

	PR c++/27491
	* semantics.c (finish_compound_literal): Only set TREE_HAS_CONSTRUCTOR
	on CONSTRUCTORs.

	* g++.dg/init/brace5.C: New test.

--- gcc/cp/semantics.c.jj	2006-04-13 13:40:01.000000000 +0200
+++ gcc/cp/semantics.c	2006-05-16 15:31:33.000000000 +0200
@@ -2025,7 +2025,8 @@ finish_compound_literal (tree type, VEC(
     }
 
   /* Mark it as a compound-literal.  */
-  TREE_HAS_CONSTRUCTOR (compound_literal) = 1;
+  if (TREE_CODE (compound_literal) == CONSTRUCTOR)
+    TREE_HAS_CONSTRUCTOR (compound_literal) = 1;
 
   return compound_literal;
 }
--- gcc/testsuite/g++.dg/init/brace5.C.jj	2006-05-16 15:40:00.000000000 +0200
+++ gcc/testsuite/g++.dg/init/brace5.C	2006-05-16 15:36:47.000000000 +0200
@@ -0,0 +1,7 @@
+// PR c++/27491
+// { dg-do compile }
+// { dg-options "" }
+
+int i = (int) { 0 };
+int j = (int) { i };
+int k = (int) { k };

	Jakub


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