]> gcc.gnu.org Git - gcc.git/commitdiff
c-parse.in (select_or_iter_stmt): Use truthvalue_conversion on the condition of a...
authorGeoffrey Keating <geoffk@redhat.com>
Fri, 29 Dec 2000 08:27:40 +0000 (08:27 +0000)
committerGeoffrey Keating <geoffk@gcc.gnu.org>
Fri, 29 Dec 2000 08:27:40 +0000 (08:27 +0000)
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-28  Geoffrey Keating  <geoffk@redhat.com>

* gcc.dg/noncompile/20001228-1.c: New test.

From-SVN: r38527

gcc/ChangeLog
gcc/c-parse.in
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/noncompile/20001228-1.c [new file with mode: 0644]

index 04d22cd73245b3eac60ce355c1a9ce7d5391c173..7a306e5604221279056286699186c04c41fd6a59 100644 (file)
@@ -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
index 8b211d1384ba5249c133cd805e5dc3b13d107230..f944ac3bd45e69c3fb3e3d96bd3b5dfd97933e53 100644 (file)
@@ -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
index 1070cbc417f4b9ecf3acde73f00c0e81847009b4..86c588b07ff33a533a9dfe8d52d32bdfbb1e74f8 100644 (file)
@@ -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 (file)
index 0000000..79efe11
--- /dev/null
@@ -0,0 +1,6 @@
+void rof(void)
+{
+  union { int a; } u;
+  for (u.a = 0; u; u.a++)  /* { dg-error "invalid operand" } */
+    ;
+}
This page took 0.110929 seconds and 5 git commands to generate.