aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/conditional-operator.cpp
blob: 137dc3987755a88c4238a12de2ac8e7fe8ef1384 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection %s -analyzer-output=text -verify

void clang_analyzer_eval(bool);

// Test that the analyzer does not crash on GNU extension operator "?:".
void NoCrashTest(int x, int y) {
	int w = x ?: y;
}

void OperatorEvaluationTest(int y) {
  int x = 1;
	int w = x ?: y;  // expected-note {{'?' condition is true}}
	
	// TODO: We are not precise when processing the "?:" operator in C++.
  clang_analyzer_eval(w == 1); // expected-warning{{UNKNOWN}}
                               // expected-note@-1{{UNKNOWN}}
}