From abcfa61f513e499fe3f2f44df9cb48e133fc4fc0 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Sat, 14 Sep 2013 05:46:42 +0000 Subject: [PATCH] Parse: Template specializations which aren't dependent needn't have their parsing be delayed Summary: We should treat a non-dependent template specialization like it wasn't templated at all. Reviewers: rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1554 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190743 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Parse/ParseCXXInlineMethods.cpp | 9 +++++---- test/CodeGenCXX/delayed-template-parsing.cpp | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 test/CodeGenCXX/delayed-template-parsing.cpp diff --git a/lib/Parse/ParseCXXInlineMethods.cpp b/lib/Parse/ParseCXXInlineMethods.cpp index 725d69f77b..8d82d03d83 100644 --- a/lib/Parse/ParseCXXInlineMethods.cpp +++ b/lib/Parse/ParseCXXInlineMethods.cpp @@ -113,11 +113,12 @@ NamedDecl *Parser::ParseCXXInlineMethodDef(AccessSpecifier AS, // In delayed template parsing mode, if we are within a class template // or if we are about to parse function member template then consume // the tokens and store them for parsing at the end of the translation unit. - if (getLangOpts().DelayedTemplateParsing && - DefinitionKind == FDK_Definition && + if (getLangOpts().DelayedTemplateParsing && + DefinitionKind == FDK_Definition && ((Actions.CurContext->isDependentContext() || - TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate) && - !Actions.IsInsideALocalClassWithinATemplateFunction())) { + (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate && + TemplateInfo.Kind != ParsedTemplateInfo::ExplicitSpecialization)) && + !Actions.IsInsideALocalClassWithinATemplateFunction())) { CachedTokens Toks; LexTemplateFunctionForLateParsing(Toks); diff --git a/test/CodeGenCXX/delayed-template-parsing.cpp b/test/CodeGenCXX/delayed-template-parsing.cpp new file mode 100644 index 0000000000..fa177d4562 --- /dev/null +++ b/test/CodeGenCXX/delayed-template-parsing.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -cxx-abi microsoft -fms-extensions -fdelayed-template-parsing -triple=i386-pc-win32 | FileCheck %s +// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -cxx-abi microsoft -fms-extensions -fdelayed-template-parsing -triple=x86_64-pc-win32 | FileCheck -check-prefix X64 %s + +namespace ClassScopeSpecialization { + struct Type { + template + void Foo() {} + template <> + void Foo<0>() {} + }; + + void call() { + Type T; +// CHECK: call {{.*}} @"\01??$Foo@$0A@@Type@ClassScopeSpecialization@@QAEXXZ" +// X64: call {{.*}} @"\01??$Foo@$0A@@Type@ClassScopeSpecialization@@QEAAXXZ" + T.Foo<0>(); + } +} -- 2.40.0