[cfe-commits] r142333 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaTemplate.cpp test/SemaCXX/cxx0x-compat.cpp

Richard Smith richard-llvm at metafoo.co.uk
Mon Oct 17 20:44:04 PDT 2011


Author: rsmith
Date: Mon Oct 17 22:44:03 2011
New Revision: 142333

URL: http://llvm.org/viewvc/llvm-project?rev=142333&view=rev
Log:
Add -Wc++11-compat warning for an inline specifier on an explicit instantiation.

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

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=142333&r1=142332&r2=142333&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Oct 17 22:44:03 2011
@@ -2428,6 +2428,8 @@
   "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<

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=142333&r1=142332&r2=142333&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Mon Oct 17 22:44:03 2011
@@ -6157,9 +6157,11 @@
   //   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

Modified: cfe/trunk/test/SemaCXX/cxx0x-compat.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-compat.cpp?rev=142333&r1=142332&r2=142333&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx0x-compat.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-compat.cpp Mon Oct 17 22:44:03 2011
@@ -15,6 +15,8 @@
   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}}
 }





More information about the cfe-commits mailing list