This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] Add support for __VA_OPT__


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]