This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] Avoid spurious -Wignored-qualifiers warning on artificial C++17 P0138R2 cast (PR c++/83919)


OK.

On Thu, Jan 18, 2018 at 6:17 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> These casts for P0138R2 isn't something the user typed in their code,
> so diagnosing -Wignored-qualifiers on these looks wrong.
> -Wuseless-cast has been handled similarly in the past already.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2018-01-18  Jakub Jelinek  <jakub@redhat.com>
>
>         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.
>
> --- gcc/cp/typeck.c.jj  2018-01-17 22:00:06.863228592 +0100
> +++ gcc/cp/typeck.c     2018-01-18 10:58:39.976333499 +0100
> @@ -8689,6 +8689,7 @@ convert_for_assignment (tree type, tree
>        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
> --- gcc/cp/decl.c.jj    2018-01-18 00:41:40.564015137 +0100
> +++ gcc/cp/decl.c       2018-01-18 11:10:10.579713182 +0100
> @@ -6091,6 +6091,7 @@ reshape_init (tree type, tree init, tsub
>        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
> --- gcc/testsuite/g++.dg/cpp0x/pr83919.C.jj     2018-01-18 11:03:08.048295967 +0100
> +++ gcc/testsuite/g++.dg/cpp0x/pr83919.C        2018-01-18 10:59:57.465322655 +0100
> @@ -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;
> +};
>
>         Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]