diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2014-07-09 22:44:42 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2014-07-09 22:44:42 +0000 |
commit | 2ec99953415c8d17a20b72f92b0d268478d1bfde (patch) | |
tree | b02f959d9997fd80cadd477063c83e136789fa8d | |
parent | a6ea72bf8296fcb351b76e4f0c11763bc5ae1505 (diff) | |
download | gcc-2ec99953415c8d17a20b72f92b0d268478d1bfde.zip gcc-2ec99953415c8d17a20b72f92b0d268478d1bfde.tar.gz gcc-2ec99953415c8d17a20b72f92b0d268478d1bfde.tar.bz2 |
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
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/decl.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/explicit8.C | 22 |
4 files changed, 44 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6174193..5827bbd 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,12 @@ 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 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5ab8ccd..1ade586 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 675e343..f4ccc1f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 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. diff --git a/gcc/testsuite/g++.dg/cpp0x/explicit8.C b/gcc/testsuite/g++.dg/cpp0x/explicit8.C new file mode 100644 index 0000000..acacf97 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/explicit8.C @@ -0,0 +1,22 @@ +// 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" } +}; |