Aaron Ballman f8d448d5e5 Correct behavior of VLA extension diagnostic in C89 mode
Post-commit feedback (https://reviews.llvm.org/D156565#4654773) found
that the changes in 84a3aadf0f2483dde0acfc4e79f2a075a5f35bd1 caused us
to diagnose use of VLAs in C89 mode by default which was an unintended
change.

This adds -Wvla-cxx-extension as a warning group and adds the C++-
specific warnings to it while leaving the C warnings under
-Wvla-extension. -Wvla-cxx-extension is then added to -Wall.
2023-10-23 08:07:59 -04:00

25 lines
911 B
C

/* RUN: %clang_cc1 -verify=off -std=c89 %s
* RUN: %clang_cc1 -verify=off -Wall -std=c89 %s
* RUN: %clang_cc1 -verify -pedantic -std=c89 %s
* RUN: %clang_cc1 -verify -Wvla-extension -std=c89 %s
* RUN: %clang_cc1 -verify=off -Wvla-cxx-extension -std=c89 %s
* RUN: %clang_cc1 -verify=off -pedantic -std=c99 %s
* RUN: %clang_cc1 -verify=off -Wall -std=c99 %s
* RUN: %clang_cc1 -verify=off -std=c99 -Wvla-extension %s
* The next run line still issues the extension warning because VLAs are an
* extension in C89, but the line after it will issue the congratulatory
* diagnostic.
* RUN: %clang_cc1 -verify -Wvla -std=c89 %s
* RUN: %clang_cc1 -verify=wvla -Wvla -std=c99 %s
*/
/* off-no-diagnostics */
void func(int n) {
int array[n]; /* expected-warning {{variable length arrays are a C99 feature}}
wvla-warning {{variable length array used}}
*/
(void)array;
}