From: Paolo Carlini <paolo.carlini@oracle.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Cc: Jason Merrill <jason@redhat.com>
Subject: [C++ Patch] PR 69095
Date: Sun, 22 May 2016 18:26:00 -0000 [thread overview]
Message-ID: <5741F9D9.6040906@oracle.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 589 bytes --]
Hi,
finally sending a patch for this issue. As noticed by submitter himself,
it appears to boil down to a rather straightforward case of not
rejecting unexpanded parameter packs in default arguments. In order to
handle all the combinations (in/out of class, template
parameter/function parameter) I added calls of
check_for_bare_parameter_packs both to cp_parser_default_argument and
cp_parser_late_parsing_default_args (to have a meaningful location for
the latter, the patchlet which I sent earlier today is a must). Tested
x86_64-linux.
Thanks,
Paolo.
//////////////////////
[-- Attachment #2: CL_69095 --]
[-- Type: text/plain, Size: 320 bytes --]
/cp
2016-05-22 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/69095
* parser.c (cp_parser_default_argument): Call
check_for_bare_parameter_packs.
(cp_parser_late_parsing_default_args): Likewise.
/testsuite
2016-05-22 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/69095
* g++.dg/cpp0x/variadic168.C: New.
[-- Attachment #3: patch_69095 --]
[-- Type: text/plain, Size: 1747 bytes --]
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 236569)
+++ cp/parser.c (working copy)
@@ -20673,6 +20673,8 @@ cp_parser_default_argument (cp_parser *parser, boo
}
if (BRACE_ENCLOSED_INITIALIZER_P (default_argument))
maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
+ if (check_for_bare_parameter_packs (default_argument))
+ default_argument = error_mark_node;
if (template_parm_p)
pop_deferring_access_checks ();
parser->greater_than_is_operator_p = saved_greater_than_is_operator_p;
@@ -26403,6 +26405,9 @@ cp_parser_late_parsing_default_args (cp_parser *pa
continue;
}
+ if (check_for_bare_parameter_packs (parsed_arg))
+ parsed_arg = error_mark_node;
+
TREE_PURPOSE (parm) = parsed_arg;
/* Update any instantiations we've already created. */
Index: testsuite/g++.dg/cpp0x/variadic168.C
===================================================================
--- testsuite/g++.dg/cpp0x/variadic168.C (revision 0)
+++ testsuite/g++.dg/cpp0x/variadic168.C (working copy)
@@ -0,0 +1,18 @@
+// PR c++/69095
+// { dg-do compile { target c++11 } }
+
+struct B1 {
+ template <typename Ret, typename... Args, unsigned = sizeof(Args)> // { dg-error "parameter packs not expanded" }
+ void insert(Ret);
+};
+
+struct B2 {
+ template <typename Ret, typename... Args>
+ void insert(Ret, unsigned = sizeof(Args)); // { dg-error "parameter packs not expanded" }
+};
+
+template <typename Ret, typename... Args, unsigned = sizeof(Args)> // { dg-error "parameter packs not expanded" }
+void insert1(Ret);
+
+template <typename Ret, typename... Args>
+void insert2(Ret, unsigned = sizeof(Args)); // { dg-error "parameter packs not expanded" }
next reply other threads:[~2016-05-22 18:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-22 18:26 Paolo Carlini [this message]
2016-05-23 13:32 ` Jason Merrill
2016-05-23 15:25 ` Paolo Carlini
2016-05-23 17:30 ` Jason Merrill
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=5741F9D9.6040906@oracle.com \
--to=paolo.carlini@oracle.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
/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).