aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseTemplate.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-02-25 23:02:36 +0000
committerDouglas Gregor <dgregor@apple.com>2009-02-25 23:02:36 +0000
commit3965b7be250de002d8744331631b9901941666a0 (patch)
treebb44455ae531d916159cbd3bc5f40d513cdaa589 /lib/Parse/ParseTemplate.cpp
parentce87b929703cac0b3f236b0b0d1c7b78d8af38f2 (diff)
Cope with use of the token '>>' inside a template argument list, e.g.,
vector<vector<double>> Matrix; In C++98/03, this token always means "right shift". However, if we're in a context where we know that it can't mean "right shift", provide a friendly reminder to put a space between the two >'s and then treat it as two >'s as part of recovery. In C++0x, this token is always broken into two '>' tokens. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65484 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseTemplate.cpp')
-rw-r--r--lib/Parse/ParseTemplate.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp
index 64fc8fdf47..65705e8d32 100644
--- a/lib/Parse/ParseTemplate.cpp
+++ b/lib/Parse/ParseTemplate.cpp
@@ -431,14 +431,24 @@ Parser::ParseTemplateIdAfterTemplateName(DeclTy *Template,
}
}
- if (Tok.isNot(tok::greater))
+ if (Tok.isNot(tok::greater) && Tok.isNot(tok::greatergreater))
return true;
- // Determine the location of the '>'. Only consume this token if the
- // caller asked us to.
+ // Determine the location of the '>' or '>>'. Only consume this
+ // token if the caller asked us to.
RAngleLoc = Tok.getLocation();
- if (ConsumeLastToken)
+ if (Tok.is(tok::greatergreater)) {
+ if (!getLang().CPlusPlus0x)
+ Diag(Tok.getLocation(), diag::err_two_right_angle_brackets_need_space);
+
+ Tok.setKind(tok::greater);
+ if (!ConsumeLastToken) {
+ // Since we're not supposed to consume the '>>' token, we need
+ // to insert a second '>' token after the first.
+ PP.EnterToken(Tok);
+ }
+ } else if (ConsumeLastToken)
ConsumeToken();
return false;
@@ -670,6 +680,6 @@ Parser::ParseTemplateArgumentList(TemplateArgList &TemplateArgs,
ConsumeToken();
}
- return Tok.isNot(tok::greater);
+ return Tok.isNot(tok::greater) && Tok.isNot(tok::greatergreater);
}