forked from OSchip/llvm-project
Permit duplicate explicit class instantiations if MSVCCompat is enabled
llvm-svn: 208402
This commit is contained in:
parent
77c456be3e
commit
eadcdbbe57
|
@ -3396,6 +3396,9 @@ def err_nested_name_spec_non_tag : Error<
|
|||
// C++ Explicit Instantiation
|
||||
def err_explicit_instantiation_duplicate : Error<
|
||||
"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<
|
||||
"previous explicit instantiation is here">;
|
||||
def ext_explicit_instantiation_after_specialization : Extension<
|
||||
|
|
|
@ -6526,8 +6526,12 @@ Sema::CheckSpecializationInstantiationRedecl(SourceLocation NewLoc,
|
|||
// For a given template and a given set of template-arguments,
|
||||
// - an explicit instantiation definition shall appear at most once
|
||||
// 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::note_previous_explicit_instantiation);
|
||||
HasNoEffect = true;
|
||||
|
|
|
@ -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}}
|
Loading…
Reference in New Issue