diff options
author | John McCall <rjmccall@apple.com> | 2012-05-07 06:16:58 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2012-05-07 06:16:58 +0000 |
commit | 6347b68fd95ba302d095078a39a2a3e371c708d3 (patch) | |
tree | d0bebad522eb1a997b1a8efdb79844ec1d3f1265 /clang/lib/Parse/ParseDeclCXX.cpp | |
parent | 42f8db9070a48515604d7026e5484c939184f334 (diff) | |
download | bcm5719-llvm-6347b68fd95ba302d095078a39a2a3e371c708d3.tar.gz bcm5719-llvm-6347b68fd95ba302d095078a39a2a3e371c708d3.zip |
Change how we suppress access control in explicit instantiations
so that we actually accumulate all the delayed diagnostics. Do
this so that we can restore those diagnostics to good standing
if it turns out that we were wrong to suppress, e.g. if the
tag specifier is actually an elaborated type specifier and not
a declaration.
llvm-svn: 156291
Diffstat (limited to 'clang/lib/Parse/ParseDeclCXX.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 2a641413536..730c345d807 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -968,9 +968,13 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, // As an extension we do not perform access checking on the names used to // specify explicit specializations either. This is important to allow // specializing traits classes for private types. - Sema::SuppressAccessChecksRAII SuppressAccess(Actions, - TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation || - TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization); + // + // Note that we don't suppress if this turns out to be an elaborated + // type specifier. + bool shouldDelayDiagsInTag = + (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation || + TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization); + SuppressAccessChecks diagsFromTag(*this, shouldDelayDiagsInTag); ParsedAttributes attrs(AttrFactory); // If attributes exist after tag, parse them. @@ -1103,10 +1107,6 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, } } - // As soon as we're finished parsing the class's template-id, turn access - // checking back on. - SuppressAccess.done(); - // There are four options here. // - If we are in a trailing return type, this is always just a reference, // and we must not try to parse a definition. For instance, @@ -1149,6 +1149,14 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, else TUK = Sema::TUK_Reference; + // If this is an elaborated type specifier, and we delayed + // diagnostics before, just merge them into the current pool. + if (shouldDelayDiagsInTag) { + diagsFromTag.done(); + if (TUK == Sema::TUK_Reference) + diagsFromTag.redelay(); + } + if (!Name && !TemplateId && (DS.getTypeSpecType() == DeclSpec::TST_error || TUK != Sema::TUK_Definition)) { if (DS.getTypeSpecType() != DeclSpec::TST_error) { |