This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] Add support for __VA_OPT__
- From: Pedro Alves <palves at redhat dot com>
- To: Tom Tromey <tom at tromey dot com>, gdb-patches at sourceware dot org
- Date: Wed, 20 Sep 2017 17:43:11 +0100
- Subject: Re: [RFA] Add support for __VA_OPT__
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4326B267D4
- References: <20170918024223.5607-1-tom@tromey.com>
W00t, thanks for doing this (and the gcc side as well!)
On 09/18/2017 03:42 AM, Tom Tromey wrote:
> diff --git a/gdb/testsuite/gdb.base/macscp.exp b/gdb/testsuite/gdb.base/macscp.exp
> index 54b5ab2..a08ec46 100644
> --- a/gdb/testsuite/gdb.base/macscp.exp
> +++ b/gdb/testsuite/gdb.base/macscp.exp
> @@ -620,6 +620,10 @@ gdb_test_no_output "macro define va_gnu(args...) varfunc (fixedarg, args)" \
> gdb_test_no_output "macro define va2_gnu(args...) varfunc (fixedarg, ## args)" \
> "define fourth varargs helper"
>
> +gdb_test_no_output \
> + "macro define va3_cxx2a(x, ...) varfunc (x __VA_OPT__(,) __VA_ARGS__)" \
> + "define fifth varargs helper"
> +
> gdb_test "macro expand va_c99(one, two, three)" \
> "expands to: *varfunc \\(fixedarg, *one, two, three\\)" \
> "c99 varargs expansion"
> @@ -644,6 +648,14 @@ gdb_test "macro expand va2_gnu()" \
> "expands to: *varfunc \\(fixedarg\\)" \
> "gnu varargs expansion special splicing without an argument"
>
> +gdb_test "macro expand va3_cxx2a(23)" \
> + "expands to: *varfunc \\(23 \\)" \
> + "C++2a __VA_OPT__ handling without variable argument"
> +
> +gdb_test "macro expand va3_cxx2a(23, 24, 25)" \
> + "expands to: *varfunc \\(23, 24, 25\\)" \
> + "C++2a __VA_OPT__ handling with variable argument"
> +
The patch looks good to me, though I think it'd be nice to see
tests that make sure that ill-formed input doesn't send us
to the weeds. Like:
- does the state machine handle "__VA_OPT__)" gracefully?
I.e., ')' before '('.
- similarly: "__VA_OPT__)(,)"
- does the state machine handle multiple occurrences of
__VA_OPT__ in the same macro expansion? It looks like
it, but....
Also, does this handle:
__VA_OPT__(__VA_ARGS__)
correctly? I think so, but...
Thanks,
Pedro Alves