mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-01 22:26:05 +00:00

A significant number of our tests in C accidentally use functions without prototypes. This patch converts the function signatures to have a prototype for the situations where the test is not specific to K&R C declarations. e.g., void func(); becomes void func(void); This is the eighth batch of tests being updated (there are a significant number of other tests left to be updated).
141 lines
2.5 KiB
C
141 lines
2.5 KiB
C
// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify -std=c99 -Dbool=_Bool -Dtrue=1 -Dfalse=0 %s
|
|
// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify -std=c11 -Dbool=_Bool -Dtrue=1 -Dfalse=0 %s
|
|
extern void clang_analyzer_eval(bool);
|
|
|
|
void test__Bool_value(void) {
|
|
{
|
|
bool b = true;
|
|
clang_analyzer_eval(b == 1); // expected-warning{{TRUE}}
|
|
}
|
|
|
|
{
|
|
bool b = false;
|
|
clang_analyzer_eval(b == 0); // expected-warning{{TRUE}}
|
|
}
|
|
|
|
{
|
|
bool b = -10;
|
|
clang_analyzer_eval(b == 1); // expected-warning{{TRUE}}
|
|
}
|
|
|
|
{
|
|
bool b = 10;
|
|
clang_analyzer_eval(b == 1); // expected-warning{{TRUE}}
|
|
}
|
|
|
|
{
|
|
bool b = 10;
|
|
b++;
|
|
clang_analyzer_eval(b == 1); // expected-warning{{TRUE}}
|
|
}
|
|
|
|
{
|
|
bool b = 0;
|
|
b++;
|
|
clang_analyzer_eval(b == 1); // expected-warning{{TRUE}}
|
|
}
|
|
}
|
|
|
|
void test__Bool_increment(void) {
|
|
{
|
|
bool b = true;
|
|
b++;
|
|
clang_analyzer_eval(b == 1); // expected-warning{{TRUE}}
|
|
}
|
|
|
|
{
|
|
bool b = false;
|
|
b++;
|
|
clang_analyzer_eval(b == 1); // expected-warning{{TRUE}}
|
|
}
|
|
|
|
{
|
|
bool b = true;
|
|
++b;
|
|
clang_analyzer_eval(b == 1); // expected-warning{{TRUE}}
|
|
}
|
|
|
|
{
|
|
bool b = false;
|
|
++b;
|
|
clang_analyzer_eval(b == 1); // expected-warning{{TRUE}}
|
|
}
|
|
|
|
{
|
|
bool b = 0;
|
|
++b;
|
|
clang_analyzer_eval(b == 1); // expected-warning{{TRUE}}
|
|
}
|
|
|
|
{
|
|
bool b = 10;
|
|
++b;
|
|
++b;
|
|
clang_analyzer_eval(b == 1); // expected-warning{{TRUE}}
|
|
}
|
|
|
|
{
|
|
bool b = -10;
|
|
++b;
|
|
clang_analyzer_eval(b == 1); // expected-warning{{TRUE}}
|
|
}
|
|
|
|
{
|
|
bool b = -1;
|
|
++b;
|
|
clang_analyzer_eval(b == 1); // expected-warning{{TRUE}}
|
|
}
|
|
}
|
|
|
|
void test__Bool_decrement(void) {
|
|
{
|
|
bool b = true;
|
|
b--;
|
|
clang_analyzer_eval(b == 0); // expected-warning{{TRUE}}
|
|
}
|
|
|
|
{
|
|
bool b = false;
|
|
b--;
|
|
clang_analyzer_eval(b == 1); // expected-warning{{TRUE}}
|
|
}
|
|
|
|
{
|
|
bool b = true;
|
|
--b;
|
|
clang_analyzer_eval(b == 0); // expected-warning{{TRUE}}
|
|
}
|
|
|
|
{
|
|
bool b = false;
|
|
--b;
|
|
clang_analyzer_eval(b == 1); // expected-warning{{TRUE}}
|
|
}
|
|
|
|
{
|
|
bool b = 0;
|
|
--b;
|
|
clang_analyzer_eval(b == 1); // expected-warning{{TRUE}}
|
|
}
|
|
|
|
{
|
|
bool b = 10;
|
|
--b;
|
|
clang_analyzer_eval(b == 0); // expected-warning{{TRUE}}
|
|
--b;
|
|
clang_analyzer_eval(b == 1); // expected-warning{{TRUE}}
|
|
}
|
|
|
|
{
|
|
bool b = -10;
|
|
--b;
|
|
clang_analyzer_eval(b == 0); // expected-warning{{TRUE}}
|
|
}
|
|
|
|
{
|
|
bool b = 1;
|
|
--b;
|
|
clang_analyzer_eval(b == 0); // expected-warning{{TRUE}}
|
|
}
|
|
}
|