================ @@ -0,0 +1,68 @@ +// RUN: %clang_cc1 %s -std=c23 -verify=expected,c -fsyntax-only +// RUN: %clang_cc1 %s -std=c23 -verify=good -fsyntax-only -Wno-vla +// RUN: %clang_cc1 -x c++ %s -verify -fsyntax-only +// RUN: %clang_cc1 -DCARET -fsyntax-only -std=c23 -fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines=1 %s 2>&1 | FileCheck %s -strict-whitespace + +// good-no-diagnostics + +int n, m; // #decl +int size(int); + +void foo(int vla[n], int n); // expected-warning {{variable length array size expression refers to declaration from an outer scope}} \ + expected-note {{does not refer to this declaration}} \ + expected-note@#decl {{refers to this declaration instead}} + +void bar(int (*vla)[n], int n); // expected-warning {{variable length array size expression refers to declaration from an outer scope}} \ + expected-note {{does not refer to this declaration}} \ + expected-note@#decl {{refers to this declaration instead}} + +void baz(int n, int vla[n]); // no diagnostic expected + +void quux(int vla[n + 12], int n); // expected-warning {{variable length array size expression refers to declaration from an outer scope}} \ + expected-note {{does not refer to this declaration}} \ + expected-note@#decl {{refers to this declaration instead}} + +void quibble(int vla[size(n)], int n); // expected-warning {{variable length array size expression refers to declaration from an outer scope}} \ + expected-note {{does not refer to this declaration}} \ + expected-note@#decl {{refers to this declaration instead}} + +void quobble(int vla[n + m], int n, int m); // expected-warning 2 {{variable length array size expression refers to declaration from an outer scope}} \ + expected-note 2 {{does not refer to this declaration}} \ + expected-note@#decl 2 {{refers to this declaration instead}} + +// For const int, we still treat the function as having a variably-modified +// type, but only in C. ---------------- uecker wrote:
Note that there is proposal in flight for C that might change this. https://github.com/llvm/llvm-project/pull/129772 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits