xref: /aosp_15_r20/external/clang/test/Analysis/conditional-operator.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection %s -analyzer-output=text -verify
2*67e74705SXin Li 
3*67e74705SXin Li void clang_analyzer_eval(bool);
4*67e74705SXin Li 
5*67e74705SXin Li // Test that the analyzer does not crash on GNU extension operator "?:".
NoCrashTest(int x,int y)6*67e74705SXin Li void NoCrashTest(int x, int y) {
7*67e74705SXin Li 	int w = x ?: y;
8*67e74705SXin Li }
9*67e74705SXin Li 
OperatorEvaluationTest(int y)10*67e74705SXin Li void OperatorEvaluationTest(int y) {
11*67e74705SXin Li   int x = 1;
12*67e74705SXin Li 	int w = x ?: y;  // expected-note {{'?' condition is true}}
13*67e74705SXin Li 
14*67e74705SXin Li 	// TODO: We are not precise when processing the "?:" operator in C++.
15*67e74705SXin Li   clang_analyzer_eval(w == 1); // expected-warning{{UNKNOWN}}
16*67e74705SXin Li                                // expected-note@-1{{UNKNOWN}}
17*67e74705SXin Li }