]> granicus.if.org Git - clang/commitdiff
[temp.explicit]p1: constexpr cannot be specified in explicit instantiations.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 14 Oct 2011 19:58:02 +0000 (19:58 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 14 Oct 2011 19:58:02 +0000 (19:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141982 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaTemplate.cpp
test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp

index a3a423d9d75b69f9e759fa7363ce7c7ef39be026..4051a8063875eb6279b7172f9cc0513c1e7b3815 100644 (file)
@@ -2412,6 +2412,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 err_explicit_instantiation_constexpr : Error<
+  "explicit instantiation cannot be 'constexpr'">;
 def ext_explicit_instantiation_without_qualified_id : Extension<
   "qualifier in explicit instantiation of %q0 requires a template-id "
   "(a typedef is not permitted)">;
index 929d74efa98a4121f486f68f3edd0ec72985af53..8dda34c8ab5d5832cfd73427276ce365244c42a4 100644 (file)
@@ -6164,9 +6164,12 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
   if (D.getDeclSpec().isInlineSpecified() && getLangOptions().CPlusPlus0x)
     Diag(D.getDeclSpec().getInlineSpecLoc(),
          diag::err_explicit_instantiation_inline)
-      <<FixItHint::CreateRemoval(D.getDeclSpec().getInlineSpecLoc());
-
-  // FIXME: check for constexpr specifier.
+      << 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
+    // not already specified.
+    Diag(D.getDeclSpec().getConstexprSpecLoc(),
+         diag::err_explicit_instantiation_constexpr);
 
   // C++0x [temp.explicit]p2:
   //   There are two forms of explicit instantiation: an explicit instantiation
index e898a4896825962b1ad8785f60d30de9859d7c6e..97e78fd791fac0f3912aa50a96e36b0ed8262076 100644 (file)
@@ -5,6 +5,11 @@ struct X {
   void f() {}
 };
 
-template inline void X<int>::f(); // expected-error{{'inline'}}
+template inline void X<int>::f(); // expected-error{{explicit instantiation cannot be 'inline'}}
 
-// FIXME: test constexpr
+template<typename T>
+struct Y {
+  constexpr int f() { return 0; }
+};
+
+template constexpr int Y<int>::f(); // expected-error{{explicit instantiation cannot be 'constexpr'}}