* [C++ Patch] PR 69095
@ 2016-05-22 18:26 Paolo Carlini
2016-05-23 13:32 ` Jason Merrill
0 siblings, 1 reply; 4+ messages in thread
From: Paolo Carlini @ 2016-05-22 18:26 UTC (permalink / raw)
To: gcc-patches; +Cc: Jason Merrill
[-- 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" }
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [C++ Patch] PR 69095
2016-05-22 18:26 [C++ Patch] PR 69095 Paolo Carlini
@ 2016-05-23 13:32 ` Jason Merrill
2016-05-23 15:25 ` Paolo Carlini
0 siblings, 1 reply; 4+ messages in thread
From: Jason Merrill @ 2016-05-23 13:32 UTC (permalink / raw)
To: Paolo Carlini, gcc-patches
On 05/22/2016 02:26 PM, Paolo Carlini wrote:
> 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
Hmm, would it make sense to check in cp_parser_initializer?
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [C++ Patch] PR 69095
2016-05-23 13:32 ` Jason Merrill
@ 2016-05-23 15:25 ` Paolo Carlini
2016-05-23 17:30 ` Jason Merrill
0 siblings, 1 reply; 4+ messages in thread
From: Paolo Carlini @ 2016-05-23 15:25 UTC (permalink / raw)
To: gcc-patches; +Cc: Jason Merrill
[-- Attachment #1: Type: text/plain, Size: 680 bytes --]
Hi,
On 23/05/2016 15:32, Jason Merrill wrote:
> On 05/22/2016 02:26 PM, Paolo Carlini wrote:
>> 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
>
> Hmm, would it make sense to check in cp_parser_initializer?
Oh yes. The below is already past g++.dg/tm...
Thanks!
Paolo.
////////////////////
[-- Attachment #2: patch_69095_2 --]
[-- Type: text/plain, Size: 1248 bytes --]
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 236592)
+++ cp/parser.c (working copy)
@@ -20800,6 +20800,9 @@ cp_parser_initializer (cp_parser* parser, bool* is
init = error_mark_node;
}
+ if (check_for_bare_parameter_packs (init))
+ init = error_mark_node;
+
return init;
}
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" }
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [C++ Patch] PR 69095
2016-05-23 15:25 ` Paolo Carlini
@ 2016-05-23 17:30 ` Jason Merrill
0 siblings, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2016-05-23 17:30 UTC (permalink / raw)
To: Paolo Carlini, gcc-patches
On 05/23/2016 11:25 AM, Paolo Carlini wrote:
> On 23/05/2016 15:32, Jason Merrill wrote:
>> On 05/22/2016 02:26 PM, Paolo Carlini wrote:
>>> 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
>>
>> Hmm, would it make sense to check in cp_parser_initializer?
> Oh yes. The below is already past g++.dg/tm...
OK if testing passes.
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-05-23 17:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-22 18:26 [C++ Patch] PR 69095 Paolo Carlini
2016-05-23 13:32 ` Jason Merrill
2016-05-23 15:25 ` Paolo Carlini
2016-05-23 17:30 ` 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).