xref: /aosp_15_r20/external/clang/test/Sema/warn-sizeof-arrayarg.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify %s
2*67e74705SXin Li 
3*67e74705SXin Li typedef int Arr[10];
4*67e74705SXin Li 
5*67e74705SXin Li typedef int trungl_int;
6*67e74705SXin Li 
f(int a[10],Arr arr)7*67e74705SXin Li void f(int a[10], Arr arr) { // expected-note 4 {{declared here}}
8*67e74705SXin Li 
9*67e74705SXin Li   /* Should warn. */
10*67e74705SXin Li   (void)sizeof(a);  // \
11*67e74705SXin Li       // expected-warning{{sizeof on array function parameter will return size of 'int *' instead of 'int [10]'}}
12*67e74705SXin Li   (void)sizeof((((a))));  // \
13*67e74705SXin Li       // expected-warning{{sizeof on array function parameter will return size of 'int *' instead of 'int [10]'}}
14*67e74705SXin Li   (void)sizeof a;  // \
15*67e74705SXin Li       // expected-warning{{sizeof on array function parameter will return size of 'int *' instead of 'int [10]'}}
16*67e74705SXin Li   (void)sizeof arr;  // \
17*67e74705SXin Li       // expected-warning{{sizeof on array function parameter will return size of 'int *' instead of 'Arr' (aka 'int [10]')}}
18*67e74705SXin Li 
19*67e74705SXin Li   /* Shouldn't warn. */
20*67e74705SXin Li   int b[10];
21*67e74705SXin Li   (void)sizeof b;
22*67e74705SXin Li   Arr brr;
23*67e74705SXin Li   (void)sizeof brr;
24*67e74705SXin Li   (void)sizeof(Arr);
25*67e74705SXin Li   (void)sizeof(int);
26*67e74705SXin Li }
27