===================================================================
@@ -7426,13 +7426,16 @@ grokfndecl (tree ctype,
return NULL_TREE;
}
+ if (inlinep & 1)
+ error ("%<inline%> is not allowed in declaration of friend "
+ "template specialization %qD",
+ decl);
+ if (inlinep & 2)
+ error ("%<constexpr%> is not allowed in declaration of friend "
+ "template specialization %qD",
+ decl);
if (inlinep)
- {
- error ("%<inline%> is not allowed in declaration of friend "
- "template specialization %qD",
- decl);
- return NULL_TREE;
- }
+ return NULL_TREE;
}
}
@@ -7471,8 +7474,10 @@ grokfndecl (tree ctype,
{
if (PROCESSING_REAL_TEMPLATE_DECL_P())
error ("cannot declare %<::main%> to be a template");
- if (inlinep)
+ if (inlinep & 1)
error ("cannot declare %<::main%> to be inline");
+ if (inlinep & 2)
+ error ("cannot declare %<::main%> to be constexpr");
if (!publicp)
error ("cannot declare %<::main%> to be static");
inlinep = 0;
===================================================================
@@ -0,0 +1,7 @@
+// { dg-do compile { target c++11 } }
+
+template<typename T> void f(T);
+
+template <class T> class A {
+ friend constexpr void f<>(int); // { dg-error "'constexpr' is not allowed" }
+};
===================================================================
@@ -0,0 +1,3 @@
+// { dg-do compile { target c++11 } }
+
+constexpr int main (); // { dg-error "constexpr" }