1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection \
2 // RUN: -verify -analyzer-config eagerly-assume=false -std=c99 %s \
3 // RUN: -Wno-implicit-function-declaration
5 int printf(const char *restrict
,...);
7 void clang_analyzer_eval(int);
8 void clang_analyzer_dump(int*);
10 // Testing core functionality of the region store.
11 int compoundLiteralTest(void) {
13 for (index
= 0; index
< 2; index
++) {
14 int thing
= (int []){0, 1}[index
];
15 printf("thing: %i\n", thing
);
20 int compoundLiteralTest2(void) {
22 for (index
= 0; index
< 3; index
++) {
23 int thing
= (int [][3]){{0,0,0}, {1,1,1}, {2,2,2}}[index
][index
];
24 printf("thing: %i\n", thing
);
29 int concreteOffsetBindingIsInvalidatedBySymbolicOffsetAssignment(int length
,
33 return values
[0]; // no-warning
39 int initStruct(struct X
*st
);
40 int structOffsetBindingIsInvalidated(int length
, int i
){
43 return l
.mem
; // no-warning
46 void testConstraintOnRegionOffset(int *values
, int length
, int i
){
49 clang_analyzer_eval(values
[1] == 4);// expected-warning {{UNKNOWN}}
53 int initArray(int *values
);
54 void testConstraintOnRegionOffsetStack(int *values
, int length
, int i
) {
57 clang_analyzer_eval(values
[0] == 4);// expected-warning {{UNKNOWN}}
62 void b(); // expected-warning {{a function declaration without a prototype is deprecated in all versions of C and is treated as a zero-parameter prototype in C23, conflicting with a subsequent definition}}
63 void missingPrototypeCallsiteMatchingArgsAndParams() {
64 // expected-warning@+1 {{passing arguments to 'b' without a prototype is deprecated in all versions of C and is not supported in C23}}
67 void b(int *c
) { // expected-note {{conflicting prototype is here}}
68 clang_analyzer_dump(c
); // expected-warning {{&Element{buffer,0 S64b,int}}}
72 void c(); // expected-warning {{a function declaration without a prototype is deprecated in all versions of C and is treated as a zero-parameter prototype in C23, conflicting with a subsequent definition}}
73 void missingPrototypeCallsiteMismatchingArgsAndParams() {
74 // expected-warning@+1 {{passing arguments to 'c' without a prototype is deprecated in all versions of C and is not supported in C23}}
77 void c(int *c
) { // expected-note {{conflicting prototype is here}}
78 clang_analyzer_dump(c
); // expected-warning {{Unknown}}