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]

Re: RFC: PATCH: PR c++/45709: [4.3/4.4/4.5/4.6 regression] internal compiler error: in add_phi_arg, at tree-phinodes.c:395


On Fri, Sep 17, 2010 at 05:15:32PM -0700, H.J. Lu wrote:
> On Fri, Sep 17, 2010 at 03:49:10PM -0700, H.J. Lu wrote:
> > Hi,
> > 
> > This patch reverts the build_aggr_init change in revision 127647:
> > 
> > http://gcc.gnu.org/ml/gcc-cvs/2007-08/msg00541.html
> > 
> > Does it make any senses?
> > 
> > Thanks.
> > 
> > 
> 
> I missed another part.
> 
> 

Slight update to fix g++.dg/conversion/op5.C regresion.


H.J.
---
gcc/

2010-09-17  H.J. Lu  <hongjiu.lu@intel.com>

	PR c++/45709
	* init.c (build_aggr_init): Properly set const type.

gcc/testsuite/

2010-09-17  H.J. Lu  <hongjiu.lu@intel.com>

	PR c++/45709
	* g++.dg/torture/pr45709.C: New.

diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 189bcbe..b88384b 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -1316,6 +1316,8 @@ build_aggr_init (tree exp, tree init, int flags, tsubst_flags_t complain)
     /* Just know that we've seen something for this node.  */
     TREE_USED (exp) = 1;
 
+  if (was_const != TYPE_READONLY (TYPE_MAIN_VARIANT (type)))
+    TREE_TYPE (exp) = TYPE_MAIN_VARIANT (type);
   is_global = begin_init_stmts (&stmt_expr, &compound_stmt);
   destroy_temps = stmts_are_full_exprs_p ();
   current_stmt_tree ()->stmts_are_full_exprs_p = 0;
@@ -1323,6 +1325,8 @@ build_aggr_init (tree exp, tree init, int flags, tsubst_flags_t complain)
 		      init, LOOKUP_NORMAL|flags, complain);
   stmt_expr = finish_init_stmts (is_global, stmt_expr, compound_stmt);
   current_stmt_tree ()->stmts_are_full_exprs_p = destroy_temps;
+  if (was_const != TYPE_READONLY (TYPE_MAIN_VARIANT (type)))
+    TREE_TYPE (exp) = type;
   TREE_READONLY (exp) = was_const;
   TREE_THIS_VOLATILE (exp) = was_volatile;
 
--- /dev/null	2010-09-09 09:16:30.485584932 -0700
+++ gcc/gcc/testsuite/g++.dg/torture/pr45709.C	2010-09-17 15:15:22.000000000 -0700
@@ -0,0 +1,17 @@
+struct Region {
+    int storage[4];
+    int count;
+};
+static inline Region subtract(int lhs)
+{
+  Region reg;
+  int* storage = reg.storage;
+  if (lhs > 0)
+    storage++;
+  reg.count = storage - reg.storage;
+  return reg;
+}
+void bar(int a)
+{
+  const Region copyBack(subtract(a));
+}


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