diff options
author | Reid Kleckner <rnk@google.com> | 2016-05-24 21:23:54 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2016-05-24 21:23:54 +0000 |
commit | 9a96e4207423804b7589ac958aae2bfbd41425df (patch) | |
tree | ccc7c25a46e0b2fe6662b636ba3219ed589afba5 /clang/lib/Parse/ParseDecl.cpp | |
parent | 3270bdbb038d51c98a059d0d517d0d4465ebb920 (diff) | |
download | bcm5719-llvm-9a96e4207423804b7589ac958aae2bfbd41425df.tar.gz bcm5719-llvm-9a96e4207423804b7589ac958aae2bfbd41425df.zip |
[ms] Allow more unqualified lookup of types in dependent base classes
Summary:
In dependent contexts where we know a type name is required, such as a
new expression, we can recover by forming a DependentNameType.
This generalizes our existing compatibility hack for default arguments
for template type parameters.
Works towards parsing atlctrlw.h, which is PR26748.
Reviewers: avt77, rsmith
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D20500
llvm-svn: 270615
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 8a3110c5153..746f996d368 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -2279,6 +2279,24 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS, return false; } + if (getLangOpts().CPlusPlus && (!SS || SS->isEmpty()) && + getLangOpts().MSVCCompat) { + // Lookup of an unqualified type name has failed in MSVC compatibility mode. + // Give Sema a chance to recover if we are in a template with dependent base + // classes. + if (ParsedType T = Actions.ActOnMSVCUnknownTypeName( + *Tok.getIdentifierInfo(), Tok.getLocation(), + DSC == DSC_template_type_arg)) { + const char *PrevSpec; + unsigned DiagID; + DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, DiagID, T, + Actions.getASTContext().getPrintingPolicy()); + DS.SetRangeEnd(Tok.getLocation()); + ConsumeToken(); + return false; + } + } + // Otherwise, if we don't consume this token, we are going to emit an // error anyway. Try to recover from various common problems. Check // to see if this was a reference to a tag name without a tag specified. @@ -2986,16 +3004,6 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, Actions.getTypeName(*Tok.getIdentifierInfo(), Tok.getLocation(), getCurScope()); - // MSVC: If we weren't able to parse a default template argument, and it's - // just a simple identifier, create a DependentNameType. This will allow - // us to defer the name lookup to template instantiation time, as long we - // forge a NestedNameSpecifier for the current context. - if (!TypeRep && DSContext == DSC_template_type_arg && - getLangOpts().MSVCCompat && getCurScope()->isTemplateParamScope()) { - TypeRep = Actions.ActOnDelayedDefaultTemplateArg( - *Tok.getIdentifierInfo(), Tok.getLocation()); - } - // If this is not a typedef name, don't parse it as part of the declspec, // it must be an implicit int or an error. if (!TypeRep) { |