diff options
| author | Thiago Macieira <[email protected]> | 2009-07-27 21:47:03 +0200 |
|---|---|---|
| committer | Thiago Macieira <[email protected]> | 2009-08-03 14:59:42 +0200 |
| commit | d0457b70e33f1a090a91b0037e9254a0e14b8427 (patch) | |
| tree | 2984b2db2129ba8cfefeac46d246a4a335b92150 /src/libs | |
| parent | 88549a4b1dbbb16c7d63f176fd870ec8bdb61477 (diff) | |
Compile the C++ parser library with Sun CC 5.9.
Things you mustn't do:
1) end an enum with a comma
2) #include <cxxxx> and not use std::
3) use anonymous structures
All three things are invalid C++. Anonymous structures inside
anonymous unions are allowed by GCC, but that doesn't mean it's valid.
Diffstat (limited to 'src/libs')
| -rw-r--r-- | src/libs/cplusplus/Macro.cpp | 6 | ||||
| -rw-r--r-- | src/libs/cplusplus/Macro.h | 27 | ||||
| -rw-r--r-- | src/libs/cplusplus/SimpleLexer.cpp | 4 | ||||
| -rw-r--r-- | src/libs/cplusplus/pp-engine.cpp | 22 |
4 files changed, 30 insertions, 29 deletions
diff --git a/src/libs/cplusplus/Macro.cpp b/src/libs/cplusplus/Macro.cpp index b510dc1f51b..0c6f0344a1e 100644 --- a/src/libs/cplusplus/Macro.cpp +++ b/src/libs/cplusplus/Macro.cpp @@ -60,12 +60,12 @@ Macro::Macro() QString Macro::toString() const { QString text; - if (_hidden) + if (f._hidden) text += QLatin1String("#undef "); else text += QLatin1String("#define "); text += QString::fromUtf8(_name.constData(), _name.size()); - if (_functionLike) { + if (f._functionLike) { text += QLatin1Char('('); bool first = true; foreach (const QByteArray formal, _formals) { @@ -75,7 +75,7 @@ QString Macro::toString() const first = false; text += QString::fromUtf8(formal.constData(), formal.size()); } - if (_variadic) + if (f._variadic) text += QLatin1String("..."); text += QLatin1Char(')'); } diff --git a/src/libs/cplusplus/Macro.h b/src/libs/cplusplus/Macro.h index 922daeca358..cf35a691824 100644 --- a/src/libs/cplusplus/Macro.h +++ b/src/libs/cplusplus/Macro.h @@ -93,22 +93,22 @@ public: { _line = line; } bool isHidden() const - { return _hidden; } + { return f._hidden; } void setHidden(bool isHidden) - { _hidden = isHidden; } + { f._hidden = isHidden; } bool isFunctionLike() const - { return _functionLike; } + { return f._functionLike; } void setFunctionLike(bool isFunctionLike) - { _functionLike = isFunctionLike; } + { f._functionLike = isFunctionLike; } bool isVariadic() const - { return _variadic; } + { return f._variadic; } void setVariadic(bool isVariadic) - { _variadic = isVariadic; } + { f._variadic = isVariadic; } QString toString() const; @@ -117,6 +117,13 @@ public: unsigned _hashcode; private: + struct Flags + { + unsigned _hidden: 1; + unsigned _functionLike: 1; + unsigned _variadic: 1; + }; + QByteArray _name; QByteArray _definition; QVector<QByteArray> _formals; @@ -126,13 +133,7 @@ private: union { unsigned _state; - - struct - { - unsigned _hidden: 1; - unsigned _functionLike: 1; - unsigned _variadic: 1; - }; + Flags f; }; }; diff --git a/src/libs/cplusplus/SimpleLexer.cpp b/src/libs/cplusplus/SimpleLexer.cpp index 60ce47cd8fc..7fa9677bda5 100644 --- a/src/libs/cplusplus/SimpleLexer.cpp +++ b/src/libs/cplusplus/SimpleLexer.cpp @@ -129,14 +129,14 @@ QList<SimpleToken> SimpleLexer::operator()(const QString &text, int state) break; SimpleToken simpleTk; - simpleTk._kind = int(tk.kind); + simpleTk._kind = int(tk.f.kind); simpleTk._position = int(lex.tokenOffset()); simpleTk._length = int(lex.tokenLength()); simpleTk._text = text.midRef(simpleTk._position, simpleTk._length); lex.setScanAngleStringLiteralTokens(false); - if (tk.newline && tk.is(T_POUND)) + if (tk.f.newline && tk.is(T_POUND)) inPreproc = true; else if (inPreproc && tokens.size() == 1 && simpleTk.is(T_IDENTIFIER) && simpleTk.text() == QLatin1String("include")) diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index 35ddf3ace82..ec169c3d942 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -64,7 +64,7 @@ struct Value { enum Kind { Kind_Long, - Kind_ULong, + Kind_ULong }; Kind kind; @@ -231,7 +231,7 @@ protected: QByteArray tokenSpell() const { const QByteArray text = QByteArray::fromRawData(source.constData() + (*_lex)->offset, - (*_lex)->length); + (*_lex)->f.length); return text; } @@ -677,7 +677,7 @@ void Preprocessor::processSkippingBlocks(bool skippingBlocks, unsigned offset = start->offset; if (_skipping[iflevel]) { - if (_dot->newline) + if (_dot->f.newline) ++offset; client->startSkippingBlocks(offset); @@ -751,7 +751,7 @@ void Preprocessor::preprocess(const QString &fileName, const QByteArray &source, while (true) { - if (_dot->joined) + if (_dot->f.joined) out("\\"); processNewline(); @@ -759,13 +759,13 @@ void Preprocessor::preprocess(const QString &fileName, const QByteArray &source, if (_dot->is(T_EOF_SYMBOL)) { break; - } else if (_dot->is(T_POUND) && (! _dot->joined && _dot->newline)) { + } else if (_dot->is(T_POUND) && (! _dot->f.joined && _dot->f.newline)) { // handle the preprocessor directive TokenIterator start = _dot; do { ++_dot; - } while (_dot->isNot(T_EOF_SYMBOL) && (_dot->joined || ! _dot->newline)); + } while (_dot->isNot(T_EOF_SYMBOL) && (_dot->f.joined || ! _dot->f.newline)); const bool skippingBlocks = _skipping[iflevel]; @@ -777,11 +777,11 @@ void Preprocessor::preprocess(const QString &fileName, const QByteArray &source, do { ++_dot; - } while (_dot->isNot(T_EOF_SYMBOL) && (_dot->joined || ! _dot->newline)); + } while (_dot->isNot(T_EOF_SYMBOL) && (_dot->f.joined || ! _dot->f.newline)); } else { - if (_dot->whitespace) { + if (_dot->f.whitespace) { unsigned endOfPreviousToken = 0; if (_dot != _tokens.constBegin()) @@ -1027,14 +1027,14 @@ const char *Preprocessor::endOfToken(const Token &token) const QByteArray Preprocessor::tokenSpell(const Token &token) const { const QByteArray text = QByteArray::fromRawData(_source.constBegin() + token.offset, - token.length); + token.f.length); return text; } QByteArray Preprocessor::tokenText(const Token &token) const { const QByteArray text(_source.constBegin() + token.offset, - token.length); + token.f.length); return text; } @@ -1179,7 +1179,7 @@ void Preprocessor::processDefine(TokenIterator firstToken, TokenIterator lastTok macro.setName(tokenText(*tk)); ++tk; // skip T_IDENTIFIER - if (tk->is(T_LPAREN) && ! tk->whitespace) { + if (tk->is(T_LPAREN) && ! tk->f.whitespace) { // a function-like macro definition macro.setFunctionLike(true); |
