mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-13 19:24:21 +00:00
0dd49a5628
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).
35 lines
1.3 KiB
C
35 lines
1.3 KiB
C
// RUN: %clang_analyze_cc1 \
|
|
// RUN: -analyzer-checker=core,alpha.cplusplus.EnumCastOutOfRange \
|
|
// RUN: -verify %s
|
|
|
|
enum En_t {
|
|
En_0 = -4,
|
|
En_1,
|
|
En_2 = 1,
|
|
En_3,
|
|
En_4 = 4
|
|
};
|
|
|
|
void unscopedUnspecifiedCStyle(void) {
|
|
enum En_t Below = (enum En_t)(-5); // expected-warning {{not in the valid range}}
|
|
enum En_t NegVal1 = (enum En_t)(-4); // OK.
|
|
enum En_t NegVal2 = (enum En_t)(-3); // OK.
|
|
enum En_t InRange1 = (enum En_t)(-2); // expected-warning {{not in the valid range}}
|
|
enum En_t InRange2 = (enum En_t)(-1); // expected-warning {{not in the valid range}}
|
|
enum En_t InRange3 = (enum En_t)(0); // expected-warning {{not in the valid range}}
|
|
enum En_t PosVal1 = (enum En_t)(1); // OK.
|
|
enum En_t PosVal2 = (enum En_t)(2); // OK.
|
|
enum En_t InRange4 = (enum En_t)(3); // expected-warning {{not in the valid range}}
|
|
enum En_t PosVal3 = (enum En_t)(4); // OK.
|
|
enum En_t Above = (enum En_t)(5); // expected-warning {{not in the valid range}}
|
|
}
|
|
|
|
enum En_t unused;
|
|
void unusedExpr(void) {
|
|
// Following line is not something that EnumCastOutOfRangeChecker should
|
|
// evaluate. Checker should either ignore this line or process it without
|
|
// producing any warnings. However, compilation will (and should) still
|
|
// generate a warning having nothing to do with this checker.
|
|
unused; // expected-warning {{expression result unused}}
|
|
}
|