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