xref: /llvm-project/clang/test/Analysis/symbol-simplification-assertion.c (revision f75bc5bfc8f898de10e14163998c63eeb2b9f705)
1 // RUN: %clang_analyze_cc1 %s \
2 // RUN:   -analyzer-checker=core \
3 // RUN:   -analyzer-checker=debug.ExprInspection \
4 // RUN:   -analyzer-config eagerly-assume=true \
5 // RUN:   -verify
6 
7 // Here we test that no assertion is fired during symbol simplification.
8 // Related issue: https://github.com/llvm/llvm-project/issues/55546
9 
10 extern void abort() __attribute__((__noreturn__));
11 #define assert(expr) ((expr) ? (void)(0) : abort())
12 
13 void clang_analyzer_warnIfReached();
14 
15 int a, b, c;
16 long L, L1;
test()17 void test() {
18   assert(a + L + 1 + b != c);
19   assert(L == a);
20   assert(c == 0);
21   L1 = 0;
22   assert(a + L1 + 1 + b != c);
23   assert(a == 0); // no-assertion
24   clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
25 }
26