public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paolo Carlini <paolo.carlini@oracle.com>
To: Jason Merrill <jason@redhat.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [C++ Patch] PR 84632 ("[8 Regression] internal compiler error: tree check: expected record_type or union_type or qual_union_type, have array_type in reduced_constant_expression_p...")
Date: Fri, 23 Mar 2018 10:48:00 -0000	[thread overview]
Message-ID: <e00e4910-fd52-1dc4-f8c8-a52c0ac44112@oracle.com> (raw)
In-Reply-To: <CADzB+2kL+jrm7NTWwWa-Tm_0sx0njMZqfswVrCWnvzKech7reg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1006 bytes --]

Hi,

On 22/03/2018 23:26, Jason Merrill wrote:
> On Thu, Mar 22, 2018 at 5:39 PM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
>> ... with patch ;)
>>
>> If you are curious where the heck that INDIRECT_REF is coming from, is
>> coming from the gimplifier, cp_gimpliify_expr, via build_vec_init. Grrr.
> Hmm, maybe build_vec_init should call itself directly rather than via
> build_aggr_init in the case of multidimensional arrays.
Yes, arranging things like that seems doable. However, yesterday, while 
fiddling with the idea and instrumenting the code with some gcc_asserts, 
I noticed that we have yet another tree code to handle, TARGET_EXPR, as 
in lines #41, #47, #56 of ext/complit12.C, and in that case 
build_aggr_init is simply called by check_initializer via 
build_aggr_init_full_exprs, the "normal" path. Well, unless we want to 
adjust/reject complit12.C too, which clang rejects, in fact with errors 
on lines #19 and #29 too. The below passes testing.

Thanks,
Paolo.

/////////////////

[-- Attachment #2: patch_84632_3 --]
[-- Type: text/plain, Size: 2548 bytes --]

Index: cp/init.c
===================================================================
--- cp/init.c	(revision 258758)
+++ cp/init.c	(working copy)
@@ -1688,14 +1688,6 @@ build_aggr_init (tree exp, tree init, int flags, t
 	}
       else
 	{
-	  /* An array may not be initialized use the parenthesized
-	     initialization form -- unless the initializer is "()".  */
-	  if (init && TREE_CODE (init) == TREE_LIST)
-	    {
-	      if (complain & tf_error)
-		error ("bad array initializer");
-	      return error_mark_node;
-	    }
 	  /* Must arrange to initialize each element of EXP
 	     from elements of INIT.  */
 	  if (cv_qualified_p (type))
@@ -1705,14 +1697,16 @@ build_aggr_init (tree exp, tree init, int flags, t
 	  from_array = (itype && same_type_p (TREE_TYPE (init),
 					      TREE_TYPE (exp)));
 
-	  if (init && !from_array
-	      && !BRACE_ENCLOSED_INITIALIZER_P (init))
+	  if (init && !BRACE_ENCLOSED_INITIALIZER_P (init)
+	      && (!from_array
+		  || (TREE_CODE (init) != CONSTRUCTOR
+		      && TREE_CODE (init) != INDIRECT_REF
+		      && TREE_CODE (init) != TARGET_EXPR)))
 	    {
 	      if (complain & tf_error)
-		permerror (init_loc, "array must be initialized "
-			   "with a brace-enclosed initializer");
-	      else
-		return error_mark_node;
+		error_at (init_loc, "array must be initialized "
+			  "with a brace-enclosed initializer");
+	      return error_mark_node;
 	    }
 	}
 
Index: testsuite/g++.dg/init/array49.C
===================================================================
--- testsuite/g++.dg/init/array49.C	(nonexistent)
+++ testsuite/g++.dg/init/array49.C	(working copy)
@@ -0,0 +1,6 @@
+// PR c++/84632
+// { dg-additional-options "-w" }
+
+class {
+  &a;  // { dg-error "forbids declaration" }
+} b[2] = b;  // { dg-error "initialized" }
Index: testsuite/g++.dg/torture/pr70499.C
===================================================================
--- testsuite/g++.dg/torture/pr70499.C	(revision 258758)
+++ testsuite/g++.dg/torture/pr70499.C	(working copy)
@@ -1,5 +1,5 @@
 // { dg-do compile }
-// { dg-additional-options "-w -fpermissive -Wno-psabi" }
+// { dg-additional-options "-w -Wno-psabi" }
 // { dg-additional-options "-mavx" { target x86_64-*-* i?86-*-* } }
 
 typedef double __m256d __attribute__ ((__vector_size__ (32), __may_alias__));
@@ -30,7 +30,7 @@ struct Foo {
 template<typename Tx>  
 __attribute__((__always_inline__)) inline void inlineFunc(Tx hx[]) {
     Tx x = hx[0], y = hx[1];
-    Tx lam[1] = (x*y);
+    Tx lam[1] = {(x*y)};
 }
 
 void FooBarFunc () {

  reply	other threads:[~2018-03-23 10:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-22  8:12 Paolo Carlini
2018-03-22 18:11 ` Jason Merrill
2018-03-22 19:04   ` Paolo Carlini
2018-03-22 21:19     ` Paolo Carlini
2018-03-22 21:30       ` Jason Merrill
2018-03-22 21:39         ` Paolo Carlini
2018-03-22 22:26           ` Paolo Carlini
2018-03-22 22:35             ` Jason Merrill
2018-03-23 10:48               ` Paolo Carlini [this message]
2018-03-23 12:45                 ` Jason Merrill
2018-03-26 10:30                   ` Paolo Carlini
2018-03-26 17:17                     ` Jason Merrill
2018-03-26 18:25                       ` Paolo Carlini
2018-03-26 18:33                         ` Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e00e4910-fd52-1dc4-f8c8-a52c0ac44112@oracle.com \
    --to=paolo.carlini@oracle.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).