llvm-project/clang/test/Parser/while-loop-outside-function.c
inclyc edaae251cc
[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
2022-07-25 11:48:24 +08:00

27 lines
536 B
C

// RUN: %clang_cc1 -fsyntax-only -verify %s
while // expected-error {{while loop outside of a function}}
(1) {};
// without semicolon
while // expected-error {{while loop outside of a function}}
(1) {}
int overload_return(); // expected-note {{previous declaration is here}}
void overload_return() // expected-error {{conflicting types for 'overload_return'}}
{
while(1) {};
while(1);
}
while // expected-error {{while loop outside of a function}}
(1);
void correct();
void correct() {
while(1) {};
while(1);
}