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