diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-03-23 00:00:23 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-03-23 00:00:23 +0000 |
commit | 743de1f671ee0ef213c7404cfdc85579dd12c56e (patch) | |
tree | 79310cea41ee23c8e69b42c357b1b7cf3c75f8cb /lib/Parse/ParseDecl.cpp | |
parent | f05c05d2e1a2952e6cc7c3e54366fb8d99ff579c (diff) |
Recognize rvalue references in C++03, but complain about them. This leads to far better error recovery.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67495 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 0dddfdff79..6d2aad6905 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -1660,7 +1660,8 @@ void Parser::ParseDeclaratorInternal(Declarator &D, tok::TokenKind Kind = Tok.getKind(); // Not a pointer, C++ reference, or block. if (Kind != tok::star && (Kind != tok::amp || !getLang().CPlusPlus) && - (Kind != tok::ampamp || !getLang().CPlusPlus0x) && + // We parse rvalue refs in C++03, because otherwise the errors are scary. + (Kind != tok::ampamp || !getLang().CPlusPlus) && (Kind != tok::caret || !getLang().Blocks)) { if (DirectDeclParser) (this->*DirectDeclParser)(D); @@ -1669,7 +1670,7 @@ void Parser::ParseDeclaratorInternal(Declarator &D, // Otherwise, '*' -> pointer, '^' -> block, '&' -> lvalue reference, // '&&' -> rvalue reference - SourceLocation Loc = ConsumeToken(); // Eat the *, ^ or &. + SourceLocation Loc = ConsumeToken(); // Eat the *, ^, & or &&. D.SetRangeEnd(Loc); if (Kind == tok::star || (Kind == tok::caret && getLang().Blocks)) { @@ -1695,6 +1696,11 @@ void Parser::ParseDeclaratorInternal(Declarator &D, // Is a reference DeclSpec DS; + // Complain about rvalue references in C++03, but then go on and build + // the declarator. + if (Kind == tok::ampamp && !getLang().CPlusPlus0x) + Diag(Loc, diag::err_rvalue_reference); + // C++ 8.3.2p1: cv-qualified references are ill-formed except when the // cv-qualifiers are introduced through the use of a typedef or of a // template type argument, in which case the cv-qualifiers are ignored. |