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>
This commit is contained in:
Francois Ferrand
2016-02-26 18:48:39 +01:00
parent 285c8a7543
commit 7b2c09a118
11 changed files with 53 additions and 37 deletions

View File

@@ -403,7 +403,9 @@ void tst_SimpleLexer::ppOpOrPunc()
QFETCH(Kind, expectedTokenKind);
const QByteArray source = QTest::currentDataTag();
run(source, toTokens({unsigned(expectedTokenKind)}), false, CompareKind, true);
LanguageFeatures languageFeatures;
languageFeatures.cxxEnabled = true;
run(source, toTokens({unsigned(expectedTokenKind)}), false, CompareKind, true, languageFeatures);
}
void tst_SimpleLexer::ppOpOrPunc_data()
@@ -574,6 +576,7 @@ void tst_SimpleLexer::user_defined_literals()
const TokenCompareFlags compareFlags = CompareKind | CompareBytes | CompareUtf16Chars | CompareUserDefinedLiteral;
LanguageFeatures languageFeatures;
languageFeatures.cxx11Enabled = true;
languageFeatures.cxxEnabled = true;
run(source, expectedTokens, false, compareFlags, false, languageFeatures);
}
@@ -626,7 +629,10 @@ void tst_SimpleLexer::offsets()
| CompareUtf16CharsBegin
| CompareUtf16CharsEnd
;
run(source, expectedTokens, false, compareFlags);
LanguageFeatures languageFeatures;
languageFeatures.cxxEnabled = true;
run(source, expectedTokens, false, compareFlags, false, languageFeatures);
}
void tst_SimpleLexer::offsets_data()