Add __builtion_unreachable to vector::size(), vector::capacity()
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / allocation-size-multiline-1.c
blobbc8319471757e06491e3be888876a52e2e3e8b16
1 /* { dg-additional-options "-fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
3 #include <stdint.h>
5 void test_constant_1 (void)
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);
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 ^~~~~~~~~~~~~~~~~~~~
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 ~~~~~~~~~~~~~~~~~^~~
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++ } } */
32 void test_constant_2 (void)
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);
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 ^~~~~~~~~~~~~~~~~~~~
45 (1) allocated 2 bytes here
46 (2) assigned to 'int32_t *'
47 { dg-end-multiline-output "" { target c } } */
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 ~~~~~~~~~~~~~~~~~^~~
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++ } } */
60 void test_symbolic (int n)
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);
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 ^~~~~~~~~~~~~~~~~~~~~~~~
73 (1) allocated 'n * 2' bytes and assigned to 'int32_t *'
74 { dg-end-multiline-output "" { target c } } */
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 ~~~~~~~~~~~~~~~~~^~~~~~~
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++ } } */