2017-10-06 Jakub Jelinek <jakub@redhat.com>
+ PR c++/82299
+ * decl.c (reshape_init): Suppress warn_useless_cast for direct enum
+ init.
+ * typeck.c (convert_for_assignment): Likewise.
+
P0704R1 - fixing const-qualified pointers to members
* typeck2.c (build_m_component_ref): For -std=c++2a allow
pointer to const & qualified method on rvalue.
tree elt = CONSTRUCTOR_ELT (init, 0)->value;
type = cv_unqualified (type);
if (check_narrowing (ENUM_UNDERLYING_TYPE (type), elt, complain))
- return cp_build_c_cast (type, elt, tf_warning_or_error);
+ {
+ warning_sentinel w (warn_useless_cast);
+ return cp_build_c_cast (type, elt, tf_warning_or_error);
+ }
else
return error_mark_node;
}
{
tree elt = CONSTRUCTOR_ELT (rhs, 0)->value;
if (check_narrowing (ENUM_UNDERLYING_TYPE (type), elt, complain))
- rhs = cp_build_c_cast (type, elt, complain);
+ {
+ warning_sentinel w (warn_useless_cast);
+ rhs = cp_build_c_cast (type, elt, complain);
+ }
else
rhs = error_mark_node;
}
2017-10-06 Jakub Jelinek <jakub@redhat.com>
+ PR c++/82299
+ * g++.dg/cpp0x/pr82299.C: New test.
+
P0704R1 - fixing const-qualified pointers to members
* g++.dg/cpp2a/ptrmem1.C: New test.
--- /dev/null
+// PR c++/82299
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wuseless-cast" }
+
+enum Enum : char { A = 0, B = 1 };
+
+struct S {
+ Enum e { Enum::A }; // { dg-bogus "useless cast to type" }
+};