summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-06-06 22:36:36 +0000
committerReid Kleckner <reid@kleckner.net>2014-06-06 22:36:36 +0000
commitdf6e4a06e42b8282220a73e6299b30ff2ec329ed (patch)
tree1384aa1336da74d0c26d9a12c19d3f4da9acf480 /clang/lib/Parse/ParseDecl.cpp
parent57e06dfb4123b2dc2b3483931f8319cc35bb44b3 (diff)
downloadbcm5719-llvm-df6e4a06e42b8282220a73e6299b30ff2ec329ed.tar.gz
bcm5719-llvm-df6e4a06e42b8282220a73e6299b30ff2ec329ed.zip
Delay lookup of simple default template arguments under -fms-compatibility
MSVC delays parsing of default arguments until instantiation. If the default argument is never used, it is never parsed. We don't model this. Instead, if lookup of a type name fails in a template argument context, we form a DependentNameType, which will be looked up at instantiation time. This fixes errors about 'CControlWinTraits' in atlwin.h. Reviewers: rsmith Differential Revision: http://reviews.llvm.org/D3995 llvm-svn: 210382
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r--clang/lib/Parse/ParseDecl.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 65ec44c5775..92a13659ea3 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -2227,6 +2227,8 @@ Parser::getDeclSpecContextFromDeclaratorContext(unsigned Context) {
return DSC_class;
if (Context == Declarator::FileContext)
return DSC_top_level;
+ if (Context == Declarator::TemplateTypeArgContext)
+ return DSC_template_type_arg;
if (Context == Declarator::TrailingReturnContext)
return DSC_trailing;
if (Context == Declarator::AliasDeclContext ||
@@ -2753,6 +2755,16 @@ 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) {
OpenPOWER on IntegriCloud