summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-02-08 01:16:55 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-02-08 01:16:55 +0000
commit8f8697f3e185364129e35335e53e868761d35d1a (patch)
tree6cbf98f3ca0464a351b7b49e93bc2bdbf4185306 /clang/lib/Parse/ParseDecl.cpp
parentf283fdcd509686b4fbc089ae7020a8e9dbfbcb74 (diff)
downloadbcm5719-llvm-8f8697f3e185364129e35335e53e868761d35d1a.tar.gz
bcm5719-llvm-8f8697f3e185364129e35335e53e868761d35d1a.zip
Fix constructor declarator detection for the case when the name is followed by
an attribute-specifier-seq. (Also fixes the same problem for deduction-guides.) llvm-svn: 294396
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r--clang/lib/Parse/ParseDecl.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 9e8823fb4d1..d224a77d842 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -4675,6 +4675,10 @@ bool Parser::isConstructorDeclarator(bool IsUnqualified, bool DeductionGuide) {
return false;
}
+ // There may be attributes here, appertaining to the constructor name or type
+ // we just stepped past.
+ SkipCXX11Attributes();
+
// Current class name must be followed by a left parenthesis.
if (Tok.isNot(tok::l_paren)) {
TPA.Revert();
@@ -4742,18 +4746,24 @@ bool Parser::isConstructorDeclarator(bool IsUnqualified, bool DeductionGuide) {
case tok::r_paren:
// C(X )
+
+ // Skip past the right-paren and any following attributes to get to
+ // the function body or trailing-return-type.
+ ConsumeParen();
+ SkipCXX11Attributes();
+
if (DeductionGuide) {
// C(X) -> ... is a deduction guide.
- IsConstructor = NextToken().is(tok::arrow);
+ IsConstructor = Tok.is(tok::arrow);
break;
}
- if (NextToken().is(tok::colon) || NextToken().is(tok::kw_try)) {
+ if (Tok.is(tok::colon) || Tok.is(tok::kw_try)) {
// Assume these were meant to be constructors:
// C(X) : (the name of a bit-field cannot be parenthesized).
// C(X) try (this is otherwise ill-formed).
IsConstructor = true;
}
- if (NextToken().is(tok::semi) || NextToken().is(tok::l_brace)) {
+ if (Tok.is(tok::semi) || Tok.is(tok::l_brace)) {
// If we have a constructor name within the class definition,
// assume these were meant to be constructors:
// C(X) {
OpenPOWER on IntegriCloud