xref: /aosp_15_r20/external/clang/test/Sema/vla-2.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic
2*67e74705SXin Li // Check that we don't crash trying to emit warnings in a potentially-evaluated
3*67e74705SXin Li // sizeof or typeof.  (This test needs to be in a separate file because we use
4*67e74705SXin Li // a different codepath when we have already emitted an error.)
5*67e74705SXin Li 
PotentiallyEvaluatedSizeofWarn(int n)6*67e74705SXin Li int PotentiallyEvaluatedSizeofWarn(int n) {
7*67e74705SXin Li   return (int)sizeof *(0 << 32,(int(*)[n])0); // expected-warning {{expression result unused}} expected-warning {{shift count >= width of type}}
8*67e74705SXin Li }
9*67e74705SXin Li 
PotentiallyEvaluatedTypeofWarn(int n)10*67e74705SXin Li void PotentiallyEvaluatedTypeofWarn(int n) {
11*67e74705SXin Li   __typeof(*(0 << 32,(int(*)[n])0)) x; // expected-warning {{expression result unused}} expected-warning {{shift count >= width of type}}
12*67e74705SXin Li   (void)x;
13*67e74705SXin Li }
14*67e74705SXin Li 
PotentiallyEvaluatedArrayBoundWarn(int n)15*67e74705SXin Li void PotentiallyEvaluatedArrayBoundWarn(int n) {
16*67e74705SXin Li   (void)*(int(*)[(0 << 32,n)])0; // FIXME: We should warn here.
17*67e74705SXin Li }
18