Commit 2ec99953 by Paolo Carlini Committed by Paolo Carlini

re PR c++/60686 (message " only declarations of constructors can be ‘explicit’ "…

re PR c++/60686 (message " only declarations of constructors can be ‘explicit’ " now conflicting with C++11)

/cp
2014-07-09  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/60686
	* decl.c (grokdeclarator): Adjust error messages about 'explicit'
	outside class declaration, in friend declaration, and neither on
	constructor nor conversion operator.

/testsuite
2014-07-09  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/60686
	* g++.dg/cpp0x/explicit8.C: New.

From-SVN: r212415
parent a6ea72bf
2014-07-09 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/60686
* decl.c (grokdeclarator): Adjust error messages about 'explicit'
outside class declaration, in friend declaration, and neither on
constructor nor conversion operator.
2014-07-09 Paolo Carlini <paolo.carlini@oracle.com>
DR 1584
PR c++/57466
* pt.c (check_cv_quals_for_unify): Implement resolution, disregard
......
......@@ -10117,9 +10117,16 @@ 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. */
if (!current_class_type)
error ("%<explicit%> outside class declaration");
else if (friendp)
error ("%<explicit%> in friend declaration");
else
error ("only declarations of constructors and conversion operators "
"can be %<explicit%>");
explicitp = 0;
}
......
2014-07-09 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/60686
* g++.dg/cpp0x/explicit8.C: New.
2014-07-09 Paolo Carlini <paolo.carlini@oracle.com>
DR 1584
PR c++/57466
* g++.dg/template/pr57466.C: New.
......
// 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 "'explicit' outside class declaration" }
struct B {
explicit void f(); // { dg-error "only declarations of constructors and conversion operators can be 'explicit'" }
};
explicit void B::f() { } // { dg-error "'explicit' outside class declaration" }
struct C {
explicit C(int);
};
struct D {
explicit friend C::C(int); // { dg-error "'explicit' in friend declaration" }
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment