aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libs/3rdparty/cplusplus/Keywords.cpp56
-rw-r--r--src/libs/3rdparty/cplusplus/Token.h1
-rw-r--r--src/libs/cplusplus/MatchingText.cpp1
-rw-r--r--src/plugins/cppeditor/cpphighlighter.cpp1
-rw-r--r--src/plugins/cpptools/cppcodeformatter.cpp1
-rw-r--r--src/plugins/cpptools/projectpart.cpp3
-rw-r--r--src/plugins/cpptools/projectpartbuilder.cpp13
-rw-r--r--tests/auto/cplusplus/ast/tst_ast.cpp1
-rw-r--r--tests/auto/cplusplus/cxx11/tst_cxx11.cpp2
-rw-r--r--tests/auto/cplusplus/lexer/tst_lexer.cpp10
-rw-r--r--tests/auto/cplusplus/semantic/tst_semantic.cpp1
11 files changed, 53 insertions, 37 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;
diff --git a/src/libs/cplusplus/MatchingText.cpp b/src/libs/cplusplus/MatchingText.cpp
index 08ea34c918..86b37c97c7 100644
--- a/src/libs/cplusplus/MatchingText.cpp
+++ b/src/libs/cplusplus/MatchingText.cpp
@@ -201,6 +201,7 @@ static Tokens getTokens(const QTextCursor &cursor, int &prevState)
features.qtKeywordsEnabled = false;
features.qtMocRunEnabled = false;
features.cxx11Enabled = true;
+ features.cxxEnabled = true;
features.c99Enabled = true;
SimpleLexer tokenize;
diff --git a/src/plugins/cppeditor/cpphighlighter.cpp b/src/plugins/cppeditor/cpphighlighter.cpp
index e9b21d81fd..17fb5e668e 100644
--- a/src/plugins/cppeditor/cpphighlighter.cpp
+++ b/src/plugins/cppeditor/cpphighlighter.cpp
@@ -74,6 +74,7 @@ void CppHighlighter::highlightBlock(const QString &text)
// FIXME: Check defaults or get from document.
LanguageFeatures features;
features.cxx11Enabled = true;
+ features.cxxEnabled = true;
features.c99Enabled = true;
SimpleLexer tokenize;
diff --git a/src/plugins/cpptools/cppcodeformatter.cpp b/src/plugins/cpptools/cppcodeformatter.cpp
index 0d3586dcd1..e27832a2ff 100644
--- a/src/plugins/cpptools/cppcodeformatter.cpp
+++ b/src/plugins/cpptools/cppcodeformatter.cpp
@@ -1066,6 +1066,7 @@ int CodeFormatter::tokenizeBlock(const QTextBlock &block, bool *endedJoined)
features.qtEnabled = true;
features.qtMocRunEnabled = true;
features.qtKeywordsEnabled = true;
+ features.cxxEnabled = true;
features.objCEnabled = true;
SimpleLexer tokenize;
diff --git a/src/plugins/cpptools/projectpart.cpp b/src/plugins/cpptools/projectpart.cpp
index e091c50483..85ea324c9f 100644
--- a/src/plugins/cpptools/projectpart.cpp
+++ b/src/plugins/cpptools/projectpart.cpp
@@ -45,6 +45,9 @@ void ProjectPart::updateLanguageFeatures()
{
const bool hasQt = qtVersion != NoQt;
languageFeatures.cxx11Enabled = languageVersion >= CXX11;
+ languageFeatures.cxxEnabled = languageVersion >= CXX98;
+ languageFeatures.c99Enabled = languageVersion >= C99;
+ languageFeatures.objCEnabled = languageExtensions & ObjectiveCExtensions;
languageFeatures.qtEnabled = hasQt;
languageFeatures.qtMocRunEnabled = hasQt;
if (!hasQt) {
diff --git a/src/plugins/cpptools/projectpartbuilder.cpp b/src/plugins/cpptools/projectpartbuilder.cpp
index 224f0678f8..b01795f9cf 100644
--- a/src/plugins/cpptools/projectpartbuilder.cpp
+++ b/src/plugins/cpptools/projectpartbuilder.cpp
@@ -208,11 +208,11 @@ void ProjectPartBuilder::setConfigFileName(const QString &configFileName)
QList<Core::Id> ProjectPartBuilder::createProjectPartsForFiles(const QStringList &files,
FileClassifier fileClassifier)
{
- QList<Core::Id> languages;
+ QSet<Core::Id> languages;
ProjectFileCategorizer cat(m_templatePart->displayName, files, fileClassifier);
if (cat.hasNoParts())
- return languages;
+ return languages.toList();
using CppTools::ProjectFile;
using CppTools::ProjectPart;
@@ -223,7 +223,7 @@ QList<Core::Id> ProjectPartBuilder::createProjectPartsForFiles(const QStringList
ProjectPart::C11,
ProjectPart::NoExtensions);
// TODO: there is no C...
-// languages += ProjectExplorer::Constants::LANG_C;
+ languages += ProjectExplorer::Constants::LANG_CXX;
}
if (cat.hasObjcSources()) {
createProjectPart(cat.objcSources(),
@@ -231,7 +231,7 @@ QList<Core::Id> ProjectPartBuilder::createProjectPartsForFiles(const QStringList
ProjectPart::C11,
ProjectPart::ObjectiveCExtensions);
// TODO: there is no Ojective-C...
-// languages += ProjectExplorer::Constants::LANG_OBJC;
+ languages += ProjectExplorer::Constants::LANG_CXX;
}
if (cat.hasCxxSources()) {
createProjectPart(cat.cxxSources(),
@@ -249,7 +249,7 @@ QList<Core::Id> ProjectPartBuilder::createProjectPartsForFiles(const QStringList
languages += ProjectExplorer::Constants::LANG_CXX;
}
- return languages;
+ return languages.toList();
}
namespace {
@@ -316,8 +316,6 @@ void ProjectPartBuilder::evaluateProjectPartToolchain(
languageVersion = ProjectPart::CXX11;
else if (flags & ToolChain::StandardCxx98)
languageVersion = ProjectPart::CXX98;
- else
- languageVersion = ProjectPart::CXX11;
auto &languageExtensions = projectPart->languageExtensions;
@@ -357,6 +355,7 @@ void ProjectPartBuilder::createProjectPart(const QVector<ProjectFile> &theSource
ProjectPart::Ptr part(m_templatePart->copy());
part->displayName = partName;
part->files = theSources;
+ part->languageVersion = languageVersion;
QTC_ASSERT(part->project, return);
if (ProjectExplorer::Target *activeTarget = part->project->activeTarget()) {
diff --git a/tests/auto/cplusplus/ast/tst_ast.cpp b/tests/auto/cplusplus/ast/tst_ast.cpp
index 9fda954780..509949e3c9 100644
--- a/tests/auto/cplusplus/ast/tst_ast.cpp
+++ b/tests/auto/cplusplus/ast/tst_ast.cpp
@@ -51,6 +51,7 @@ public:
const StringLiteral *fileId = control.stringLiteral("<stdin>");
LanguageFeatures features;
features.cxx11Enabled = cxx11Enabled;
+ features.cxxEnabled = true;
features.objCEnabled = true;
features.qtEnabled = qtMocRun;
features.qtKeywordsEnabled = qtMocRun;
diff --git a/tests/auto/cplusplus/cxx11/tst_cxx11.cpp b/tests/auto/cplusplus/cxx11/tst_cxx11.cpp
index f75b7e29e6..ef81d41235 100644
--- a/tests/auto/cplusplus/cxx11/tst_cxx11.cpp
+++ b/tests/auto/cplusplus/cxx11/tst_cxx11.cpp
@@ -141,6 +141,7 @@ class tst_cxx11: public QObject
if (file.open(QFile::ReadOnly)) {
LanguageFeatures features;
features.cxx11Enabled = true;
+ features.cxxEnabled = true;
features.c99Enabled = c99Enabled;
processDocument(doc, QTextStream(&file).readAll().toUtf8(), features, errors);
} else {
@@ -292,6 +293,7 @@ void tst_cxx11::lambdaType()
LanguageFeatures features;
features.cxx11Enabled = true;
+ features.cxxEnabled = true;
QByteArray errors;
Document::Ptr doc = Document::create(QLatin1String("testFile"));
diff --git a/tests/auto/cplusplus/lexer/tst_lexer.cpp b/tests/auto/cplusplus/lexer/tst_lexer.cpp
index fd36540902..23ddcc21b0 100644
--- a/tests/auto/cplusplus/lexer/tst_lexer.cpp
+++ b/tests/auto/cplusplus/lexer/tst_lexer.cpp
@@ -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()
diff --git a/tests/auto/cplusplus/semantic/tst_semantic.cpp b/tests/auto/cplusplus/semantic/tst_semantic.cpp
index b7a4c161cf..bfa85b38a3 100644
--- a/tests/auto/cplusplus/semantic/tst_semantic.cpp
+++ b/tests/auto/cplusplus/semantic/tst_semantic.cpp
@@ -142,6 +142,7 @@ public:
features.qtMocRunEnabled = qtMocRun;
features.qtKeywordsEnabled = qtMocRun;
features.cxx11Enabled = enableCxx11;
+ features.cxxEnabled = true;
diag.errorCount = 0; // reset the error count.
TranslationUnit *unit = parse(source, TranslationUnit::ParseTranlationUnit, features);
QSharedPointer<Document> doc(new Document(unit));