re PR c++/82299 (-Wuseless-cast errors on typed enums used in member data initializers in c++1z)
PR c++/82299 * decl.c (reshape_init): Suppress warn_useless_cast for direct enum init. * typeck.c (convert_for_assignment): Likewise. * g++.dg/cpp0x/pr82299.C: New test. From-SVN: r253499
This commit is contained in:
parent
1e28109018
commit
a45258d20b
|
@ -1,3 +1,10 @@
|
|||
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.
|
||||
|
||||
2017-10-05 Jason Merrill <jason@redhat.com>
|
||||
|
||||
* call.c (convert_arg_to_ellipsis): Use the result of force_rvalue.
|
||||
|
|
|
@ -6100,7 +6100,10 @@ reshape_init (tree type, tree init, tsubst_flags_t complain)
|
|||
{
|
||||
tree elt = CONSTRUCTOR_ELT (init, 0)->value;
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -8414,7 +8414,10 @@ convert_for_assignment (tree type, tree rhs,
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2017-10-06 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/82299
|
||||
* g++.dg/cpp0x/pr82299.C: New test.
|
||||
|
||||
2017-10-06 Christophe Lyon <christophe.lyon@linaro.org>
|
||||
|
||||
Backport from mainline r253251.
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
// 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" }
|
||||
};
|
Loading…
Reference in New Issue