diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-08-06 09:47:24 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-08-06 09:47:24 +0000 |
commit | 2b602adf9798eaf13850efaf8ed41c69d3cf7da6 (patch) | |
tree | 67aa07cc6eda84e08dad6d8300fcdd9ea71d3f56 /lib/Parse/ParseDecl.cpp | |
parent | fcecd3cc07ad395e05db864bc21f7790f7878156 (diff) |
Introduce a new token kind 'cxx_defaultarg_end' to mark the end of C++ default arguments that were part of
lexed method declarations.
This avoid interference with tokens coming after the point where the default arg tokens were 'injected', e.g. for
typedef struct Inst {
void m(int x=0);
} *InstPtr;
when parsing '0' the next token would be '*' and things would be messed up.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110436 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 6f65640d60..65b4fb77ad 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -3085,9 +3085,17 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D, delete DefArgToks; DefArgToks = 0; Actions.ActOnParamDefaultArgumentError(Param); - } else + } else { + // Mark the end of the default argument so that we know when to + // stop when we parse it later on. + Token DefArgEnd; + DefArgEnd.startToken(); + DefArgEnd.setKind(tok::cxx_defaultarg_end); + DefArgEnd.setLocation(Tok.getLocation()); + DefArgToks->push_back(DefArgEnd); Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc, (*DefArgToks)[1].getLocation()); + } } else { // Consume the '='. ConsumeToken(); |