[RISC-V] Avoid unnecessary extensions when value is already extended
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / allocation-size-multiline-3.c
blobeeb52192fd44370f40be66acd2164cb244d4f00d
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
19 int32_t *ptr = (int32_t *) alloca (99);
20 ^~~~~~
22 (1) allocated 99 bytes here
23 (2) assigned to 'int32_t *' {aka '{re:long :re?}int *'} here; 'sizeof (int32_t {aka {re:long :re?}int})' is '4'
24 { dg-end-multiline-output "" { target c } } */
25 /* { dg-begin-multiline-output "" }
26 int32_t *ptr = (int32_t *) alloca (99);
27 ^~~~~~
28 'void test_constant_99()': events 1-2
29 int32_t *ptr = (int32_t *) alloca (99);
30 ^~~~~~
32 (1) allocated 99 bytes here
33 (2) assigned to 'int32_t*' {aka '{re:long :re?}int*'} here; 'sizeof (int32_t {aka {re:long :re?}int})' is '4'
34 { dg-end-multiline-output "" { target c++ } } */
36 void test_symbolic (int n)
38 int32_t *ptr = (int32_t *) alloca (n * 2); /* { dg-warning "allocated buffer size is not a multiple of the pointee's size" } */
41 /* { dg-begin-multiline-output "" }
42 int32_t *ptr = (int32_t *) alloca (n * 2);
43 ^~~~~~
44 'test_symbolic': events 1-2
45 int32_t *ptr = (int32_t *) alloca (n * 2);
46 ^~~~~~
48 (1) allocated 'n * 2' bytes here
49 (2) assigned to 'int32_t *' {aka '{re:long :re?}int *'} here; 'sizeof (int32_t {aka {re:long :re?}int})' is '4'
50 { dg-end-multiline-output "" { target c } } */
51 /* { dg-begin-multiline-output "" }
52 int32_t *ptr = (int32_t *) alloca (n * 2);
53 ^~~~~~
54 'void test_symbolic(int)': events 1-2
55 int32_t *ptr = (int32_t *) alloca (n * 2);
56 ^~~~~~
58 (1) allocated '(n * 2)' bytes here
59 (2) assigned to 'int32_t*' {aka '{re:long :re?}int*'} here; 'sizeof (int32_t {aka {re:long :re?}int})' is '4'
60 { dg-end-multiline-output "" { target c++ } } */