aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty
diff options
context:
space:
mode:
authorChristian Kamm <kamm@incasoftware.de>2012-09-18 12:57:51 +0200
committerhjk <qthjk@ovi.com>2012-09-19 11:58:34 +0200
commit392c80c6e4b3e0112d4fca50ee3351a6345db3fa (patch)
treedaa2db1fb4d72efffa04d2f00fcdde021f6c282d /src/libs/3rdparty
parent44c9cef30a022125e8ebc70b7b58c5ad25fafcd6 (diff)
C++11: Fix use of >> in template arguments.
Change-Id: Ic99ca897e7a3b9c82cf8c5093a90bf9c88dbb0ed Reviewed-by: hjk <qthjk@ovi.com>
Diffstat (limited to 'src/libs/3rdparty')
-rw-r--r--src/libs/3rdparty/cplusplus/Parser.cpp23
-rw-r--r--src/libs/3rdparty/cplusplus/Parser.h3
-rw-r--r--src/libs/3rdparty/cplusplus/TranslationUnit.cpp28
-rw-r--r--src/libs/3rdparty/cplusplus/TranslationUnit.h2
4 files changed, 46 insertions, 10 deletions
diff --git a/src/libs/3rdparty/cplusplus/Parser.cpp b/src/libs/3rdparty/cplusplus/Parser.cpp
index 64723254700..591d227b47d 100644
--- a/src/libs/3rdparty/cplusplus/Parser.cpp
+++ b/src/libs/3rdparty/cplusplus/Parser.cpp
@@ -107,7 +107,7 @@ inline int precedence(int tokenKind, bool templateArguments)
{
// ### this will/might need some tuning for C++0x
// (see: [temp.names]p3)
- if (templateArguments && tokenKind == T_GREATER)
+ if (templateArguments && (tokenKind == T_GREATER || tokenKind == T_GREATER_GREATER))
return -1;
if (lookAtAssignmentOperator(tokenKind))
@@ -212,6 +212,11 @@ bool Parser::switchTemplateArguments(bool templateArguments)
return previousTemplateArguments;
}
+bool Parser::maybeSplitGreaterGreaterToken(int n)
+{
+ return _translationUnit->maybeSplitGreaterGreaterToken(_tokenIndex + n - 1);
+}
+
bool Parser::blockErrors(bool block)
{ return _translationUnit->blockErrors(block); }
@@ -433,9 +438,9 @@ bool Parser::parseTemplateId(NameAST *&node, unsigned template_token)
ast->template_token = template_token;
ast->identifier_token = consumeToken();
ast->less_token = consumeToken();
- if (LA() == T_GREATER || parseTemplateArgumentList(
+ if (maybeSplitGreaterGreaterToken() || LA() == T_GREATER || parseTemplateArgumentList(
ast->template_argument_list)) {
- if (LA() == T_GREATER) {
+ if (maybeSplitGreaterGreaterToken() || LA() == T_GREATER) {
ast->greater_token = consumeToken();
node = ast;
return true;
@@ -1103,7 +1108,7 @@ bool Parser::parseTemplateDeclaration(DeclarationAST *&node)
if (LA() == T_LESS) {
ast->less_token = consumeToken();
- if (LA() == T_GREATER || parseTemplateParameterList(ast->template_parameter_list))
+ if (maybeSplitGreaterGreaterToken() || LA() == T_GREATER || parseTemplateParameterList(ast->template_parameter_list))
match(T_GREATER, &ast->greater_token);
}
@@ -1318,7 +1323,7 @@ bool Parser::parseTemplateArgument(ExpressionAST *&node)
if (_cxx0xEnabled && LA() == T_DOT_DOT_DOT)
index = 2;
- if (LA(index) == T_COMMA || LA(index) == T_GREATER)
+ if (LA(index) == T_COMMA || maybeSplitGreaterGreaterToken(index) || LA(index) == T_GREATER)
return true;
}
@@ -1796,7 +1801,7 @@ bool Parser::parseTemplateTypeParameter(DeclarationAST *&node)
if (LA() == T_LESS)
ast->less_token = consumeToken();
parseTemplateParameterList(ast->template_parameter_list);
- if (LA() == T_GREATER)
+ if (maybeSplitGreaterGreaterToken() || LA() == T_GREATER)
ast->greater_token = consumeToken();
if (LA() == T_CLASS)
ast->class_token = consumeToken();
@@ -1816,7 +1821,7 @@ bool Parser::parseTemplateTypeParameter(DeclarationAST *&node)
return false;
}
-bool Parser::lookAtTypeParameter() const
+bool Parser::lookAtTypeParameter()
{
if (LA() == T_CLASS || LA() == T_TYPENAME) {
if (LA(2) == T_IDENTIFIER) {
@@ -1827,7 +1832,7 @@ bool Parser::lookAtTypeParameter() const
return true;
default:
- return false;
+ return maybeSplitGreaterGreaterToken(3);
}
} else if (LA(2) == T_COLON_COLON) {
// found something like template <typename ::foo::bar>...
@@ -2947,7 +2952,7 @@ bool Parser::parseUnqualifiedName(NameAST *&node, bool acceptTemplateId)
if (acceptTemplateId && LA(2) == T_LESS) {
bool blocked = blockErrors(true);
if (parseTemplateId(node)
- && (! _templateArguments || (LA() == T_COMMA || LA() == T_GREATER ||
+ && (! _templateArguments || (LA() == T_COMMA || maybeSplitGreaterGreaterToken() || LA() == T_GREATER ||
LA() == T_LPAREN || LA() == T_RPAREN ||
LA() == T_STAR || LA() == T_AMPER || // ptr-operators
LA() == T_COLON_COLON))) {
diff --git a/src/libs/3rdparty/cplusplus/Parser.h b/src/libs/3rdparty/cplusplus/Parser.h
index cb0c7803c53..472ad412a2e 100644
--- a/src/libs/3rdparty/cplusplus/Parser.h
+++ b/src/libs/3rdparty/cplusplus/Parser.h
@@ -259,7 +259,7 @@ public:
bool skip(int l, int r);
int find(int token, int stopAt);
- bool lookAtTypeParameter() const;
+ bool lookAtTypeParameter();
bool lookAtCVQualifier() const;
bool lookAtFunctionSpecifier() const;
bool lookAtStorageClassSpecifier() const;
@@ -277,6 +277,7 @@ public:
int peekAtQtContextKeyword() const;
bool switchTemplateArguments(bool templateArguments);
+ bool maybeSplitGreaterGreaterToken(int n = 1);
bool blockErrors(bool block);
void warning(unsigned index, const char *format, ...);
diff --git a/src/libs/3rdparty/cplusplus/TranslationUnit.cpp b/src/libs/3rdparty/cplusplus/TranslationUnit.cpp
index a26a23eabce..7afef149ef1 100644
--- a/src/libs/3rdparty/cplusplus/TranslationUnit.cpp
+++ b/src/libs/3rdparty/cplusplus/TranslationUnit.cpp
@@ -552,6 +552,34 @@ unsigned TranslationUnit::findPreviousLineOffset(unsigned tokenIndex) const
return lineOffset;
}
+bool TranslationUnit::maybeSplitGreaterGreaterToken(unsigned tokenIndex)
+{
+ Token &tok = _tokens->at(tokenIndex);
+ if (tok.kind() != T_GREATER_GREATER)
+ return false;
+
+ tok.f.kind = T_GREATER;
+ tok.f.length = 1;
+
+ Token newGreater;
+ newGreater.f.kind = T_GREATER;
+ newGreater.f.expanded = tok.f.expanded;
+ newGreater.f.generated = tok.f.generated;
+ newGreater.f.length = 1;
+ newGreater.offset = tok.offset + 1;
+
+ _tokens->insert(_tokens->begin() + tokenIndex + 1, newGreater);
+
+ std::map<unsigned, std::pair<unsigned, unsigned> >::const_iterator it =
+ _expandedLineColumn.find(tok.offset);
+ if (it != _expandedLineColumn.end()) {
+ const std::pair<unsigned, unsigned> newPosition(it->second.first, it->second.second + 1);
+ _expandedLineColumn.insert(std::make_pair(newGreater.offset, newPosition));
+ }
+
+ return true;
+}
+
void TranslationUnit::showErrorLine(unsigned index, unsigned column, FILE *out)
{
unsigned lineOffset = _lineOffsets[findLineNumber(_tokens->at(index).offset)];
diff --git a/src/libs/3rdparty/cplusplus/TranslationUnit.h b/src/libs/3rdparty/cplusplus/TranslationUnit.h
index 95832f43281..f6ac1959dbf 100644
--- a/src/libs/3rdparty/cplusplus/TranslationUnit.h
+++ b/src/libs/3rdparty/cplusplus/TranslationUnit.h
@@ -134,6 +134,8 @@ public:
unsigned findPreviousLineOffset(unsigned tokenIndex) const;
+ bool maybeSplitGreaterGreaterToken(unsigned tokenIndex);
+
public:
struct PPLine {
unsigned offset;