llvm-project/clang/test/Analysis/consteval-if.cpp
Imad Aldij 778f60d92d
[analyzer] Add support for consteval in ConditionBRVisitor::VisitTerminator (#146859)
Fix crash when ConditionBRVisitor::VisitTerminator is faced with `if
consteval` which doesn't have the expected traditional condition

Fixes #139130
2025-07-07 20:18:48 +02:00

17 lines
483 B
C++

// RUN: %clang_analyze_cc1 -std=c++23 -analyzer-checker=core -verify %s
// RUN: %clang_analyze_cc1 -std=c++26 -analyzer-checker=core -verify %s
void test_consteval() {
if consteval {
int *ptr = nullptr;
*ptr = 42; // expected-warning{{Dereference of null pointer (loaded from variable 'ptr')}}
}
}
void test_not_consteval() {
if !consteval {
int *ptr = nullptr;
*ptr = 42; // expected-warning{{Dereference of null pointer (loaded from variable 'ptr')}}
}
}