diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-11-07 20:56:01 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-11-07 20:56:01 +0000 |
commit | 45fa560c72441069d9e4eb1e66efd87349caa552 (patch) | |
tree | f86ce87dabd0fe05e6e06c4edc5312652ab48d09 /lib/Parse/ParseDeclCXX.cpp | |
parent | cf6ba2eeaeabb03541ee98859805800c39759a47 (diff) |
When we notice that a member function is defined with "= delete" or "=
default", make a note of which is used when creating the
initial declaration. Previously, we would wait until later to handle
default/delete as a definition, but this is too late: when adding the
declaration, we already treated the declaration as "user-provided"
when in fact it was merely "user-declared".
Fixes PR10861 and PR10442, along with a bunch of FIXMEs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144011 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDeclCXX.cpp')
-rw-r--r-- | lib/Parse/ParseDeclCXX.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 721d185f53..04c94a053d 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -1779,25 +1779,27 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, HasInitializer = true; } - bool IsDefinition = false; + FunctionDefinitionKind DefinitionKind = FDK_Declaration; // function-definition: // // In C++11, a non-function declarator followed by an open brace is a // braced-init-list for an in-class member initialization, not an // erroneous function definition. if (Tok.is(tok::l_brace) && !getLang().CPlusPlus0x) { - IsDefinition = true; + DefinitionKind = FDK_Definition; } else if (DeclaratorInfo.isFunctionDeclarator()) { if (Tok.is(tok::l_brace) || Tok.is(tok::colon) || Tok.is(tok::kw_try)) { - IsDefinition = true; + DefinitionKind = FDK_Definition; } else if (Tok.is(tok::equal)) { const Token &KW = NextToken(); - if (KW.is(tok::kw_default) || KW.is(tok::kw_delete)) - IsDefinition = true; + if (KW.is(tok::kw_default)) + DefinitionKind = FDK_Defaulted; + else if (KW.is(tok::kw_delete)) + DefinitionKind = FDK_Deleted; } } - if (IsDefinition) { + if (DefinitionKind) { if (!DeclaratorInfo.isFunctionDeclarator()) { Diag(Tok, diag::err_func_def_no_params); ConsumeBrace(); @@ -1825,7 +1827,7 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, Decl *FunDecl = ParseCXXInlineMethodDef(AS, AccessAttrs, DeclaratorInfo, TemplateInfo, - VS, Init); + VS, DefinitionKind, Init); for (unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i) { LateParsedAttrs[i]->setDecl(FunDecl); |