Commit 320d13ec by Paolo Carlini Committed by Paolo Carlini

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
parent effb52da
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>
......
......@@ -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;
}
......
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
......
......@@ -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" }
};
// 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;
}
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