[PATCH] D152009: [clang] Fix assertion while parsing an invalid for loop

Shafik Yaghmour via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 2 14:58:36 PDT 2023


shafik added inline comments.


================
Comment at: clang/lib/Parse/ParseStmt.cpp:2200
         Diag(Tok, diag::err_expected_semi_for);
-      else
-        // Skip until semicolon or rparen, don't consume it.
----------------
Can you explain why you removed this?


================
Comment at: clang/test/Parser/cxx0x-for-range.cpp:67
+    int a[] = {1, 2, 3, 4, 5};
+    for (auto x = n ? 1 : 2 : a); // expected-error {{expected ';' in 'for' statement specifier}} \
+                                  // expected-error {{expected expression}}
----------------
Did you try dropping the `;` at the end of this line to make sure it still does what we expect?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152009/new/

https://reviews.llvm.org/D152009



More information about the cfe-commits mailing list