+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>
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
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" }
};
--- /dev/null
+// 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;
+}