summaryrefslogtreecommitdiff
path: root/src/libs/cplusplus
diff options
context:
space:
mode:
authorFrancois Ferrand <thetypz@gmail.com>2014-10-24 14:55:43 +0200
committerFrancois Ferrand <thetypz@gmail.com>2016-03-08 17:24:22 +0000
commit41b232962a9222ddc594ef7d564041af0c476cb9 (patch)
treee38343360733bd601d388c08a9fb20ff43744023 /src/libs/cplusplus
parent90571432280a36f5e9ef5da468f832cf1d973f66 (diff)
downloadqt-creator-41b232962a9222ddc594ef7d564041af0c476cb9.tar.gz
C++: fix trigraph parsing in macros.
Trigraphs must only be parsed before/during preprocessing. The preprocessor will now replace trigraphs with their standard form, and re-lexing in TranslationUnit will not try to parse any trigraph. Also added a few missing trigraphs: ??=, ??', ??! and ??-. Task-number: QTCREATORBUG-13253 Change-Id: I1723ed53b00090b878c22b83b7e963b647b65f72 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Diffstat (limited to 'src/libs/cplusplus')
-rw-r--r--src/libs/cplusplus/pp-engine.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp
index c505f94e3e..134fb4d51c 100644
--- a/src/libs/cplusplus/pp-engine.cpp
+++ b/src/libs/cplusplus/pp-engine.cpp
@@ -50,6 +50,7 @@
#include <cplusplus/Lexer.h>
#include <cplusplus/Token.h>
#include <cplusplus/Literals.h>
+#include <cplusplus/cppassert.h>
#include <utils/scopedswap.h>
@@ -1439,7 +1440,25 @@ void Preprocessor::preprocess(const QString &fileName, const QByteArray &source,
enforceSpacing(tk, macroExpanded);
// Finally output the token.
- currentOutputBuffer().append(tk.tokenStart(), tk.bytes());
+ if (!tk.f.trigraph) {
+ currentOutputBuffer().append(tk.tokenStart(), tk.bytes());
+ } else {
+ switch (tk.kind()) {
+ case T_LBRACKET: currentOutputBuffer().append("["); break;
+ case T_RBRACKET: currentOutputBuffer().append("]"); break;
+ case T_LBRACE: currentOutputBuffer().append("{"); break;
+ case T_RBRACE: currentOutputBuffer().append("}"); break;
+ case T_POUND: currentOutputBuffer().append("#"); break;
+ case T_POUND_POUND: currentOutputBuffer().append("##"); break;
+ case T_CARET: currentOutputBuffer().append("^"); break;
+ case T_CARET_EQUAL: currentOutputBuffer().append("^="); break;
+ case T_PIPE: currentOutputBuffer().append("|"); break;
+ case T_PIPE_EQUAL: currentOutputBuffer().append("|="); break;
+ case T_TILDE: currentOutputBuffer().append("~"); break;
+ case T_TILDE_EQUAL: currentOutputBuffer().append("~="); break;
+ default: CPP_ASSERT(0, qDebug() << tk.spell()); break;
+ }
+ }
} while (tk.isNot(T_EOF_SYMBOL));