annotate gcc/testsuite/gcc.dg/Walloca-5.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* { dg-do compile } */
kono
parents:
diff changeset
2 /* { dg-require-effective-target alloca } */
kono
parents:
diff changeset
3 /* { dg-options "-Walloca-larger-than=123 -O2" } */
kono
parents:
diff changeset
4 /* { dg-xfail-if "Currently broken but Andrew's work should fix this" { *-*-* } } */
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 /* The argument to alloca ends up having a range of 0..MAXINT(32bits),
kono
parents:
diff changeset
7 so we think we have a range because of the upcast. Consequently,
kono
parents:
diff changeset
8 we warn with "alloca may be too large", but we should technically
kono
parents:
diff changeset
9 warn with "unbounded use of alloca".
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 We currently drill through casts to figure this stuff out, but we
kono
parents:
diff changeset
12 get confused because it's not just a cast. It's a cast, plus a
kono
parents:
diff changeset
13 multiply.
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 <bb 2>:
kono
parents:
diff changeset
16 # RANGE [0, 4294967295] NONZERO 4294967295
kono
parents:
diff changeset
17 _1 = (long unsigned int) something_4(D);
kono
parents:
diff changeset
18 # RANGE [0, 34359738360] NONZERO 34359738360
kono
parents:
diff changeset
19 _2 = _1 * 8;
kono
parents:
diff changeset
20 _3 = __builtin_alloca (_2);
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 I don't know whether it's even worth such fine-grained warnings.
kono
parents:
diff changeset
23 Perhaps we should generically warn everywhere with "alloca may be
kono
parents:
diff changeset
24 too large".
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 I'm hoping that this particular case will be easier to diagnose with
kono
parents:
diff changeset
27 Andrew's work. */
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 void useit(void *);
kono
parents:
diff changeset
30 void foobar(unsigned int something)
kono
parents:
diff changeset
31 {
kono
parents:
diff changeset
32 useit(__builtin_alloca (something * sizeof (const char *))); // { dg-warning "unbounded use of alloca" "" { xfail *-*-* } }
kono
parents:
diff changeset
33 }