* C++ PATCH for Core DR 393, parm w/ pointer to array of unknown bound
@ 2017-07-11 18:41 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2017-07-11 18:41 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 229 bytes --]
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.
[-- Attachment #2: dr393.diff --]
[-- Type: text/plain, Size: 1685 bytes --]
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 --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 } }
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-07-11 18:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-11 18:41 C++ PATCH for Core DR 393, parm w/ pointer to array of unknown bound Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).