re PR c++/83919 (spurious -Wignored-qualifiers warning)
authorJakub Jelinek <jakub@redhat.com>
Fri, 19 Jan 2018 22:35:09 +0000 (23:35 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 19 Jan 2018 22:35:09 +0000 (23:35 +0100)
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

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/pr83919.C [new file with mode: 0644]

index 3e40d79e95230aeeab4aec212b6346822659594e..eb39b4023910af2df6d081f3cf20b951e6236d14 100644 (file)
@@ -1,3 +1,10 @@
+2018-01-19  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.
+
 2018-01-19  Marek Polacek  <polacek@redhat.com>
 
        * constexpr.c (fold_simple): Simplify.
index 32ac81fc27164c5f19882cfa54a58dddb5e10a96..039ddd92cb7f890aecf6795549cad6bb6da04348 100644 (file)
@@ -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
index d0adb798278431b1e65b7f813d129d7532bebd79..1102f677f159170308dd48bee1ca58f06cdf5652 100644 (file)
@@ -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
index 2d0e317602b6e634c558238abe4a585ba3278b4e..d6ea61f593805711d616dafbc957c28d2a2c050d 100644 (file)
@@ -1,3 +1,8 @@
+2018-01-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/83919
+       * g++.dg/cpp0x/pr83919.C: New test.
+
 2018-01-19  Jeff Law  <law@redhat.com>
            Jakub Jelinek  <jakub@redhat.com>
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr83919.C b/gcc/testsuite/g++.dg/cpp0x/pr83919.C
new file mode 100644 (file)
index 0000000..a612f02
--- /dev/null
@@ -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;
+};