diff options
author | Francois Ferrand <thetypz@gmail.com> | 2016-02-26 18:48:39 +0100 |
---|---|---|
committer | Francois Ferrand <thetypz@gmail.com> | 2016-08-23 12:35:04 +0000 |
commit | 7b2c09a1186f2cf69f276017ba08da89560f55be (patch) | |
tree | e336ae35ba2779b4051d1fcdfb9003b40792b88a /src/libs/3rdparty | |
parent | 285c8a7543aae0d71949451f04c99a4924900104 (diff) | |
download | qt-creator-7b2c09a1186f2cf69f276017ba08da89560f55be.tar.gz |
C++: Disable C++ keywords in C files
In some (legacy) C files, new and delete may be used for regular identifier.
There are some limitations:
* Header files have no 'implicit' type, and may be parsed as C++ or ObjC depending on the
other files in the project.
* QMakeProject use a single ProjectPart for C and C++ files, so there will still be the issue.
Change-Id: Iec11687b35f7ccf1e7c0d091b143ae90d950e440
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'src/libs/3rdparty')
-rw-r--r-- | src/libs/3rdparty/cplusplus/Keywords.cpp | 56 | ||||
-rw-r--r-- | src/libs/3rdparty/cplusplus/Token.h | 1 |
2 files changed, 29 insertions, 28 deletions
diff --git a/src/libs/3rdparty/cplusplus/Keywords.cpp b/src/libs/3rdparty/cplusplus/Keywords.cpp index a1cbcb4a3d..a71058a903 100644 --- a/src/libs/3rdparty/cplusplus/Keywords.cpp +++ b/src/libs/3rdparty/cplusplus/Keywords.cpp @@ -61,14 +61,14 @@ static inline int classify3(const char *s, LanguageFeatures features) } } } - else if (s[0] == 'n') { + else if (features.cxxEnabled && s[0] == 'n') { if (s[1] == 'e') { if (s[2] == 'w') { return T_NEW; } } } - else if (s[0] == 't') { + else if (features.cxxEnabled && s[0] == 't') { if (s[1] == 'r') { if (s[2] == 'y') { return T_TRY; @@ -90,7 +90,7 @@ static inline int classify3(const char *s, LanguageFeatures features) static inline int classify4(const char *s, LanguageFeatures features) { - if (s[0] == 'a') { + if (features.cxxEnabled && s[0] == 'a') { if (s[1] == 'u') { if (s[2] == 't') { if (s[3] == 'o') { @@ -166,7 +166,7 @@ static inline int classify4(const char *s, LanguageFeatures features) } } else if (s[0] == 't') { - if (s[1] == 'h') { + if (features.cxxEnabled && s[1] == 'h') { if (s[2] == 'i') { if (s[3] == 's') { return T_THIS; @@ -227,7 +227,7 @@ static inline int classify5(const char *s, LanguageFeatures features) } } else if (s[0] == 'c') { - if (s[1] == 'a') { + if (features.cxxEnabled && s[1] == 'a') { if (s[2] == 't') { if (s[3] == 'c') { if (s[4] == 'h') { @@ -236,7 +236,7 @@ static inline int classify5(const char *s, LanguageFeatures features) } } } - else if (s[1] == 'l') { + else if (features.cxxEnabled && s[1] == 'l') { if (s[2] == 'a') { if (s[3] == 's') { if (s[4] == 's') { @@ -297,7 +297,7 @@ static inline int classify5(const char *s, LanguageFeatures features) } } } - else if (s[0] == 't') { + else if (features.cxxEnabled && s[0] == 't') { if (s[1] == 'h') { if (s[2] == 'r') { if (s[3] == 'o') { @@ -318,7 +318,7 @@ static inline int classify5(const char *s, LanguageFeatures features) } } } - else if (s[1] == 's') { + else if (features.cxxEnabled && s[1] == 's') { if (s[2] == 'i') { if (s[3] == 'n') { if (s[4] == 'g') { @@ -345,7 +345,7 @@ static inline int classify5(const char *s, LanguageFeatures features) static inline int classify6(const char *s, LanguageFeatures features) { if (s[0] == 'd') { - if (s[1] == 'e') { + if (features.cxxEnabled && s[1] == 'e') { if (s[2] == 'l') { if (s[3] == 'e') { if (s[4] == 't') { @@ -370,7 +370,7 @@ static inline int classify6(const char *s, LanguageFeatures features) } else if (s[0] == 'e') { if (s[1] == 'x') { - if (s[2] == 'p') { + if (features.cxxEnabled && s[2] == 'p') { if (s[3] == 'o') { if (s[4] == 'r') { if (s[5] == 't') { @@ -390,7 +390,7 @@ static inline int classify6(const char *s, LanguageFeatures features) } } } - else if (s[0] == 'f') { + else if (features.cxxEnabled && s[0] == 'f') { if (s[1] == 'r') { if (s[2] == 'i') { if (s[3] == 'e') { @@ -416,7 +416,7 @@ static inline int classify6(const char *s, LanguageFeatures features) } } } - else if (s[0] == 'p') { + else if (features.cxxEnabled && s[0] == 'p') { if (s[1] == 'u') { if (s[2] == 'b') { if (s[3] == 'l') { @@ -499,7 +499,7 @@ static inline int classify6(const char *s, LanguageFeatures features) if (s[1] == 'y') { if (s[2] == 'p') { if (s[3] == 'e') { - if (s[4] == 'i') { + if (features.cxxEnabled && s[4] == 'i') { if (s[5] == 'd') { return T_TYPEID; } @@ -614,7 +614,7 @@ static inline int classify7(const char *s, LanguageFeatures features) } } } - else if (s[0] == 'm') { + else if (features.cxxEnabled && s[0] == 'm') { if (s[1] == 'u') { if (s[2] == 't') { if (s[3] == 'a') { @@ -644,7 +644,7 @@ static inline int classify7(const char *s, LanguageFeatures features) } } } - else if (s[0] == 'p') { + else if (features.cxxEnabled && s[0] == 'p') { if (s[1] == 'r') { if (s[2] == 'i') { if (s[3] == 'v') { @@ -704,7 +704,7 @@ static inline int classify7(const char *s, LanguageFeatures features) } } } - else if (s[0] == 'v') { + else if (features.cxxEnabled && s[0] == 'v') { if (s[1] == 'i') { if (s[2] == 'r') { if (s[3] == 't') { @@ -719,7 +719,7 @@ static inline int classify7(const char *s, LanguageFeatures features) } } } - else if (s[0] == 'w') { + else if (features.cxxEnabled && s[0] == 'w') { if (s[1] == 'c') { if (s[2] == 'h') { if (s[3] == 'a') { @@ -873,7 +873,7 @@ static inline int classify8(const char *s, LanguageFeatures features) } } } - else if (s[0] == 'e') { + else if (features.cxxEnabled && s[0] == 'e') { if (s[1] == 'x') { if (s[2] == 'p') { if (s[3] == 'l') { @@ -907,7 +907,7 @@ static inline int classify8(const char *s, LanguageFeatures features) } } } - else if (s[0] == 'o') { + else if (features.cxxEnabled && s[0] == 'o') { if (s[1] == 'p') { if (s[2] == 'e') { if (s[3] == 'r') { @@ -941,7 +941,7 @@ static inline int classify8(const char *s, LanguageFeatures features) } } } - else if (s[0] == 't') { + else if (features.cxxEnabled && s[0] == 't') { if (s[1] == 'e') { if (s[2] == 'm') { if (s[3] == 'p') { @@ -1093,7 +1093,7 @@ static inline int classify9(const char *s, LanguageFeatures features) } } } - else if (s[0] == 'n') { + else if (features.cxxEnabled && s[0] == 'n') { if (s[1] == 'a') { if (s[2] == 'm') { if (s[3] == 'e') { @@ -1112,7 +1112,7 @@ static inline int classify9(const char *s, LanguageFeatures features) } } } - else if (s[0] == 'p') { + else if (features.cxxEnabled && s[0] == 'p') { if (s[1] == 'r') { if (s[2] == 'o') { if (s[3] == 't') { @@ -1188,7 +1188,7 @@ static inline int classify10(const char *s, LanguageFeatures features) } } } - else if (s[2] == 'd') { + else if (features.cxxEnabled && s[2] == 'd') { if (s[3] == 'e') { if (s[4] == 'c') { if (s[5] == 'l') { @@ -1241,7 +1241,7 @@ static inline int classify10(const char *s, LanguageFeatures features) } } } - else if (s[0] == 'c') { + else if (features.cxxEnabled && s[0] == 'c') { if (s[1] == 'o') { if (s[2] == 'n') { if (s[3] == 's') { @@ -1344,7 +1344,7 @@ static inline int classify11(const char *s, LanguageFeatures features) } } } - else if (s[0] == 's') { + else if (features.cxxEnabled && s[0] == 's') { if (s[1] == 't') { if (s[2] == 'a') { if (s[3] == 't') { @@ -1445,7 +1445,7 @@ static inline int classify12(const char *s, LanguageFeatures features) } } } - else if (s[0] == 'd') { + else if (features.cxxEnabled && s[0] == 'd') { if (s[1] == 'y') { if (s[2] == 'n') { if (s[3] == 'a') { @@ -1556,9 +1556,9 @@ static inline int classify13(const char *s, LanguageFeatures features) return T_IDENTIFIER; } -static inline int classify16(const char *s, LanguageFeatures) +static inline int classify16(const char *s, LanguageFeatures features) { - if (s[0] == 'r') { + if (features.cxxEnabled && s[0] == 'r') { if (s[1] == 'e') { if (s[2] == 'i') { if (s[3] == 'n') { diff --git a/src/libs/3rdparty/cplusplus/Token.h b/src/libs/3rdparty/cplusplus/Token.h index 358587366e..c460f59582 100644 --- a/src/libs/3rdparty/cplusplus/Token.h +++ b/src/libs/3rdparty/cplusplus/Token.h @@ -413,6 +413,7 @@ struct LanguageFeatures unsigned int qtEnabled : 1; // If Qt is used. unsigned int qtMocRunEnabled : 1; unsigned int qtKeywordsEnabled : 1; // If Qt is used but QT_NO_KEYWORDS defined + unsigned int cxxEnabled : 1; unsigned int cxx11Enabled : 1; unsigned int objCEnabled : 1; unsigned int c99Enabled : 1; |