diff options
author | John McCall <rjmccall@apple.com> | 2010-04-13 06:39:49 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-04-13 06:39:49 +0000 |
commit | 84821e7143fc6175cf2036b9ca3d0ad6924820f8 (patch) | |
tree | 1cecd659ce94462726d24d3639d58f10798e9da6 /clang/lib/Parse/ParseDecl.cpp | |
parent | 069711865f8ad206e76ce7f32994aee553083992 (diff) | |
download | bcm5719-llvm-84821e7143fc6175cf2036b9ca3d0ad6924820f8.tar.gz bcm5719-llvm-84821e7143fc6175cf2036b9ca3d0ad6924820f8.zip |
Parse constructor names in friend declarations. Part of the fix for
PR6207.
llvm-svn: 101119
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index da4a0028447..09ae231c5e7 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -904,7 +904,9 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, // reinforced by the NAD status of core issue 635. TemplateIdAnnotation *TemplateId = static_cast<TemplateIdAnnotation *>(Next.getAnnotationValue()); - if (DSContext == DSC_top_level && TemplateId->Name && + if ((DSContext == DSC_top_level || + (DSContext == DSC_class && DS.isFriendSpecified())) && + TemplateId->Name && Actions.isCurrentClassName(*TemplateId->Name, CurScope, &SS)) { if (isConstructorDeclarator()) { // The user meant this to be an out-of-line constructor @@ -949,7 +951,8 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, // If we're in a context where the identifier could be a class name, // check whether this is a constructor declaration. - if (DSContext == DSC_top_level && + if ((DSContext == DSC_top_level || + (DSContext == DSC_class && DS.isFriendSpecified())) && Actions.isCurrentClassName(*Next.getIdentifierInfo(), CurScope, &SS)) { if (isConstructorDeclarator()) @@ -2599,12 +2602,17 @@ void Parser::ParseDirectDeclarator(Declarator &D) { Tok.is(tok::annot_template_id) || Tok.is(tok::tilde)) { // We found something that indicates the start of an unqualified-id. // Parse that unqualified-id. - bool AllowConstructorName - = ((D.getCXXScopeSpec().isSet() && - D.getContext() == Declarator::FileContext) || - (!D.getCXXScopeSpec().isSet() && - D.getContext() == Declarator::MemberContext)) && - !D.getDeclSpec().hasTypeSpecifier(); + bool AllowConstructorName; + if (D.getDeclSpec().hasTypeSpecifier()) + AllowConstructorName = false; + else if (D.getCXXScopeSpec().isSet()) + AllowConstructorName = + (D.getContext() == Declarator::FileContext || + (D.getContext() == Declarator::MemberContext && + D.getDeclSpec().isFriendSpecified())); + else + AllowConstructorName = (D.getContext() == Declarator::MemberContext); + if (ParseUnqualifiedId(D.getCXXScopeSpec(), /*EnteringContext=*/true, /*AllowDestructorName=*/true, |