Permit duplicate explicit class instantiations if MSVCCompat is enabled

llvm-svn: 208402
This commit is contained in:
Will Wilson 2014-05-09 09:52:13 +00:00
parent 77c456be3e
commit eadcdbbe57
3 changed files with 18 additions and 2 deletions

View File

@ -3396,6 +3396,9 @@ def err_nested_name_spec_non_tag : Error<
// C++ Explicit Instantiation // C++ Explicit Instantiation
def err_explicit_instantiation_duplicate : Error< def err_explicit_instantiation_duplicate : Error<
"duplicate explicit instantiation of %0">; "duplicate explicit instantiation of %0">;
def warn_explicit_instantiation_duplicate : ExtWarn<
"duplicate explicit instantiation of %0 ignored as a Microsoft extension">,
InGroup<Microsoft>;
def note_previous_explicit_instantiation : Note< def note_previous_explicit_instantiation : Note<
"previous explicit instantiation is here">; "previous explicit instantiation is here">;
def ext_explicit_instantiation_after_specialization : Extension< def ext_explicit_instantiation_after_specialization : Extension<

View File

@ -6526,8 +6526,12 @@ Sema::CheckSpecializationInstantiationRedecl(SourceLocation NewLoc,
// For a given template and a given set of template-arguments, // For a given template and a given set of template-arguments,
// - an explicit instantiation definition shall appear at most once // - an explicit instantiation definition shall appear at most once
// in a program, // in a program,
Diag(NewLoc, diag::err_explicit_instantiation_duplicate)
<< PrevDecl; // MSVCCompat: MSVC silently ignores duplicate explicit instantiations.
Diag(NewLoc, (getLangOpts().MSVCCompat)
? diag::warn_explicit_instantiation_duplicate
: diag::err_explicit_instantiation_duplicate)
<< PrevDecl;
Diag(DiagLocForExplicitInstantiation(PrevDecl, PrevPointOfInstantiation), Diag(DiagLocForExplicitInstantiation(PrevDecl, PrevPointOfInstantiation),
diag::note_previous_explicit_instantiation); diag::note_previous_explicit_instantiation);
HasNoEffect = true; HasNoEffect = true;

View File

@ -0,0 +1,9 @@
// RUN: %clang_cc1 -fms-compatibility -fdelayed-template-parsing -fsyntax-only -verify %s
template <typename T>
class A {
};
typedef int TInt;
template class A<int>; // expected-note {{previous explicit instantiation is here}}
template class A<TInt>; // expected-warning {{duplicate explicit instantiation of 'A<int>' ignored as a Microsoft extension}}