* c-parse.in (compstmt): Clear last_expr_type.
* parse.y (primary, primary_no_id): Use compstmt_or_stmtexpr
instead of compstmt.
(compstmt_or_stmtexpr): Renamed from compstmt.
(compstmt): In addition to compstmt_or_stmtexpr clear last_expr_type.
* gcc.c-torture/execute/
20020206-1.c: Test whether nesting 2
expression statements work instead.
* gcc.dg/noncompile/
20020207-1.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@49609
138bc75d-0d04-0410-961f-
82ee72b054a4
+2002-02-08 Jakub Jelinek <jakub@redhat.com>
+
+ * c-common.c (c_expand_expr): Revert 2002-02-06 patch.
+ * c-parse.in (compstmt): Clear last_expr_type.
+
2002-02-07 Richard Henderson <rth@redhat.com>
* loop.c (strength_reduce): Sink final_value when not
/* If we want the result of this expression, find the last
EXPR_STMT in the COMPOUND_STMT and mark it as addressable. */
- if (target != const0_rtx)
+ if (target != const0_rtx
+ && TREE_CODE (STMT_EXPR_STMT (exp)) == COMPOUND_STMT
+ && TREE_CODE (COMPOUND_BODY (STMT_EXPR_STMT (exp))) == SCOPE_STMT)
{
- tree expr = STMT_EXPR_STMT (exp);
- tree last;
+ tree expr = COMPOUND_BODY (STMT_EXPR_STMT (exp));
+ tree last = TREE_CHAIN (expr);
- while (TREE_CODE (expr) == COMPOUND_STMT
- && TREE_CODE (COMPOUND_BODY (expr)) == SCOPE_STMT)
+ while (TREE_CHAIN (last))
{
- expr = COMPOUND_BODY (expr);
- last = TREE_CHAIN (expr);
-
- while (TREE_CHAIN (last))
- {
- expr = last;
- last = TREE_CHAIN (last);
- }
-
- if (TREE_CODE (last) != SCOPE_STMT)
- abort ();
-
- if (TREE_CODE (expr) == EXPR_STMT)
- {
- TREE_ADDRESSABLE (expr) = 1;
- break;
- }
+ expr = last;
+ last = TREE_CHAIN (last);
}
+
+ if (TREE_CODE (last) == SCOPE_STMT
+ && TREE_CODE (expr) == EXPR_STMT)
+ TREE_ADDRESSABLE (expr) = 1;
}
expand_stmt (STMT_EXPR_STMT (exp));
compstmt: compstmt_start compstmt_nostart
{ RECHAIN_STMTS ($1, COMPOUND_BODY ($1));
+ last_expr_type = NULL_TREE;
$$ = $1; }
;
+2002-02-08 Jakub Jelinek <jakub@redhat.com>
+
+ * parse.y (primary, primary_no_id): Use compstmt_or_stmtexpr
+ instead of compstmt.
+ (compstmt_or_stmtexpr): Renamed from compstmt.
+ (compstmt): In addition to compstmt_or_stmtexpr clear last_expr_type.
+
2002-02-07 Nathan Sidwell <nathan@codesourcery.com>
Rename instantiate_type_flags to tsubst_flags_t & expand use.
pedwarn ("ISO C++ forbids braced-groups within expressions");
$<ttype>$ = begin_stmt_expr ();
}
- compstmt ')'
+ compstmt_or_stmtexpr ')'
{ $$ = finish_stmt_expr ($<ttype>2); }
/* Koenig lookup support
We could store lastiddecl in $1 to avoid another lookup,
YYERROR;
}
$<ttype>$ = expand_start_stmt_expr (); }
- compstmt ')'
+ compstmt_or_stmtexpr ')'
{ if (pedantic)
pedwarn ("ISO C++ forbids braced-groups within expressions");
$$ = expand_end_stmt_expr ($<ttype>2); }
}
;
-compstmt:
+compstmt_or_stmtexpr:
save_lineno '{'
{ $<ttype>$ = begin_compound_stmt (0); }
compstmtend
finish_compound_stmt (0, $<ttype>3); }
;
+compstmt:
+ compstmt_or_stmtexpr
+ { last_expr_type = NULL_TREE; }
+ ;
+
simple_if:
IF
{ $<ttype>$ = begin_if_stmt ();
+2002-02-08 Jakub Jelinek <jakub@redhat.com>
+
+ * gcc.c-torture/execute/20020206-1.c: Test whether nesting 2
+ expression statements work instead.
+ * gcc.dg/noncompile/20020207-1.c: New test.
+
2002-02-07 Richard Henderson <rth@redhat.com>
* gcc.dg/debug/dwarf2-1.c (foo): Return a value.
-/* This testcase ICEd because c_expand_expr did not mark statement expression
- return value as one which shouldn't be ignored. */
-
struct A {
unsigned int a, b, c;
};
{
struct A d;
- d = ({ { bar (); } });
+ d = ({ ({ bar (); }); });
baz (&d);
exit (0);
}
--- /dev/null
+/* This testcase ICEd because statement expression type was set, but was not
+ as used. */
+
+struct A {
+ unsigned int a, b, c;
+};
+
+extern void abort (void);
+extern void exit (int);
+
+struct A bar (void)
+{
+ return (struct A) { 176, 52, 31 };
+}
+
+void baz (struct A *a)
+{
+ if (a->a != 176 || a->b != 52 || a->c != 31)
+ abort ();
+}
+
+int main ()
+{
+ struct A d;
+
+ d = ({ { bar (); } }); /* { dg-error "void value" } */
+ d = ({ if (1) { bar (); } }); /* { dg-error "void value" } */
+ d = ({ while (0) { bar (); } }); /* { dg-error "void value" } */
+ d = ({ do { bar (); } while (0); }); /* { dg-error "void value" } */
+ baz (&d);
+ exit (0);
+}