Debian Codegraph @

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

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