summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Parse/ParseDecl.cpp33
-rw-r--r--clang/lib/Parse/ParseExpr.cpp1
-rw-r--r--clang/lib/Sema/DeclSpec.cpp4
-rw-r--r--clang/lib/Sema/SemaDecl.cpp3
-rw-r--r--clang/lib/Sema/SemaType.cpp1
5 files changed, 39 insertions, 3 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index f4a79077a92..29f9921217d 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -3064,8 +3064,8 @@ void Parser::ParseParenDeclarator(Declarator &D) {
/// '=' assignment-expression
/// [GNU] declaration-specifiers abstract-declarator[opt] attributes
///
-/// For C++, after the parameter-list, it also parses "cv-qualifier-seq[opt]"
-/// and "exception-specification[opt]".
+/// For C++, after the parameter-list, it also parses "cv-qualifier-seq[opt]",
+/// C++0x "ref-qualifier[opt]" and "exception-specification[opt]".
///
void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
ParsedAttributes &attrs,
@@ -3085,6 +3085,8 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
// cv-qualifier-seq[opt].
DeclSpec DS;
+ SourceLocation RefQualifierLoc;
+ bool RefQualifierIsLValueRef = true;
bool hasExceptionSpec = false;
SourceLocation ThrowLoc;
bool hasAnyExceptionSpec = false;
@@ -3097,6 +3099,16 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
if (!DS.getSourceRange().getEnd().isInvalid())
EndLoc = DS.getSourceRange().getEnd();
+ // Parse ref-qualifier[opt]
+ if (Tok.is(tok::amp) || Tok.is(tok::ampamp)) {
+ if (!getLang().CPlusPlus0x)
+ Diag(Tok, diag::ext_rvalue_reference);
+
+ RefQualifierIsLValueRef = Tok.is(tok::amp);
+ RefQualifierLoc = ConsumeToken();
+ EndLoc = RefQualifierLoc;
+ }
+
// Parse exception-specification[opt].
if (Tok.is(tok::kw_throw)) {
hasExceptionSpec = true;
@@ -3121,6 +3133,8 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
SourceLocation(),
/*arglist*/ 0, 0,
DS.getTypeQualifiers(),
+ RefQualifierIsLValueRef,
+ RefQualifierLoc,
hasExceptionSpec, ThrowLoc,
hasAnyExceptionSpec,
Exceptions.data(),
@@ -3320,6 +3334,8 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
SourceLocation EndLoc = RParenLoc;
DeclSpec DS;
+ SourceLocation RefQualifierLoc;
+ bool RefQualifierIsLValueRef = true;
bool hasExceptionSpec = false;
SourceLocation ThrowLoc;
bool hasAnyExceptionSpec = false;
@@ -3334,6 +3350,16 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
if (!DS.getSourceRange().getEnd().isInvalid())
EndLoc = DS.getSourceRange().getEnd();
+ // Parse ref-qualifier[opt]
+ if (Tok.is(tok::amp) || Tok.is(tok::ampamp)) {
+ if (!getLang().CPlusPlus0x)
+ Diag(Tok, diag::ext_rvalue_reference);
+
+ RefQualifierIsLValueRef = Tok.is(tok::amp);
+ RefQualifierLoc = ConsumeToken();
+ EndLoc = RefQualifierLoc;
+ }
+
// Parse exception-specification[opt].
if (Tok.is(tok::kw_throw)) {
hasExceptionSpec = true;
@@ -3362,6 +3388,8 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
EllipsisLoc,
ParamInfo.data(), ParamInfo.size(),
DS.getTypeQualifiers(),
+ RefQualifierIsLValueRef,
+ RefQualifierLoc,
hasExceptionSpec, ThrowLoc,
hasAnyExceptionSpec,
Exceptions.data(),
@@ -3443,6 +3471,7 @@ void Parser::ParseFunctionDeclaratorIdentifierList(SourceLocation LParenLoc,
SourceLocation(),
&ParamInfo[0], ParamInfo.size(),
/*TypeQuals*/0,
+ true, SourceLocation(),
/*exception*/false,
SourceLocation(), false, 0, 0, 0,
LParenLoc, RLoc, D),
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index acbf3a5a927..67351f7e2fc 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1859,6 +1859,7 @@ ExprResult Parser::ParseBlockLiteralExpression() {
true, false,
SourceLocation(),
0, 0, 0,
+ true, SourceLocation(),
false, SourceLocation(),
false, 0, 0, 0,
CaretLoc, CaretLoc,
diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp
index 4152c5740a9..8a35ab70923 100644
--- a/clang/lib/Sema/DeclSpec.cpp
+++ b/clang/lib/Sema/DeclSpec.cpp
@@ -52,6 +52,8 @@ DeclaratorChunk DeclaratorChunk::getFunction(const ParsedAttributes &attrs,
ParamInfo *ArgInfo,
unsigned NumArgs,
unsigned TypeQuals,
+ bool RefQualifierIsLvalueRef,
+ SourceLocation RefQualifierLoc,
bool hasExceptionSpec,
SourceLocation ThrowLoc,
bool hasAnyExceptionSpec,
@@ -74,6 +76,8 @@ DeclaratorChunk DeclaratorChunk::getFunction(const ParsedAttributes &attrs,
I.Fun.TypeQuals = TypeQuals;
I.Fun.NumArgs = NumArgs;
I.Fun.ArgInfo = 0;
+ I.Fun.RefQualifierIsLValueRef = RefQualifierIsLvalueRef;
+ I.Fun.RefQualifierLoc = RefQualifierLoc.getRawEncoding();
I.Fun.hasExceptionSpec = hasExceptionSpec;
I.Fun.ThrowLoc = ThrowLoc.getRawEncoding();
I.Fun.hasAnyExceptionSpec = hasAnyExceptionSpec;
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 39d198be392..1c487b8113a 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -5539,7 +5539,8 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc,
Declarator D(DS, Declarator::BlockContext);
D.AddTypeInfo(DeclaratorChunk::getFunction(ParsedAttributes(),
false, false, SourceLocation(), 0,
- 0, 0, false, SourceLocation(),
+ 0, 0, true, SourceLocation(),
+ false, SourceLocation(),
false, 0,0,0, Loc, Loc, D),
SourceLocation());
D.SetIdentifier(&II, Loc);
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 8ca1e008238..b663f58f032 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -520,6 +520,7 @@ static void maybeSynthesizeBlockSignature(TypeProcessingState &state,
/*variadic*/ false, SourceLocation(),
/*args*/ 0, 0,
/*type quals*/ 0,
+ /*ref-qualifier*/true, SourceLocation(),
/*EH*/ false, SourceLocation(), false, 0, 0, 0,
/*parens*/ loc, loc,
declarator));
OpenPOWER on IntegriCloud