From: Paolo Carlini Date: Fri, 22 May 2015 14:14:38 +0000 (+0000) Subject: re PR c++/65598 (Fix column location for 'explicit') X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=320d13eccc9e0df7e3ac2d9d81b8a56715c6c90e;p=gcc.git re PR c++/65598 (Fix column location for 'explicit') /cp 2015-05-22 Paolo Carlini PR c++/65598 * decl.c (grokdeclarator): Use the correct location in error messages about 'explicit'. /testsuite 2015-05-22 Paolo Carlini PR c++/65598 * g++.dg/cpp0x/explicit9.C: New. * g++.dg/cpp0x/explicit8.C: Check the locations too. From-SVN: r223576 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4dd8ec65cd8..047b0a14195 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-05-22 Paolo Carlini + + PR c++/65598 + * decl.c (grokdeclarator): Use the correct location in error + messages about 'explicit'. + 2015-05-22 Marek Polacek Edward Smith-Rowland <3dw4rd@verizon.net> diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5396994f7fe..06fbbd5451f 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 ("% outside class declaration"); + error_at (declspecs->locations[ds_explicit], + "% outside class declaration"); else if (friendp) - error ("% in friend declaration"); + error_at (declspecs->locations[ds_explicit], + "% in friend declaration"); else - error ("only declarations of constructors and conversion operators " - "can be %"); + error_at (declspecs->locations[ds_explicit], + "only declarations of constructors and conversion operators " + "can be %"); explicitp = 0; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6f795ade1b9..a3305450b65 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-05-22 Paolo Carlini + + PR c++/65598 + * g++.dg/cpp0x/explicit9.C: New. + * g++.dg/cpp0x/explicit8.C: Check the locations too. + 2015-05-22 Richard Biener PR tree-optimization/66251 diff --git a/gcc/testsuite/g++.dg/cpp0x/explicit8.C b/gcc/testsuite/g++.dg/cpp0x/explicit8.C index acacf97451a..9a8ecb348c6 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 00000000000..4afaafa2668 --- /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; +}