aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2020-03-10 16:05:18 -0400
committerJason Merrill <jason@redhat.com>2020-03-10 16:30:56 -0400
commit14af5d9b19b0f4ee1d929e505e245ae5c2f6bdc6 (patch)
treebab7ae0a1629bb7174dcab14477047e93da64e87 /gcc
parente00cb200f39d8144de226e76c5d0257b613dbbf6 (diff)
downloadgcc-14af5d9b19b0f4ee1d929e505e245ae5c2f6bdc6.zip
gcc-14af5d9b19b0f4ee1d929e505e245ae5c2f6bdc6.tar.gz
gcc-14af5d9b19b0f4ee1d929e505e245ae5c2f6bdc6.tar.bz2
c++: Partially revert patch for PR66139.
The patch for 66139 exposed a long-standing bug with split_nonconstant_init (since 4.7, apparently): initializion of individual elements of an aggregate are not a full-expressions, but split_nonconstant_init was making full-expressions out of them. My fix for 66139 extended the use of split_nonconstant_init, and thus the bug, to aggregate initialization of temporaries within an expression, in which context (PR94041) the bug is more noticeable. PR93922 is a problem with my implementation strategy of splitting out at gimplification time, introducing function calls that weren't in the GENERIC. So I'm going to revert the patch now and try again for GCC 11. gcc/cp/ChangeLog 2020-03-10 Jason Merrill <jason@redhat.com> PR c++/93922 PR c++/94041 PR c++/52320 PR c++/66139 * cp-gimplify.c (cp_gimplify_init_expr): Partially revert patch for 66139: Don't split_nonconstant_init. Remove pre_p parameter.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/cp-gimplify.c20
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist116.C29
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist117.C40
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh.C34
-rw-r--r--gcc/testsuite/g++.dg/eh/aggregate1.C56
6 files changed, 11 insertions, 177 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index d9807ad..e62aefd 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2020-03-10 Jason Merrill <jason@redhat.com>
+
+ PR c++/93922
+ PR c++/94041
+ PR c++/52320
+ PR c++/66139
+ * cp-gimplify.c (cp_gimplify_init_expr): Partially revert patch for
+ 66139: Don't split_nonconstant_init. Remove pre_p parameter.
+
2020-03-09 Marek Polacek <polacek@redhat.com>
PR c++/92031 - bogus taking address of rvalue error.
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 10ab995..23a25e5 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -513,7 +513,7 @@ gimplify_expr_stmt (tree *stmt_p)
/* Gimplify initialization from an AGGR_INIT_EXPR. */
static void
-cp_gimplify_init_expr (tree *expr_p, gimple_seq *pre_p)
+cp_gimplify_init_expr (tree *expr_p)
{
tree from = TREE_OPERAND (*expr_p, 1);
tree to = TREE_OPERAND (*expr_p, 0);
@@ -526,22 +526,6 @@ cp_gimplify_init_expr (tree *expr_p, gimple_seq *pre_p)
if (TREE_CODE (from) == TARGET_EXPR && TARGET_EXPR_INITIAL (from))
from = TARGET_EXPR_INITIAL (from);
- /* If we might need to clean up a partially constructed object, break down
- the CONSTRUCTOR with split_nonconstant_init. */
- if (TREE_CODE (from) == CONSTRUCTOR
- && flag_exceptions
- && TREE_SIDE_EFFECTS (from)
- && TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (to)))
- {
- gimplify_expr (&to, pre_p, NULL, is_gimple_lvalue, fb_lvalue);
- replace_placeholders (from, to);
- from = split_nonconstant_init (to, from);
- cp_genericize_tree (&from, false);
- copy_if_shared (&from);
- *expr_p = from;
- return;
- }
-
/* Look through any COMPOUND_EXPRs, since build_compound_expr pushes them
inside the TARGET_EXPR. */
for (t = from; t; )
@@ -734,7 +718,7 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
LHS of an assignment might also be involved in the RHS, as in bug
25979. */
case INIT_EXPR:
- cp_gimplify_init_expr (expr_p, pre_p);
+ cp_gimplify_init_expr (expr_p);
if (TREE_CODE (*expr_p) != INIT_EXPR)
return GS_OK;
/* Fall through. */
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist116.C b/gcc/testsuite/g++.dg/cpp0x/initlist116.C
deleted file mode 100644
index 90dd8d7..0000000
--- a/gcc/testsuite/g++.dg/cpp0x/initlist116.C
+++ /dev/null
@@ -1,29 +0,0 @@
-// PR c++/66139
-// { dg-do run { target c++11 } }
-
-int constructed = 0;
-
-class lock_guard_ext{
-public:
- lock_guard_ext() { ++constructed; }
- ~lock_guard_ext() { --constructed; }
-};
-
-struct Access {
- lock_guard_ext lock;
- int value;
-};
-
-int t() {
- throw 0;
-}
-
-Access foo1() {
- return { {}, t() };
-}
-
-int main () {
- try { foo1(); } catch (int) {}
- if (constructed != 0)
- __builtin_abort();
-}
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist117.C b/gcc/testsuite/g++.dg/cpp0x/initlist117.C
deleted file mode 100644
index 415a5de..0000000
--- a/gcc/testsuite/g++.dg/cpp0x/initlist117.C
+++ /dev/null
@@ -1,40 +0,0 @@
-// PR c++/66139
-// { dg-do run { target c++11 } }
-
-#include <initializer_list>
-
-int c, d;
-
-struct a
-{
- a (int i) { if (i) throw i; c++; }
- ~a () { d++; }
-};
-
-void check (void (*f) ())
-{
- try
- {
- c = d = 0;
- f ();
- }
- catch (int)
- {
- if (c != 1 || d != 1)
- __builtin_abort ();
- return;
- }
- __builtin_abort ();
-}
-
-int main ()
-{
- struct s { a x, y; };
- check ([] { s t { 0, 1 }; });
- check ([] { s { 0, 1 }; });
- check ([] { a t[2] { 0, 1 }; });
- using array = a[2];
- check ([] { array { 0, 1 }; });
- check ([] { std::initializer_list <a> t { 0, 1 }; });
- check ([] { std::initializer_list <a> { 0, 1 }; });
-}
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh.C
deleted file mode 100644
index 4d1f4f3..0000000
--- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh.C
+++ /dev/null
@@ -1,34 +0,0 @@
-// Test that we properly clean up if we get an exception in the middle of
-// constructing the closure object.
-
-// { dg-do run }
-// { dg-require-effective-target c++11 }
-
-struct A
-{
- A() {}
- A(const A&) { throw 1; }
-};
-
-int bs;
-struct B
-{
- B() { ++bs; }
- B(const B&) { ++bs; }
- ~B() { --bs; }
-};
-
-int main()
-{
- {
- B b1, b2;
- A a;
-
- try
- {
- [b1, a, b2]{ };
- }
- catch(...) {}
- }
- return bs;
-}
diff --git a/gcc/testsuite/g++.dg/eh/aggregate1.C b/gcc/testsuite/g++.dg/eh/aggregate1.C
deleted file mode 100644
index 38dba89..0000000
--- a/gcc/testsuite/g++.dg/eh/aggregate1.C
+++ /dev/null
@@ -1,56 +0,0 @@
-// PR c++/52320
-// { dg-do run }
-
-#if DEBUG
-extern "C" int printf (const char *, ...);
-#define FUNCTION_NAME __PRETTY_FUNCTION__
-#define TRACE_FUNCTION printf ("%p->%s\n", this, FUNCTION_NAME);
-#else
-#define TRACE_FUNCTION
-#endif
-int c,d;
-#define TRACE_CTOR TRACE_FUNCTION ++c
-#define TRACE_DTOR TRACE_FUNCTION ++d
-
-int throw_at = 0;
-
-struct A {
- A() { int i = c+1; if (i == throw_at) throw i; TRACE_CTOR; }
- A(int i) { if (i == throw_at) throw i; TRACE_CTOR; }
- A(const A&) { throw 10; }
- A &operator=(const A&) { throw 11; return *this; }
- ~A() { TRACE_DTOR; }
-};
-
-int fails;
-
-void try_idx (int i)
-{
-#if DEBUG
- printf ("trying %d\n", i);
-#endif
- throw_at = i;
- c = d = 0;
- int t = 10;
- try {
- struct X {
- A e1[2], e2;
- }
- x2[3] = { { 1, 2, 3 }, { 4, 5, 6 } };
- } catch (int x) { t = x; }
- if (t != i || c != d || c != i-1)
- {
-#if DEBUG
- printf ("%d FAIL\n", i);
-#endif
- ++fails;
- }
-}
-
-int main()
-{
- for (int i = 1; i <= 10; ++i)
- try_idx (i);
-
- return fails;
-}