if (function_body)
maybe_splice_retval_cleanup (compound_stmt);
- /* Finish the compound-statement. */
- finish_compound_stmt (compound_stmt);
/* Consume the `}'. */
braces.require_close (parser);
+ /* Finish the compound-statement. */
+ finish_compound_stmt (compound_stmt);
+
return compound_stmt;
}
add_stmt (r);
}
+/* Set EXPR_LOCATION of the cleanups of any CLEANUP_STMT in STMTS to LOC. */
+
+static void
+set_cleanup_locs (tree stmts, location_t loc)
+{
+ if (TREE_CODE (stmts) == CLEANUP_STMT)
+ {
+ protected_set_expr_location (CLEANUP_EXPR (stmts), loc);
+ set_cleanup_locs (CLEANUP_BODY (stmts), loc);
+ }
+ else if (TREE_CODE (stmts) == STATEMENT_LIST)
+ for (tree_stmt_iterator i = tsi_start (stmts);
+ !tsi_end_p (i); tsi_next (&i))
+ set_cleanup_locs (tsi_stmt (i), loc);
+}
+
/* Finish a scope. */
tree
stmt_list = pop_stmt_list (stmt_list);
+ /* input_location is the last token of the scope, usually a }. */
+ set_cleanup_locs (stmt_list, input_location);
+
if (!processing_template_decl)
{
stmt_list = c_build_bind_expr (input_location, block, stmt_list);
int j = 0;
bar (j);
if (j == 8)
- return; /* { dg-warning "statement may fall through" "" { target c++ } } */
- }
+ return;
+ } /* { dg-warning "statement may fall through" "" { target c++ } } */
case 2:
bar (99);
}
if (j == 8)
bar (1);
else
- return; /* { dg-warning "statement may fall through" "" { target c++ } } */
- }
+ return;
+ } /* { dg-warning "statement may fall through" "" { target c++ } } */
case 2:
bar (99);
}
if (j == 8)
bar (1);
else
- bar (2); /* { dg-warning "statement may fall through" "" { target c++ } } */
- }
+ bar (2);
+ } /* { dg-warning "statement may fall through" "" { target c++ } } */
case 2:
bar (99);
}
case 1:
{ /* { dg-warning "statement may fall through" "" { target c } } */
int j = 9;
- switch (j); /* { dg-warning "statement may fall through" "" { target c++ } } */
- }
+ switch (j);
+ } /* { dg-warning "statement may fall through" "" { target c++ } } */
case 2:
bar (99);
}
{
case 1:
{ /* { dg-warning "statement may fall through" "" { target c } } */
- int a[i]; /* { dg-warning "statement may fall through" "" { target c++ } } */
- }
+ int a[i];
+ } /* { dg-warning "statement may fall through" "" { target c++ } } */
case 2:
bar (99);
}
constexpr int
f4 ()
{
- W7 w13 = 5; // { dg-message "in 'constexpr' expansion of" }
+ W7 w13 = 5;
return 0;
-}
+} // { dg-message "in 'constexpr' expansion of" }
constexpr int x4 = f4 (); // { dg-message "in 'constexpr' expansion of" }
--- /dev/null
+// PR c++/88742
+// { dg-additional-options -fdump-tree-gimple-lineno }
+
+
+class C {
+public:
+ C() {}
+ ~C() {}
+ operator int() { return 1; }
+};
+
+int main() {
+ C a;
+ C b;
+ C c;
+
+ if (C e = C())
+ {
+ if (C d = C())
+ {
+ }
+ else
+ {
+ return 42;
+ } // { dg-final { scan-tree-dump-times ":25:9. C::~C" 1 "gimple" } }
+ } // { dg-final { scan-tree-dump-times ":26:5. C::~C" 1 "gimple" } }
+
+ while (C f = C())
+ {
+ break;
+ } // { dg-final { scan-tree-dump-times ":31:5. C::~C" 1 "gimple" } }
+
+ for (C h = C(); C i = C(); )
+ break; // { dg-final { scan-tree-dump-times ":34:10. C::~C" 2 "gimple" } }
+
+ switch (C g = C())
+ {
+ default:
+ break;
+ } // { dg-final { scan-tree-dump-times ":40:5. C::~C" 1 "gimple" } }
+} // { dg-final { scan-tree-dump-times ":41:1. C::~C" 3 "gimple" } }
constexpr bool
foo ()
{
- int a __attribute__((cleanup (cleanup))) = 1; // { dg-message "in 'constexpr' expansion of" }
+ int a __attribute__((cleanup (cleanup))) = 1;
return true;
-}
+} // { dg-message "in 'constexpr' expansion of" }
constexpr bool
bar ()
void foo()
{
- C c; /* count(2) */
+ C c; /* count(1) */
c.seti (1); /* count(1) */
-}
+} /* count(1) */
int main()
{
B b; // ok
D1 d1; // ok
B& b1 = d1;
- D2 x; // { dg-error "" "destructor of D2 is not transaction-safe" }
+ D2 x;
b1.f(); // ok, calls D1::f()
delete b2; // undefined behavior: calls unsafe destructor of D2
- }
+ } // { dg-error "" "destructor of D2 is not transaction-safe" }
}
virtual ~S();
};
void f() transaction_safe {
- S s; // { dg-error "unsafe" "invocation of unsafe destructor" }
-}
+ S s;
+} // { dg-error "unsafe" "invocation of unsafe destructor" }
int g(int x) { // is transaction-safe
if (x <= 0)
switch (0) {
case 0:
{
- A b; // { dg-warning "statement may fall through" }
- }
+ A b;
+ } // { dg-warning "statement may fall through" }
default:
a = 0;
}