Don't compare foreign values to enumeration type
Clang warns when comparing an enumeration type with a value not found in this enumeration: warning: comparison of constant VALUE with expression of type 'TYPE' is always false [-Wtautological-constant-out-of-range-compare] If the compiler then decides to optimize the test away because it assumes the it is indeed always false, it can lead to pretty subtle and nasty issues. Ported universal-ctags patch from Colomban Wendling
This commit is contained in:
parent
cb7da79824
commit
1e14667bbc
@ -57,7 +57,7 @@ typedef enum eException
|
||||
|
||||
/* Used to specify type of keyword.
|
||||
*/
|
||||
typedef enum eKeywordId
|
||||
enum eKeywordId
|
||||
{
|
||||
KEYWORD_ATTRIBUTE, KEYWORD_ABSTRACT, KEYWORD_ALIAS,
|
||||
KEYWORD_BOOLEAN, KEYWORD_BYTE, KEYWORD_BAD_STATE, KEYWORD_BAD_TRANS,
|
||||
@ -92,7 +92,8 @@ typedef enum eKeywordId
|
||||
KEYWORD_USING,
|
||||
KEYWORD_VIRTUAL, KEYWORD_VOID, KEYWORD_VOLATILE,
|
||||
KEYWORD_WCHAR_T, KEYWORD_WEAK, KEYWORD_WHILE
|
||||
} keywordId;
|
||||
};
|
||||
typedef int keywordId; /* to allow KEYWORD_NONE */
|
||||
|
||||
/* Used to determine whether keyword is valid for the current language and
|
||||
* what its ID is.
|
||||
|
@ -61,7 +61,7 @@ typedef enum eFortranLineType {
|
||||
|
||||
/* Used to specify type of keyword.
|
||||
*/
|
||||
typedef enum eKeywordId {
|
||||
enum eKeywordId {
|
||||
KEYWORD_allocatable,
|
||||
KEYWORD_assignment,
|
||||
KEYWORD_associate,
|
||||
@ -140,7 +140,8 @@ typedef enum eKeywordId {
|
||||
KEYWORD_volatile,
|
||||
KEYWORD_where,
|
||||
KEYWORD_while
|
||||
} keywordId;
|
||||
};
|
||||
typedef int keywordId; /* to allow KEYWORD_NONE */
|
||||
|
||||
typedef enum eTokenType {
|
||||
TOKEN_UNDEFINED,
|
||||
|
@ -27,7 +27,7 @@
|
||||
* DATA DECLARATIONS
|
||||
*/
|
||||
|
||||
typedef enum eKeywordId {
|
||||
enum eKeywordId {
|
||||
KEYWORD_package,
|
||||
KEYWORD_import,
|
||||
KEYWORD_const,
|
||||
@ -38,7 +38,8 @@ typedef enum eKeywordId {
|
||||
KEYWORD_interface,
|
||||
KEYWORD_map,
|
||||
KEYWORD_chan
|
||||
} keywordId;
|
||||
};
|
||||
typedef int keywordId; /* to allow KEYWORD_NONE */
|
||||
|
||||
typedef enum eTokenType {
|
||||
TOKEN_NONE = -1,
|
||||
|
@ -51,7 +51,7 @@ static stringList *FunctionNames;
|
||||
|
||||
/* Used to specify type of keyword.
|
||||
*/
|
||||
typedef enum eKeywordId {
|
||||
enum eKeywordId {
|
||||
KEYWORD_function,
|
||||
KEYWORD_capital_function,
|
||||
KEYWORD_capital_object,
|
||||
@ -72,7 +72,8 @@ typedef enum eKeywordId {
|
||||
KEYWORD_finally,
|
||||
KEYWORD_sap,
|
||||
KEYWORD_return
|
||||
} keywordId;
|
||||
};
|
||||
typedef int keywordId; /* to allow KEYWORD_NONE */
|
||||
|
||||
typedef enum eTokenType {
|
||||
TOKEN_UNDEFINED,
|
||||
|
@ -24,7 +24,7 @@
|
||||
#define SCOPE_SEPARATOR "::"
|
||||
|
||||
|
||||
typedef enum {
|
||||
enum {
|
||||
KEYWORD_abstract,
|
||||
KEYWORD_and,
|
||||
KEYWORD_as,
|
||||
@ -84,7 +84,8 @@ typedef enum {
|
||||
KEYWORD_while,
|
||||
KEYWORD_xor,
|
||||
KEYWORD_yield
|
||||
} keywordId;
|
||||
};
|
||||
typedef int keywordId; /* to allow KEYWORD_NONE */
|
||||
|
||||
typedef enum {
|
||||
ACCESS_UNDEFINED,
|
||||
|
@ -53,7 +53,7 @@ typedef enum eException { ExceptionNone, ExceptionEOF } exception_t;
|
||||
/*
|
||||
* Used to specify type of keyword.
|
||||
*/
|
||||
typedef enum eKeywordId {
|
||||
enum eKeywordId {
|
||||
KEYWORD_is,
|
||||
KEYWORD_begin,
|
||||
KEYWORD_body,
|
||||
@ -126,7 +126,8 @@ typedef enum eKeywordId {
|
||||
KEYWORD_comment,
|
||||
KEYWORD_create,
|
||||
KEYWORD_go
|
||||
} keywordId;
|
||||
};
|
||||
typedef int keywordId; /* to allow KEYWORD_NONE */
|
||||
|
||||
typedef enum eTokenType {
|
||||
TOKEN_UNDEFINED,
|
||||
|
Loading…
x
Reference in New Issue
Block a user