Core DR 393 - parameter pointer to array of unknown bound
authorJason Merrill <jason@redhat.com>
Tue, 11 Jul 2017 18:41:32 +0000 (14:41 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 11 Jul 2017 18:41:32 +0000 (14:41 -0400)
* decl.c (grokparms): Downgrade error about array of unknown bound
to pedwarn and disable it for C++17.

From-SVN: r250137

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

index 17caf5df9b1dea8b887347e9cfebcce5104bc073..bf77412d8bed997369649d2c919b5c58b496d7a0 100644 (file)
@@ -1,3 +1,9 @@
+2017-07-11  Jason Merrill  <jason@redhat.com>
+
+       Core DR 393
+       * decl.c (grokparms): Downgrade error about array of unknown bound
+       to pedwarn and disable it for C++17.
+
 2017-07-11  Nathan Sidwell  <nathan@acm.org>
 
        * decl2.c (reset_type_linkage_2): Dont't change ctor name.
index 43a94d9f6eb62ed4ad014a0c9349b46ebaf4dbf8..b9b8794d29b1330d02837c6790b924d396e47f7a 100644 (file)
@@ -12591,9 +12591,11 @@ grokparms (tree parmlist, tree *parms)
            }
          else if (abstract_virtuals_error (decl, type))
            any_error = 1;  /* Seems like a good idea.  */
-         else if (POINTER_TYPE_P (type))
+         else if (cxx_dialect < cxx1z
+                  && POINTER_TYPE_P (type))
            {
-             /* [dcl.fct]/6, parameter types cannot contain pointers
+             /* Before C++17 DR 393:
+                [dcl.fct]/6, parameter types cannot contain pointers
                 (references) to arrays of unknown bound.  */
              tree t = TREE_TYPE (type);
              int ptr = TYPE_PTR_P (type);
@@ -12609,12 +12611,13 @@ grokparms (tree parmlist, tree *parms)
                  t = TREE_TYPE (t);
                }
              if (TREE_CODE (t) == ARRAY_TYPE)
-               error (ptr
-                       ? G_("parameter %qD includes pointer to array of "
-                            "unknown bound %qT")
-                       : G_("parameter %qD includes reference to array of "
-                            "unknown bound %qT"),
-                       decl, t);
+               pedwarn (DECL_SOURCE_LOCATION (decl), OPT_Wpedantic,
+                        ptr
+                        ? G_("parameter %qD includes pointer to array of "
+                             "unknown bound %qT")
+                        : G_("parameter %qD includes reference to array of "
+                             "unknown bound %qT"),
+                        decl, t);
            }
 
          if (any_error)
diff --git a/gcc/testsuite/g++.dg/cpp1z/dr393.C b/gcc/testsuite/g++.dg/cpp1z/dr393.C
new file mode 100644 (file)
index 0000000..4a7645a
--- /dev/null
@@ -0,0 +1,4 @@
+// DR 393
+// { dg-options -Wpedantic }
+
+void f(int (&)[]);  // { dg-warning "unknown bound" "" { target c++14_down } }