]> granicus.if.org Git - clang/commitdiff
Add -Wc++11-compat warning for an inline specifier on an explicit instantiation.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 18 Oct 2011 03:44:03 +0000 (03:44 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 18 Oct 2011 03:44:03 +0000 (03:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142333 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaTemplate.cpp
test/SemaCXX/cxx0x-compat.cpp

index bc3740b49e183990dc45b7ca26490dd612c45ee2..354f23117188cf8ab79f1f8c49c1d27ec97998e1 100644 (file)
@@ -2428,6 +2428,8 @@ def note_explicit_instantiation_candidate : Note<
   "explicit instantiation candidate function template here %0">;
 def err_explicit_instantiation_inline : Error<
   "explicit instantiation cannot be 'inline'">;
+def warn_explicit_instantiation_inline_0x : Warning<
+  "explicit instantiation cannot be 'inline'">, InGroup<CXX11Compat>;
 def err_explicit_instantiation_constexpr : Error<
   "explicit instantiation cannot be 'constexpr'">;
 def ext_explicit_instantiation_without_qualified_id : Extension<
index 82a88312d7b7c99a1303529592376efcbd4811c8..6e8544ef2fa0fdf1e876b721e9d90742b5e5b07c 100644 (file)
@@ -6157,9 +6157,11 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
   //   inline or constexpr specifiers.
   // Presumably, this also applies to member functions of class templates as
   // well.
-  if (D.getDeclSpec().isInlineSpecified() && getLangOptions().CPlusPlus0x)
+  if (D.getDeclSpec().isInlineSpecified())
     Diag(D.getDeclSpec().getInlineSpecLoc(),
-         diag::err_explicit_instantiation_inline)
+         getLangOptions().CPlusPlus0x ?
+           diag::err_explicit_instantiation_inline :
+           diag::warn_explicit_instantiation_inline_0x)
       << FixItHint::CreateRemoval(D.getDeclSpec().getInlineSpecLoc());
   if (D.getDeclSpec().isConstexprSpecified())
     // FIXME: Add a fix-it to remove the 'constexpr' and add a 'const' if one is
index 4a7c1defee0f4781a25ea9e1d8f8f4e476896b98..5bec025b31683904bdbff32505af89f881d8dfbc 100644 (file)
@@ -15,6 +15,8 @@ namespace M {
   template void ::g<char>(char); // expected-warning {{explicit instantiation of 'g' must occur at global scope}}
 }
 
+template inline void g<double>(double); // expected-warning {{explicit instantiation cannot be 'inline'}}
+
 void g() {
   auto int n = 0; // expected-warning {{'auto' storage class specifier is redundant and incompatible with C++11}}
 }