diff options
author | John McCall <rjmccall@apple.com> | 2009-12-11 02:10:03 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2009-12-11 02:10:03 +0000 |
commit | a009726ce3a05bf7412c7f6beefeda3c12788432 (patch) | |
tree | d2cdae55454f784f8e3403d70ac4ba4960ef2662 /clang/lib/Parse/ParseDeclCXX.cpp | |
parent | 56caf31afb5ffed870a2b970a87291019f1aeb24 (diff) | |
download | bcm5719-llvm-a009726ce3a05bf7412c7f6beefeda3c12788432.tar.gz bcm5719-llvm-a009726ce3a05bf7412c7f6beefeda3c12788432.zip |
Implement access declarations. Most of the work here is parsing them, which
is difficult because they're so terribly, terribly ambiguous.
We implement access declarations in terms of using declarations, which is
quite reasonable. However, we should really persist the access/using
distinction in the AST and use the appropriate name in diagnostics. This
isn't a priority, so I'll just file a PR and hope someone else does it. :)
llvm-svn: 91095
Diffstat (limited to 'clang/lib/Parse/ParseDeclCXX.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 34ea9c7d9b0..78336bbfb15 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -357,7 +357,7 @@ Parser::DeclPtrTy Parser::ParseUsingDeclaration(unsigned Context, AttrList ? "attributes list" : "using declaration", tok::semi); - return Actions.ActOnUsingDeclaration(CurScope, AS, UsingLoc, SS, Name, + return Actions.ActOnUsingDeclaration(CurScope, AS, true, UsingLoc, SS, Name, AttrList, IsTypeName, TypenameLoc); } @@ -1065,6 +1065,46 @@ void Parser::HandleMemberFunctionDefaultArgs(Declarator& DeclaratorInfo, /// void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, const ParsedTemplateInfo &TemplateInfo) { + // Access declarations. + if (!TemplateInfo.Kind && + (Tok.is(tok::identifier) || Tok.is(tok::coloncolon)) && + TryAnnotateCXXScopeToken() && + Tok.is(tok::annot_cxxscope)) { + bool isAccessDecl = false; + if (NextToken().is(tok::identifier)) + isAccessDecl = GetLookAheadToken(2).is(tok::semi); + else + isAccessDecl = NextToken().is(tok::kw_operator); + + if (isAccessDecl) { + // Collect the scope specifier token we annotated earlier. + CXXScopeSpec SS; + ParseOptionalCXXScopeSpecifier(SS, /*ObjectType*/ 0, false); + + // Try to parse an unqualified-id. + UnqualifiedId Name; + if (ParseUnqualifiedId(SS, false, true, true, /*ObjectType*/ 0, Name)) { + SkipUntil(tok::semi); + return; + } + + // TODO: recover from mistakenly-qualified operator declarations. + if (ExpectAndConsume(tok::semi, + diag::err_expected_semi_after, + "access declaration", + tok::semi)) + return; + + Actions.ActOnUsingDeclaration(CurScope, AS, + false, SourceLocation(), + SS, Name, + /* AttrList */ 0, + /* IsTypeName */ false, + SourceLocation()); + return; + } + } + // static_assert-declaration if (Tok.is(tok::kw_static_assert)) { // FIXME: Check for templates |