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