diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-05-11 17:39:34 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-05-11 17:39:34 +0000 |
commit | 2166beba8d939d2938c5401af2c8d3687afd5d8c (patch) | |
tree | 705463c93c0c35b62eec8cf8b747a5897fe0847e /lib/Sema/SemaTemplate.cpp | |
parent | 85bcd9920582f4d3879d8fbbaf4ca4fe09690160 (diff) |
The C++98/03 standard is disturbingly silent about out-of-scope
explicit instantiations of template. C++0x clarifies the intent
(they're ill-formed in some cases; see [temp.explicit] for
details). However, one could squint at the C++98/03 standard and
conclude they are permitted, so reduce the error to a warning
(controlled by -Wc++0x-compat) in C++98/03 mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103482 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplate.cpp')
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 4689a53bdf..d660d6a4c9 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -4544,10 +4544,16 @@ static void CheckExplicitInstantiationScope(Sema &S, NamedDecl *D, if (S.getLangOptions().CPlusPlus0x && !CurContext->Encloses(ExpectedContext)) { if (NamespaceDecl *NS = dyn_cast<NamespaceDecl>(ExpectedContext)) - S.Diag(InstLoc, diag::err_explicit_instantiation_out_of_scope) + S.Diag(InstLoc, + S.getLangOptions().CPlusPlus0x? + diag::err_explicit_instantiation_out_of_scope + : diag::warn_explicit_instantiation_out_of_scope_0x) << D << NS; else - S.Diag(InstLoc, diag::err_explicit_instantiation_must_be_global) + S.Diag(InstLoc, + S.getLangOptions().CPlusPlus0x? + diag::err_explicit_instantiation_must_be_global + : diag::warn_explicit_instantiation_out_of_scope_0x) << D; S.Diag(D->getLocation(), diag::note_explicit_instantiation_here); return; @@ -4564,7 +4570,10 @@ static void CheckExplicitInstantiationScope(Sema &S, NamedDecl *D, if (CurContext->Equals(ExpectedContext)) return; - S.Diag(InstLoc, diag::err_explicit_instantiation_unqualified_wrong_namespace) + S.Diag(InstLoc, + S.getLangOptions().CPlusPlus0x? + diag::err_explicit_instantiation_unqualified_wrong_namespace + : diag::warn_explicit_instantiation_unqualified_wrong_namespace_0x) << D << ExpectedContext; S.Diag(D->getLocation(), diag::note_explicit_instantiation_here); } |