[PATCH] D129573: [clang] add a diagnostic note 'while loop outside functions' at global scope

Matheus Izvekov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 21 17:14:03 PDT 2022


mizvekov added inline comments.


================
Comment at: clang/test/Parser/while-loop-outside-function.c:4
+// basic
+while(1) {}; // expected-error {{while loop outside of a function}}
+
----------------
What I meant is something like this, we test that the error caret would be placed on the while keyword.
You have to break it down like this as you can't express in the verifier where an error would occur inside a line.


================
Comment at: clang/test/Parser/while-loop-outside-function.c:22
+// recovery
+void some_fn();
+
----------------
To demonstrate recovery, I think it would make sense to try to use this declaration later, and test that it would work.
Ie you can try to 'overload' on the return type and see that you get the expected error.


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

https://reviews.llvm.org/D129573



More information about the cfe-commits mailing list