aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2003-10-23 02:41:31 -0400
committerJason Merrill <jason@gcc.gnu.org>2003-10-23 02:41:31 -0400
commit4b5aa8815e853a213360c7e35c0a2dad4ba9897f (patch)
treeb43baa27b85bb53207e381d66c7a05a9f2b0e456 /gcc
parent941ba69d8a6d1cee3ef3031729ccfbb282a0ce5f (diff)
downloadgcc-4b5aa8815e853a213360c7e35c0a2dad4ba9897f.zip
gcc-4b5aa8815e853a213360c7e35c0a2dad4ba9897f.tar.gz
gcc-4b5aa8815e853a213360c7e35c0a2dad4ba9897f.tar.bz2
re PR c++/12726 (ICE (segfault) on trivial code)
PR c++/12726 * tree.c (build_target_expr_with_type): Don't call force_rvalue for CONSTRUCTORs. From-SVN: r72837
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/tree.c6
-rw-r--r--gcc/testsuite/g++.dg/ext/complit2.C17
3 files changed, 27 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5096f74..2ce7c03 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2003-10-23 Jason Merrill <jason@redhat.com>
+
+ PR c++/12726
+ * tree.c (build_target_expr_with_type): Don't call force_rvalue
+ for CONSTRUCTORs.
+
2003-10-22 Kazu Hirata <kazu@cs.umass.edu>
* call.c: Fix comment formatting.
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index bfcf741..63fdb94 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -311,10 +311,12 @@ build_target_expr_with_type (tree init, tree type)
if (TREE_CODE (init) == TARGET_EXPR)
return init;
else if (CLASS_TYPE_P (type) && !TYPE_HAS_TRIVIAL_INIT_REF (type)
- && TREE_CODE (init) != COND_EXPR)
+ && TREE_CODE (init) != COND_EXPR
+ && TREE_CODE (init) != CONSTRUCTOR)
/* We need to build up a copy constructor call. COND_EXPR is a special
case because we already have copies on the arms and we don't want
- another one here. */
+ another one here. A CONSTRUCTOR is aggregate initialization, which
+ is handled separately. */
return force_rvalue (init);
slot = build_decl (VAR_DECL, NULL_TREE, type);
diff --git a/gcc/testsuite/g++.dg/ext/complit2.C b/gcc/testsuite/g++.dg/ext/complit2.C
new file mode 100644
index 0000000..a8fe874
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/complit2.C
@@ -0,0 +1,17 @@
+// PR c++/12726
+// { dg-options "" }
+
+#include <string>
+
+struct foobar {
+ std::string s;
+};
+
+int main(int argc, char **argv)
+{
+ foobar fb;
+
+ fb = (foobar) { "abcd" };
+
+ return 0;
+}