diff mbox

C++ PATCH for Core DR 393, parm w/ pointer to array of unknown bound

Message ID CADzB+2kAiGCsgrhMOnwb6wG4qz8ugtjtXEdTwQWNif1Y4zCfeA@mail.gmail.com
State New
Headers show

Commit Message

Jason Merrill July 11, 2017, 6:41 p.m. UTC
Core DR 393 in C++17 removed the restriction on parameters with
pointer to array of unknown bound type; accordingly, I've reduced the
diagnostic for earlier standards to a pedwarn.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit a89d6192b65fc0eef3d95592c212a389928b6cba
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Jul 11 12:08:10 2017 -0400

            Core DR 393 - parameter pointer to array of unknown bound
    
            * decl.c (grokparms): Downgrade error about array of unknown bound
            to pedwarn and disable it for C++17.
diff mbox

Patch

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 43a94d9..b9b8794 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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,7 +12611,8 @@  grokparms (tree parmlist, tree *parms)
 		  t = TREE_TYPE (t);
 		}
 	      if (TREE_CODE (t) == ARRAY_TYPE)
-		error (ptr
+		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 "
diff --git a/gcc/testsuite/g++.dg/cpp1z/dr393.C b/gcc/testsuite/g++.dg/cpp1z/dr393.C
new file mode 100644
index 0000000..4a7645a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/dr393.C
@@ -0,0 +1,4 @@ 
+// DR 393
+// { dg-options -Wpedantic }
+
+void f(int (&)[]);  // { dg-warning "unknown bound" "" { target c++14_down } }