public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/66515 (ICE with initializer_list)
@ 2015-06-17 20:49 Jason Merrill
  2015-06-18 11:04 ` Andreas Schwab
  2015-06-22 17:27 ` Jason Merrill
  0 siblings, 2 replies; 4+ messages in thread
From: Jason Merrill @ 2015-06-17 20:49 UTC (permalink / raw)
  To: gcc-patches List

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

Now that reshape_init can return a non-CONSTRUCTOR, we need to call it 
earlier in implicit_conversion.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: 66515.patch --]
[-- Type: text/x-patch, Size: 1972 bytes --]

commit 3732672177a2f4893d79279d44b5caed24d6177b
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jun 17 07:45:03 2015 -0400

    	PR c++/66515
    	* call.c (implicit_conversion): Call reshape_init here, early.
    	(build_aggr_conv): Not here.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 2f0c53a..1787576 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -871,9 +871,7 @@ build_aggr_conv (tree type, tree ctor, int flags, tsubst_flags_t complain)
   tree field = next_initializable_field (TYPE_FIELDS (type));
   tree empty_ctor = NULL_TREE;
 
-  ctor = reshape_init (type, ctor, tf_none);
-  if (ctor == error_mark_node)
-    return NULL;
+  /* We already called reshape_init in implicit_conversion.  */
 
   /* The conversions within the init-list aren't affected by the enclosing
      context; they're always simple copy-initialization.  */
@@ -1762,6 +1760,17 @@ implicit_conversion (tree to, tree from, tree expr, bool c_cast_p,
      to that conversion.  */
   complain &= ~tf_error;
 
+  /* Call reshape_init early to remove redundant braces.  */
+  if (expr && BRACE_ENCLOSED_INITIALIZER_P (expr)
+      && COMPLETE_TYPE_P (complete_type (to))
+      && CP_AGGREGATE_TYPE_P (to))
+    {
+      expr = reshape_init (to, expr, complain);
+      if (expr == error_mark_node)
+	return NULL;
+      from = TREE_TYPE (expr);
+    }
+
   if (TREE_CODE (to) == REFERENCE_TYPE)
     conv = reference_binding (to, from, expr, c_cast_p, flags, complain);
   else
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist96.C b/gcc/testsuite/g++.dg/cpp0x/initlist96.C
new file mode 100644
index 0000000..305565c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist96.C
@@ -0,0 +1,19 @@
+// PR c++/66515
+// { dg-do compile { target c++11 } }
+
+namespace std
+{
+  template <class _E> class initializer_list
+  {
+    const _E *_M_array;
+    unsigned long _M_len;
+  };
+}
+
+struct type_t { };
+
+type_t &
+get ()
+{
+  std::initializer_list<type_t>{ { get () } };
+}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: C++ PATCH for c++/66515 (ICE with initializer_list)
  2015-06-17 20:49 C++ PATCH for c++/66515 (ICE with initializer_list) Jason Merrill
@ 2015-06-18 11:04 ` Andreas Schwab
  2015-06-18 13:55   ` Jason Merrill
  2015-06-22 17:27 ` Jason Merrill
  1 sibling, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2015-06-18 11:04 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches List

spawn /daten/aranym/gcc/gcc-20150618/Build/gcc/testsuite/g++/../../xg++ -B/daten/aranym/gcc/gcc-20150618/Build/gcc/testsuite/g++/../../ /daten/aranym/gcc/gcc-20150618/gcc/testsuite/g++.dg/cpp0x/initlist96.C -fno-diagnostics-show-caret -fdiagnostics-color=never -nostdinc++ -I/daten/aranym/gcc/gcc-20150618/Build/m68k-linux/libstdc++-v3/include/m68k-linux -I/daten/aranym/gcc/gcc-20150618/Build/m68k-linux/libstdc++-v3/include -I/daten/aranym/gcc/gcc-20150618/libstdc++-v3/libsupc++ -I/daten/aranym/gcc/gcc-20150618/libstdc++-v3/include/backward -I/daten/aranym/gcc/gcc-20150618/libstdc++-v3/testsuite/util -fmessage-length=0 -std=c++11 -pedantic-errors -Wno-long-long -S -o initlist96.s.
/daten/aranym/gcc/gcc-20150618/gcc/testsuite/g++.dg/cpp0x/initlist96.C:6:29: fatal error: definition of std::initializer_list does not match #include <initializer_list>.
compilation terminated..
compiler exited with status 1
output is:
/daten/aranym/gcc/gcc-20150618/gcc/testsuite/g++.dg/cpp0x/initlist96.C:6:29: fatal error: definition of std::initializer_list does not match #include <initializer_list>.
compilation terminated..

FAIL: g++.dg/cpp0x/initlist96.C  -std=c++11 (test for excess errors)

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: C++ PATCH for c++/66515 (ICE with initializer_list)
  2015-06-18 11:04 ` Andreas Schwab
@ 2015-06-18 13:55   ` Jason Merrill
  0 siblings, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2015-06-18 13:55 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: gcc-patches List

Should be fixed, thanks.

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: C++ PATCH for c++/66515 (ICE with initializer_list)
  2015-06-17 20:49 C++ PATCH for c++/66515 (ICE with initializer_list) Jason Merrill
  2015-06-18 11:04 ` Andreas Schwab
@ 2015-06-22 17:27 ` Jason Merrill
  1 sibling, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2015-06-22 17:27 UTC (permalink / raw)
  To: gcc-patches List

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

On 06/17/2015 04:44 PM, Jason Merrill wrote:
> Now that reshape_init can return a non-CONSTRUCTOR, we need to call it
> earlier in implicit_conversion.

I haven't noticed any problems with the original patch, but just to be 
safe this patch limits the new reshape to the same conditions as the old 
one: only classes.

Tested x86_64-pc-linux-gnu,


[-- Attachment #2: 66515-2.patch --]
[-- Type: text/x-patch, Size: 772 bytes --]

commit 98a362ded24db54963524761c3b0613ff844de51
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Jun 19 15:29:58 2015 -0400

    	PR c++/66515
    	* call.c (implicit_conversion): Only reshape for classes.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index ba5da4c..a6c313a 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -1759,8 +1759,9 @@ implicit_conversion (tree to, tree from, tree expr, bool c_cast_p,
 
   /* Call reshape_init early to remove redundant braces.  */
   if (expr && BRACE_ENCLOSED_INITIALIZER_P (expr)
+      && CLASS_TYPE_P (to)
       && COMPLETE_TYPE_P (complete_type (to))
-      && CP_AGGREGATE_TYPE_P (to))
+      && !CLASSTYPE_NON_AGGREGATE (to))
     {
       expr = reshape_init (to, expr, complain);
       if (expr == error_mark_node)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-06-22 17:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-17 20:49 C++ PATCH for c++/66515 (ICE with initializer_list) Jason Merrill
2015-06-18 11:04 ` Andreas Schwab
2015-06-18 13:55   ` Jason Merrill
2015-06-22 17:27 ` Jason Merrill

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).