Skip several analyzer socket tests on hppa*-*-hpux*
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / allocation-size-multiline-3.c
blob3cf7fb004240f104c032c4730859a024dc5ac61c
1 /* Verify that we warn for incorrect uses of "alloca" (which may be in a
2 macro in a system header), and that the output looks correct. */
4 /* { dg-additional-options "-fdiagnostics-path-format=inline-events -fdiagnostics-show-caret -fanalyzer-fine-grained" } */
5 /* { dg-require-effective-target alloca } */
7 #include <stdint.h>
8 #include "../../gcc.dg/analyzer/test-alloca.h"
10 void test_constant_99 (void)
12 int32_t *ptr = (int32_t *) alloca (99); /* { dg-warning "allocated buffer size is not a multiple of the pointee's size" } */
15 /* { dg-begin-multiline-output "" }
16 int32_t *ptr = (int32_t *) alloca (99);
17 ^~~~~~
18 'test_constant_99': events 1-2
20 | int32_t *ptr = (int32_t *) alloca (99);
21 | ^~~~~~
22 | |
23 | (1) allocated 99 bytes here
24 | (2) assigned to 'int32_t *' {aka '{re:long :re?}int *'} here; 'sizeof (int32_t {aka {re:long :re?}int})' is '4'
26 { dg-end-multiline-output "" { target c } } */
27 /* { dg-begin-multiline-output "" }
28 int32_t *ptr = (int32_t *) alloca (99);
29 ^~~~~~
30 'void test_constant_99()': events 1-2
32 | int32_t *ptr = (int32_t *) alloca (99);
33 | ^~~~~~
34 | |
35 | (1) allocated 99 bytes here
36 | (2) assigned to 'int32_t*' {aka '{re:long :re?}int*'} here; 'sizeof (int32_t {aka {re:long :re?}int})' is '4'
38 { dg-end-multiline-output "" { target c++ } } */
40 void test_symbolic (int n)
42 int32_t *ptr = (int32_t *) alloca (n * 2); /* { dg-warning "allocated buffer size is not a multiple of the pointee's size" } */
45 /* { dg-begin-multiline-output "" }
46 int32_t *ptr = (int32_t *) alloca (n * 2);
47 ^~~~~~
48 'test_symbolic': events 1-2
50 | int32_t *ptr = (int32_t *) alloca (n * 2);
51 | ^~~~~~
52 | |
53 | (1) allocated 'n * 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'
56 { dg-end-multiline-output "" { target c } } */
57 /* { dg-begin-multiline-output "" }
58 int32_t *ptr = (int32_t *) alloca (n * 2);
59 ^~~~~~
60 'void test_symbolic(int)': events 1-2
62 | int32_t *ptr = (int32_t *) alloca (n * 2);
63 | ^~~~~~
64 | |
65 | (1) allocated '(n * 2)' bytes here
66 | (2) assigned to 'int32_t*' {aka '{re:long :re?}int*'} here; 'sizeof (int32_t {aka {re:long :re?}int})' is '4'
68 { dg-end-multiline-output "" { target c++ } } */