+2018-09-19 Marek Polacek <polacek@redhat.com>
+
+ PR c++/87357 - missing -Wconversion warning
+ * decl.c (grok_op_properties): Remove diagnostic parts mentioning
+ a conversion to a reference to void. Use
+ same_type_ignoring_top_level_qualifiers_p rather than comparing types
+ directly.
+
2018-09-18 Marek Polacek <polacek@redhat.com>
P1064R0 - Allowing Virtual Function Calls in Constant Expressions
t = TYPE_MAIN_VARIANT (TREE_TYPE (t));
if (VOID_TYPE_P (t))
- warning_at (loc, OPT_Wconversion,
- ref
- ? G_("conversion to a reference to void "
- "will never use a type conversion operator")
- : G_("conversion to void "
- "will never use a type conversion operator"));
+ warning_at (loc, OPT_Wconversion, "conversion to void "
+ "will never use a type conversion operator");
else if (class_type)
{
- if (t == class_type)
+ if (same_type_ignoring_top_level_qualifiers_p (t, class_type))
warning_at (loc, OPT_Wconversion,
ref
? G_("conversion to a reference to the same type "
+2018-09-19 Marek Polacek <polacek@redhat.com>
+
+ PR c++/87357 - missing -Wconversion warning
+ * g++.dg/warn/Wconversion5.C: New test.
+
2018-09-19 Matthew Malcomson <matthew.malcomson@arm.com>
* gcc.target/aarch64/atomic-store.c: New.
--- /dev/null
+// PR c++/87357
+// { dg-do compile }
+// { dg-options "-Wconversion" }
+
+struct B { };
+
+struct X : public B {
+ operator X(); // { dg-warning "3:conversion to the same type will never use a type conversion operator" }
+ operator X&(); // { dg-warning "3:conversion to a reference to the same type will never use a type conversion operator" }
+ operator X() const; // { dg-warning "3:conversion to the same type will never use a type conversion operator" }
+ operator const X(); // { dg-warning "3:conversion to the same type will never use a type conversion operator" }
+
+ operator B(); // { dg-warning "3:conversion to a base class will never use a type conversion operator" }
+ operator B&(); // { dg-warning "3:conversion to a reference to a base class will never use a type conversion operator" }
+ operator B() const; // { dg-warning "3:conversion to a base class will never use a type conversion operator" }
+ operator const B(); // { dg-warning "3:conversion to a base class will never use a type conversion operator" }
+
+ operator void(); // { dg-warning "3:conversion to void will never use a type conversion operator" }
+ operator void() const; // { dg-warning "3:conversion to void will never use a type conversion operator" }
+};