public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/60980 (value-initialization of array member)
@ 2014-04-30 14:25 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2014-04-30 14:25 UTC (permalink / raw)
  To: gcc-patches List

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

My change to handle trivial but not callable constructors mistakenly 
removed the check that an object is of class type before we try to call 
its constructor.

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

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

commit 3635dadac4d1e507b80f21f673530f322752df9b
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Apr 29 17:08:16 2014 -0400

    	PR c++/60980
    	* init.c (build_value_init): Don't try to call an array constructor.

diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 8b9405c..46422a5 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -339,7 +339,8 @@ build_value_init (tree type, tsubst_flags_t complain)
   gcc_assert (!processing_template_decl
 	      || (SCALAR_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE));
 
-  if (type_build_ctor_call (type))
+  if (CLASS_TYPE_P (type)
+      && type_build_ctor_call (type))
     {
       tree ctor = build_aggr_init_expr
 	(type,
diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted49.C b/gcc/testsuite/g++.dg/cpp0x/defaulted49.C
new file mode 100644
index 0000000..357be41
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/defaulted49.C
@@ -0,0 +1,15 @@
+// PR c++/60980
+// { dg-do compile { target c++11 } }
+
+struct x0
+{
+  x0 () = default;
+};
+struct x1
+{
+  x0 x2[2];
+  void x3 ()
+  {
+    x1 ();
+  }
+};

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-04-30 14:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-30 14:25 C++ PATCH for c++/60980 (value-initialization of array member) 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).