blob: c4c5c38cddba0ad04e67428df8e6777e2c109b54 [file] [edit]
// DEFINE: %{analyze} = %clang_analyze_cc1 %s -triple x86_64-unknown-linux-gnu \
// DEFINE: -analyzer-checker=core,unix.StdCLibraryFunctions,debug.ExprInspection
// An EOF that is empty or outside the [INT_MIN, UINT_MAX] of the target is
// ignored, and the default of -1 is used. The int of AVR has 16 bits.
// RUN: %{analyze} -verify=ignored '-DEOF='
// RUN: %{analyze} -verify=ignored '-DEOF=()'
// RUN: %{analyze} -verify=ignored -DEOF=0x100000000
// RUN: %{analyze} -verify=ignored -DEOF=-0x80000001
// RUN: %{analyze} -verify=ignored -DEOF=0x8000000000000000
// RUN: %{analyze} -verify=ignored -DEOF=0x10000 -triple avr
// A value above INT_MAX in that range is converted to int.
// RUN: %{analyze} -verify=converted -DEOF=0xFFFFFFFE
void clang_analyzer_eval(int);
typedef struct FILE FILE;
int getc(FILE *);
void test_getc(FILE *fp) {
int y = getc(fp);
if (y < 0) {
clang_analyzer_eval(y == -1); // ignored-warning{{TRUE}} converted-warning{{FALSE}}
clang_analyzer_eval(y == -2); // ignored-warning{{FALSE}} converted-warning{{TRUE}}
}
}