This repository was archived by the owner on Nov 1, 2021. It is now read-only.
File tree 2 files changed +19
-2
lines changed
2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -9239,10 +9239,18 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
9239
9239
return (Decl*) nullptr ;
9240
9240
}
9241
9241
9242
- Specialization->setTemplateSpecializationKind (TSK, D.getIdentifierLoc ());
9243
9242
if (Attr)
9244
9243
ProcessDeclAttributeList (S, Specialization, Attr);
9245
9244
9245
+ // In MSVC mode, dllimported explicit instantiation definitions are treated as
9246
+ // instantiation declarations.
9247
+ if (TSK == TSK_ExplicitInstantiationDefinition &&
9248
+ Specialization->hasAttr <DLLImportAttr>() &&
9249
+ Context.getTargetInfo ().getCXXABI ().isMicrosoft ())
9250
+ TSK = TSK_ExplicitInstantiationDeclaration;
9251
+
9252
+ Specialization->setTemplateSpecializationKind (TSK, D.getIdentifierLoc ());
9253
+
9246
9254
if (Specialization->isDefined ()) {
9247
9255
// Let the ASTConsumer know that this function has been explicitly
9248
9256
// instantiated now, and its linkage might have changed.
Original file line number Diff line number Diff line change @@ -579,7 +579,7 @@ USE(inlineFuncTmpl<ExplicitDecl_Imported>)
579
579
// MSC-DAG: declare dllimport void @"\01??$inlineFuncTmpl@UExplicitInst_Imported@@@@YAXXZ"()
580
580
// GNU-DAG: declare dllimport void @_Z8funcTmplI21ExplicitInst_ImportedEvv()
581
581
// GNU-DAG: define weak_odr void @_Z14inlineFuncTmplI21ExplicitInst_ImportedEvv()
582
- // MO1-DAG: define available_externally dllimport void @"\01??$funcTmpl@UExplicitInst_Imported@@@@YAXXZ"()
582
+ // MO1-DAG: declare dllimport void @"\01??$funcTmpl@UExplicitInst_Imported@@@@YAXXZ"()
583
583
// MO1-DAG: define available_externally dllimport void @"\01??$inlineFuncTmpl@UExplicitInst_Imported@@@@YAXXZ"()
584
584
// GO1-DAG: define available_externally dllimport void @_Z8funcTmplI21ExplicitInst_ImportedEvv()
585
585
// GO1-DAG: define weak_odr void @_Z14inlineFuncTmplI21ExplicitInst_ImportedEvv()
@@ -609,6 +609,15 @@ USE(funcTmpl<ExplicitSpec_Imported>)
609
609
template <> __declspec (dllimport) inline void funcTmpl<ExplicitSpec_InlineDef_Imported>() {}
610
610
USE (funcTmpl<ExplicitSpec_InlineDef_Imported>)
611
611
612
+ #ifdef MSABI
613
+ namespace pr35435 {
614
+ struct X ;
615
+ template <typename T> struct __declspec (dllimport) S {
616
+ void foo (T *t) { t->problem (); }
617
+ };
618
+ template void S<X>::foo(X*); // Cannot be instantiated because X is incomplete; dllimport means it's treated as an instantiation decl.
619
+ }
620
+ #endif
612
621
613
622
614
623
// ===----------------------------------------------------------------------===//
You can’t perform that action at this time.
0 commit comments