From: Jason Merrill Date: Tue, 11 Jul 2017 18:41:32 +0000 (-0400) Subject: Core DR 393 - parameter pointer to array of unknown bound X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=19cf5a70685214d2fe4c5b79b1f8399de8a7091e;p=gcc.git 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. From-SVN: r250137 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 17caf5df9b1..bf77412d8be 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-07-11 Jason Merrill + + 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 * decl2.c (reset_type_linkage_2): Dont't change ctor name. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 43a94d9f6eb..b9b8794d29b 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,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 index 00000000000..4a7645a618f --- /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 } }