diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2015-05-22 14:14:38 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2015-05-22 14:14:38 +0000 |
commit | 320d13eccc9e0df7e3ac2d9d81b8a56715c6c90e (patch) | |
tree | f5f13937652e0994395c48f4ff5c0482fd89c46f /gcc | |
parent | effb52dae5203e21faf5f2c11bb0078e71f74482 (diff) | |
download | gcc-320d13eccc9e0df7e3ac2d9d81b8a56715c6c90e.zip gcc-320d13eccc9e0df7e3ac2d9d81b8a56715c6c90e.tar.gz gcc-320d13eccc9e0df7e3ac2d9d81b8a56715c6c90e.tar.bz2 |
re PR c++/65598 (Fix column location for 'explicit')
/cp
2015-05-22 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/65598
* decl.c (grokdeclarator): Use the correct location in error
messages about 'explicit'.
/testsuite
2015-05-22 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/65598
* g++.dg/cpp0x/explicit9.C: New.
* g++.dg/cpp0x/explicit8.C: Check the locations too.
From-SVN: r223576
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/explicit8.C | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/explicit9.C | 12 |
5 files changed, 35 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4dd8ec6..047b0a1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-05-22 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/65598 + * decl.c (grokdeclarator): Use the correct location in error + messages about 'explicit'. + 2015-05-22 Marek Polacek <polacek@redhat.com> Edward Smith-Rowland <3dw4rd@verizon.net> diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5396994..06fbbd5 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10266,12 +10266,15 @@ grokdeclarator (const cp_declarator *declarator, in the declaration of a constructor or conversion function within a class definition. */ if (!current_class_type) - error ("%<explicit%> outside class declaration"); + error_at (declspecs->locations[ds_explicit], + "%<explicit%> outside class declaration"); else if (friendp) - error ("%<explicit%> in friend declaration"); + error_at (declspecs->locations[ds_explicit], + "%<explicit%> in friend declaration"); else - error ("only declarations of constructors and conversion operators " - "can be %<explicit%>"); + error_at (declspecs->locations[ds_explicit], + "only declarations of constructors and conversion operators " + "can be %<explicit%>"); explicitp = 0; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6f795ad..a330545 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-05-22 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/65598 + * g++.dg/cpp0x/explicit9.C: New. + * g++.dg/cpp0x/explicit8.C: Check the locations too. + 2015-05-22 Richard Biener <rguenther@suse.de> PR tree-optimization/66251 diff --git a/gcc/testsuite/g++.dg/cpp0x/explicit8.C b/gcc/testsuite/g++.dg/cpp0x/explicit8.C index acacf97..9a8ecb3 100644 --- a/gcc/testsuite/g++.dg/cpp0x/explicit8.C +++ b/gcc/testsuite/g++.dg/cpp0x/explicit8.C @@ -5,18 +5,18 @@ struct A { explicit operator int() const; }; -explicit inline A::operator int() const { return 1; } // { dg-error "'explicit' outside class declaration" } +explicit inline A::operator int() const { return 1; } // { dg-error "1:'explicit' outside class declaration" } struct B { - explicit void f(); // { dg-error "only declarations of constructors and conversion operators can be 'explicit'" } + explicit void f(); // { dg-error "3:only declarations of constructors and conversion operators can be 'explicit'" } }; -explicit void B::f() { } // { dg-error "'explicit' outside class declaration" } +explicit void B::f() { } // { dg-error "1:'explicit' outside class declaration" } struct C { explicit C(int); }; struct D { - explicit friend C::C(int); // { dg-error "'explicit' in friend declaration" } + explicit friend C::C(int); // { dg-error "3:'explicit' in friend declaration" } }; diff --git a/gcc/testsuite/g++.dg/cpp0x/explicit9.C b/gcc/testsuite/g++.dg/cpp0x/explicit9.C new file mode 100644 index 0000000..4afaafa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/explicit9.C @@ -0,0 +1,12 @@ +// PR c++/65598 +// { dg-do compile { target c++11 } } + +struct ExplicitTest +{ + explicit operator bool() const; +}; + +explicit ExplicitTest::operator bool() const // { dg-error "1:'explicit' outside class declaration" } +{ + return true; +} |