From: Jason Merrill <jason@redhat.com>
To: gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: C++ PATCH for Core DR 393, parm w/ pointer to array of unknown bound
Date: Tue, 11 Jul 2017 18:41:00 -0000 [thread overview]
Message-ID: <CADzB+2kAiGCsgrhMOnwb6wG4qz8ugtjtXEdTwQWNif1Y4zCfeA@mail.gmail.com> (raw)
[-- 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 } }
reply other threads:[~2017-07-11 18:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CADzB+2kAiGCsgrhMOnwb6wG4qz8ugtjtXEdTwQWNif1Y4zCfeA@mail.gmail.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).