diff options
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-parse.in | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/noncompile/20001228-1.c | 6 |
4 files changed, 16 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 04d22cd7324..7a306e56042 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2000-12-28 Geoffrey Keating <geoffk@redhat.com> + + * c-parse.in (select_or_iter_stmt): Use truthvalue_conversion + on the condition of a FOR statement, so that it gets typechecked + and optimised. + 2000-12-29 Alexandre Oliva <aoliva@redhat.com> * c-decl.c (grokdeclarator): Prevent crash in case of overflow in diff --git a/gcc/c-parse.in b/gcc/c-parse.in index 8b211d1384b..f944ac3bd45 100644 --- a/gcc/c-parse.in +++ b/gcc/c-parse.in @@ -1896,7 +1896,8 @@ select_or_iter_stmt: { stmt_count++; RECHAIN_STMTS ($<ttype>2, FOR_INIT_STMT ($<ttype>2)); } xexpr ';' - { FOR_COND ($<ttype>2) = $6; } + { if ($6) + FOR_COND ($<ttype>2) = truthvalue_conversion ($6); } xexpr ')' { FOR_EXPR ($<ttype>2) = $9; } c99_block_lineno_labeled_stmt diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1070cbc417f..86c588b07ff 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -4,6 +4,8 @@ 2000-12-28 Geoffrey Keating <geoffk@redhat.com> + * gcc.dg/noncompile/20001228-1.c: New test. + * gcc.dg/20001228-1.c: New test. * gcc.c-torture/execute/20001228-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/noncompile/20001228-1.c b/gcc/testsuite/gcc.dg/noncompile/20001228-1.c new file mode 100644 index 00000000000..79efe117aac --- /dev/null +++ b/gcc/testsuite/gcc.dg/noncompile/20001228-1.c @@ -0,0 +1,6 @@ +void rof(void) +{ + union { int a; } u; + for (u.a = 0; u; u.a++) /* { dg-error "invalid operand" } */ + ; +} |