[PATCH] D133194: rewording note note_constexpr_invalid_cast

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 9 12:39:48 PDT 2022


aaron.ballman added inline comments.


================
Comment at: clang/test/Sema/cast.c:1-5
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-unknown-unknown %s -verify -Wvla
+
+int array[(long)(char *)0]; // expected-warning {{variable length array used}} \
+                            // expected-warning {{variable length array folded to constant array as an extension}} \
+                            // expected-note {{this conversion is not allowed in a constant expression}}
----------------
Codesbyusman wrote:
> aaron.ballman wrote:
> > I realized that we don't need to pass `-Wvla` at all, the other warning and note are on by default.
> > I realized that we don't need to pass `-Wvla` at all, the other warning and note are on by default.
> 
> But the note is not enabled without it, without it i got this error:
> that I am expecting but there is no diagnostic for it
> 
> > error: 'note' diagnostics expected but not seen: 
> >   File /home/kali/llvm-project/clang/test/Sema/cast.c Line 3: this conversion is not allowed in a constant expression
> > 1 error generated.
> 
> 
> 
Oh! I was thinking that the note was associated with the constant folding warning, not the "you used a VLA" warning, but you're absolutely right! Ignore the suggestion and keep passing -Wvla here.


================
Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:3
 // RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,cxx11_20,cxx20_2b -triple x86_64-linux -Wno-string-plus-int -Wno-pointer-arith -Wno-zero-length-array -Wno-c99-designator -fcxx-exceptions -pedantic %s -Wno-comment -Wno-tautological-pointer-compare -Wno-bool-conversion
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=expected,cxx11_20,cxx11    -triple x86_64-linux -Wno-string-plus-int -Wno-pointer-arith -Wno-zero-length-array -Wno-c99-designator -fcxx-exceptions -pedantic %s -Wno-comment -Wno-tautological-pointer-compare -Wno-bool-conversion
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=expected,cxx11_20,cxx11    -triple x86_64-linux -Wno-string-plus-int -Wno-pointer-arith -Wno-zero-length-array -Wno-c99-designator -fcxx-exceptions -pedantic %s -Wno-comment -Wno-tautological-pointer-compare -Wno-bool-conversion -Wvla 
+
----------------
aaron.ballman wrote:
> We don't need to use `-Wvla` to see the diagnostic change, and this will fix the test failures from the other RUN lines not generating the same warning about use of a VLA.
And this is a better suggestion here.


================
Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:15-17
+int array[(long)(char *)0]; // expected-warning {{variable length arrays are a C99 feature}} \
+                            // expected-warning {{variable length array folded to constant array as an extension}} \
+                            // expected-note {{cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression}}
----------------
aaron.ballman wrote:
> 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133194/new/

https://reviews.llvm.org/D133194



More information about the cfe-commits mailing list