[PATCH] Fix to PR8880 (clang dies processing a for loop).

Serge Pavlov sepavloff at gmail.com
Thu Dec 12 07:13:45 PST 2013



================
Comment at: test/Parser/bad-control.c:22-30
@@ +21,11 @@
+
+// GCC rejects this code
+void pr8880_3(int first) {
+  for ( ; ; (void)({ if (first) { first = 0; continue; } 0; })) {}
+}
+
+// GCC rejects this code (see also tests/Analysis/dead-stores.c rdar8014335()
+void pr8880_4(int first) {
+  for ( ; ; (void)({ if (first) { first = 0; break; } 0; })) {}
+}
+
----------------
Richard Smith wrote:
> Does this mean we're misinterpreting pr8880_10 and pr8880_11 below?
No, this is a feature of GCC. It uses different interpretation depending on whether code is compiled as C or as C++. In C++ mode break and continue in the second or third expression of for statement refer to the inner loop, in C mode - to the outer. However in both modes GCC reject using break/continue if for statement is not inside another loop. Clang is more consistent, it considers that the third expression refers to the inner loop and the second - to outer, the interpretation is the same in C and C++ mode.

================
Comment at: test/Sema/statements.c:94-95
@@ -93,4 +93,4 @@
 // PR 8880
 // FIXME: Clang should reject this, since GCC does.  Previously this
 // was causing a crash in the CFG builder.
 int test_pr8880() {
----------------
Richard Smith wrote:
> Remove this FIXME.
OK.


http://llvm-reviews.chandlerc.com/D2018



More information about the cfe-commits mailing list