[clang] better error message for while loops outside of control flow
authorinclyc <me@inclyc.cn>
Tue, 12 Jul 2022 16:12:12 +0000 (00:12 +0800)
committerinclyc <me@inclyc.cn>
Mon, 25 Jul 2022 03:48:24 +0000 (11:48 +0800)
commitedaae251cca07c34c55905c424a8f677623d0bd0
tree8706fecbbf9d779c185b876d0d9d0863b173087d
parent1ef32e78284bc758112632e9e190b6683ea5b95b
[clang] better error message for while loops outside of control flow

report an error when encountering 'while' token parsing declarator

```
clang/test/Parser/while-loop-outside-function.c:3:1: error: while loop outside of a function
while // expected-error {{while loop outside of a function}}
^
clang/test/Parser/while-loop-outside-function.c:7:1: error: while loop outside of a function
while // expected-error {{while loop outside of a function}}
^
```

Fixes: https://github.com/llvm/llvm-project/issues/34462

Differential Revision: https://reviews.llvm.org/D129573
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/lib/Parse/ParseDecl.cpp
clang/test/Parser/while-loop-outside-function.c [new file with mode: 0644]
clang/test/Parser/while-loop-outside-function.cpp [new file with mode: 0644]