diff options
Diffstat (limited to 'test/Sema/warn-extern-main.c')
-rw-r--r-- | test/Sema/warn-extern-main.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test/Sema/warn-extern-main.c b/test/Sema/warn-extern-main.c new file mode 100644 index 000000000000..62c2c9b4a86c --- /dev/null +++ b/test/Sema/warn-extern-main.c @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST1 +// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST2 +// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST3 +// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST4 +// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST5 +// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST6 +// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST7 +// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST8 +// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST9 -ffreestanding + +#if TEST1 +int main; // expected-warning{{variable named 'main' with external linkage has undefined behavior}} + +#elif TEST2 +extern int main; // expected-warning{{variable named 'main' with external linkage has undefined behavior}} + +#elif TEST3 +// expected-no-diagnostics +void x() { + static int main; +} + +#elif TEST4 +void x() { + extern int main; // expected-warning{{variable named 'main' with external linkage has undefined behavior}} +} + +#elif TEST5 +// expected-no-diagnostics +void x() { + int main; +} + +#elif TEST6 +// expected-no-diagnostics +static int main; + +#elif TEST7 +// expected-no-diagnostics +void x() { + auto int main; +} + +#elif TEST8 +// expected-no-diagnostics +void x() { + register int main; +} + +#elif TEST9 +// expected-no-diagnostics +int main; + +#else +#error Unknown Test +#endif |