mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 05:46:06 +00:00

Old GCC used to aggressively fold VLAs to constant-bound arrays at block scope in GNU mode. That's non-conforming, and more modern versions of GCC only do this at file scope. Update Clang to do the same. Also promote the warning for this from off-by-default to on-by-default in all cases; more recent versions of GCC likewise warn on this by default. This is still slightly more permissive than GCC, as pointed out in PR44406, as we still fold VLAs to constant arrays in structs, but that seems justifiable given that we don't support VLA-in-struct (and don't intend to ever support it), but GCC does. Differential Revision: https://reviews.llvm.org/D89523
24 lines
721 B
C++
24 lines
721 B
C++
// RUN: %clang_cc1 -pedantic-errors -std=c++98 -emit-pch %s -o %t
|
|
// RUN: %clang_cc1 -pedantic-errors -std=c++98 -include-pch %t -verify %s
|
|
|
|
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t-cxx11
|
|
// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t-cxx11 -verify %s
|
|
|
|
// RUN: %clang_cc1 -pedantic-errors -std=c++98 -emit-pch %s -o %t -fmodules
|
|
// RUN: %clang_cc1 -pedantic-errors -std=c++98 -include-pch %t -verify %s -fmodules
|
|
|
|
#ifndef HEADER_INCLUDED
|
|
|
|
#define HEADER_INCLUDED
|
|
extern const int a;
|
|
const int b = a;
|
|
|
|
#else
|
|
|
|
const int a = 5;
|
|
typedef int T[b]; // expected-error 2{{variable length array}} expected-note {{initializer of 'b'}}
|
|
// expected-note@14 {{here}}
|
|
typedef int T[5];
|
|
|
|
#endif
|