Debian Codegraph @

gcc/testsuite/c-c++-common/analyzer/allocation-size-multiline-2.c

raw
1 /* { dg-additional-options "-fdiagnostics-path-format=inline-events -fdiagnostics-show-caret -fanalyzer-fine-grained" } */
2
3 #include <stdint.h>
4
5 void test_constant_1 (void)
6 {
7 int32_t *ptr = (int32_t *) __builtin_alloca (1); /* { dg-warning "allocated buffer size is not a multiple of the pointee's size" } */
8 }
9
10 /* { dg-begin-multiline-output "" }
11 int32_t *ptr = (int32_t *) __builtin_alloca (1);
12 ^~~~~~~~~~~~~~~~~~~~
13 'test_constant_1': events 1-2
14 int32_t *ptr = (int32_t *) __builtin_alloca (1);
15 ^~~~~~~~~~~~~~~~~~~~
16 |
17 (1) allocated 1 byte here
18 (2) assigned to 'int32_t *'
19 { dg-end-multiline-output "" { target c } } */
20 /* { dg-begin-multiline-output "" }
21 int32_t *ptr = (int32_t *) __builtin_alloca (1);
22 ~~~~~~~~~~~~~~~~~^~~
23 'void test_constant_1()': events 1-2
24 int32_t *ptr = (int32_t *) __builtin_alloca (1);
25 ~~~~~~~~~~~~~~~~~^~~
26 |
27 (1) allocated 1 byte here
28 (2) assigned to 'int32_t*' {aka '{re:long :re?}int*'} here; 'sizeof (int32_t {aka {re:long :re?}int})' is '4'
29 { dg-end-multiline-output "" { target c++ } } */
30
31 void test_constant_2 (void)
32 {
33 int32_t *ptr = (int32_t *) __builtin_alloca (2); /* { dg-warning "allocated buffer size is not a multiple of the pointee's size" } */
34 }
35
36 /* { dg-begin-multiline-output "" }
37 int32_t *ptr = (int32_t *) __builtin_alloca (2);
38 ^~~~~~~~~~~~~~~~~~~~
39 'test_constant_2': events 1-2
40 int32_t *ptr = (int32_t *) __builtin_alloca (2);
41 ^~~~~~~~~~~~~~~~~~~~
42 |
43 (1) allocated 2 bytes here
44 (2) assigned to 'int32_t *'
45 { dg-end-multiline-output "" { target c } } */
46 /* { dg-begin-multiline-output "" }
47 int32_t *ptr = (int32_t *) __builtin_alloca (2);
48 ~~~~~~~~~~~~~~~~~^~~
49 'void test_constant_2()': events 1-2
50 int32_t *ptr = (int32_t *) __builtin_alloca (2);
51 ~~~~~~~~~~~~~~~~~^~~
52 |
53 (1) allocated 2 bytes here
54 (2) assigned to 'int32_t*' {aka '{re:long :re?}int*'} here; 'sizeof (int32_t {aka {re:long :re?}int})' is '4'
55 { dg-end-multiline-output "" { target c++ } } */
56
57 void test_symbolic (int n)
58 {
59 int32_t *ptr = (int32_t *) __builtin_alloca (n * 2); /* { dg-warning "allocated buffer size is not a multiple of the pointee's size" } */
60 }
61
62 /* { dg-begin-multiline-output "" }
63 int32_t *ptr = (int32_t *) __builtin_alloca (n * 2);
64 ^~~~~~~~~~~~~~~~~~~~~~~~
65 'test_symbolic': events 1-2
66 int32_t *ptr = (int32_t *) __builtin_alloca (n * 2);
67 ^~~~~~~~~~~~~~~~~~~~~~~~
68 |
69 (1) allocated 'n * 2' bytes here
70 (2) assigned to 'int32_t *'
71 { dg-end-multiline-output "" { target c } } */
72 /* { dg-begin-multiline-output "" }
73 int32_t *ptr = (int32_t *) __builtin_alloca (n * 2);
74 ~~~~~~~~~~~~~~~~~^~~~~~~
75 'void test_symbolic(int)': events 1-2
76 int32_t *ptr = (int32_t *) __builtin_alloca (n * 2);
77 ~~~~~~~~~~~~~~~~~^~~~~~~
78 |
79 (1) allocated '(n * 2)' bytes here
80 (2) assigned to 'int32_t*' {aka '{re:long :re?}int*'} here; 'sizeof (int32_t {aka {re:long :re?}int})' is '4'
81 { dg-end-multiline-output "" { target c++ } } */
82
83 /* FIXME: am getting a duplicate warning here for some reason
84 without -fanalyzer-fine-grained (PR PR analyzer/107851). */
85