annotate clang/test/Analysis/conditional-operator.cpp @ 222:81f6424ef0e3 llvm-original

LLVM original branch
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:10:01 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config eagerly-assume=false %s -analyzer-output=text -verify
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 void clang_analyzer_eval(bool);
anatofuz
parents:
diff changeset
4
anatofuz
parents:
diff changeset
5 // Test that the analyzer does not crash on GNU extension operator "?:".
anatofuz
parents:
diff changeset
6 void NoCrashTest(int x, int y) {
anatofuz
parents:
diff changeset
7 int w = x ?: y;
anatofuz
parents:
diff changeset
8 }
anatofuz
parents:
diff changeset
9
anatofuz
parents:
diff changeset
10 void OperatorEvaluationTest(int y) {
anatofuz
parents:
diff changeset
11 int x = 1;
anatofuz
parents:
diff changeset
12 int w = x ?: y; // expected-note {{'?' condition is true}}
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 // TODO: We are not precise when processing the "?:" operator in C++.
anatofuz
parents:
diff changeset
15 clang_analyzer_eval(w == 1); // expected-warning{{UNKNOWN}}
anatofuz
parents:
diff changeset
16 // expected-note@-1{{UNKNOWN}}
anatofuz
parents:
diff changeset
17 }