From: Jakub Jelinek Date: Fri, 19 Jan 2018 22:35:09 +0000 (+0100) Subject: re PR c++/83919 (spurious -Wignored-qualifiers warning) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e6f97c3feec266355a80cdcb68a5885748454c39;p=gcc.git re PR c++/83919 (spurious -Wignored-qualifiers warning) PR c++/83919 * typeck.c (convert_for_assignment): Suppress warn_ignored_qualifiers for direct enum init. * decl.c (reshape_init): Likewise. * g++.dg/cpp0x/pr83919.C: New test. From-SVN: r256903 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3e40d79e952..eb39b402391 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2018-01-19 Jakub Jelinek + + PR c++/83919 + * typeck.c (convert_for_assignment): Suppress warn_ignored_qualifiers + for direct enum init. + * decl.c (reshape_init): Likewise. + 2018-01-19 Marek Polacek * constexpr.c (fold_simple): Simplify. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 32ac81fc271..039ddd92cb7 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6091,6 +6091,7 @@ reshape_init (tree type, tree init, tsubst_flags_t complain) if (check_narrowing (ENUM_UNDERLYING_TYPE (type), elt, complain)) { warning_sentinel w (warn_useless_cast); + warning_sentinel w2 (warn_ignored_qualifiers); return cp_build_c_cast (type, elt, tf_warning_or_error); } else diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index d0adb798278..1102f677f15 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -8689,6 +8689,7 @@ convert_for_assignment (tree type, tree rhs, if (check_narrowing (ENUM_UNDERLYING_TYPE (type), elt, complain)) { warning_sentinel w (warn_useless_cast); + warning_sentinel w2 (warn_ignored_qualifiers); rhs = cp_build_c_cast (type, elt, complain); } else diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2d0e317602b..d6ea61f5938 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-01-19 Jakub Jelinek + + PR c++/83919 + * g++.dg/cpp0x/pr83919.C: New test. + 2018-01-19 Jeff Law Jakub Jelinek diff --git a/gcc/testsuite/g++.dg/cpp0x/pr83919.C b/gcc/testsuite/g++.dg/cpp0x/pr83919.C new file mode 100644 index 00000000000..a612f026191 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr83919.C @@ -0,0 +1,10 @@ +// PR c++/83919 +// { dg-do compile { target c++11 } } +// { dg-options "-Wignored-qualifiers" } + +enum class Conf; +struct foo +{ + foo (const Conf& conf) : x{conf} {} // { dg-bogus "type qualifiers ignored on cast result type" } + const Conf x; +};