===================================================================
@@ -10117,9 +10117,10 @@ grokdeclarator (const cp_declarator *declarator,
if (explicitp == 1 || (explicitp && friendp))
{
- /* [dcl.fct.spec] The explicit specifier shall only be used in
- declarations of constructors within a class definition. */
- error ("only declarations of constructors can be %<explicit%>");
+ /* [dcl.fct.spec] (C++11) The explicit specifier shall be used only
+ in the declaration of a constructor or conversion function within
+ a class definition. */
+ error ("only declarations can be marked %<explicit%>");
explicitp = 0;
}
===================================================================
@@ -0,0 +1,8 @@
+// PR c++/60686
+// { dg-do compile { target c++11 } }
+
+struct A {
+ explicit operator int() const;
+};
+
+explicit inline A::operator int() const { return 1; } // { dg-error "only declarations can be marked 'explicit'" }