diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-08-17 09:25:56 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-08-17 09:27:57 +0200 |
commit | d56599979211266b2f7b7535311205dd758353ac (patch) | |
tree | 2841f0061f3afc3a036c6609b32e7915dbb3eee6 /gcc/d/d-target-def.h | |
parent | 0215b3559e55f39f38e10984a804c53907f7491c (diff) | |
download | gcc-d56599979211266b2f7b7535311205dd758353ac.zip gcc-d56599979211266b2f7b7535311205dd758353ac.tar.gz gcc-d56599979211266b2f7b7535311205dd758353ac.tar.bz2 |
c++: Add C++20 #__VA_OPT__ support
The following patch implements C++20 # __VA_OPT__ (...) support.
Testcases cover what I came up with myself and what LLVM has for #__VA_OPT__
in its testsuite and the string literals are identical between the two
compilers on the va-opt-5.c testcase.
2021-08-17 Jakub Jelinek <jakub@redhat.com>
libcpp/
* macro.c (vaopt_state): Add m_stringify member.
(vaopt_state::vaopt_state): Initialize it.
(vaopt_state::update): Overwrite it.
(vaopt_state::stringify): New method.
(stringify_arg): Replace arg argument with first, count arguments
and add va_opt argument. Use first instead of arg->first and
count instead of arg->count, for va_opt add paste_tokens handling.
(paste_tokens): Fix up len calculation. Don't spell rhs twice,
instead use %.*s to supply lhs and rhs spelling lengths. Don't call
_cpp_backup_tokens here.
(paste_all_tokens): Call it here instead.
(replace_args): Adjust stringify_arg caller. For vaopt_state::END
if stringify is true handle __VA_OPT__ stringification.
(create_iso_definition): Handle # __VA_OPT__ similarly to # macro_arg.
gcc/testsuite/
* c-c++-common/cpp/va-opt-5.c: New test.
* c-c++-common/cpp/va-opt-6.c: New test.
Diffstat (limited to 'gcc/d/d-target-def.h')
0 files changed, 0 insertions, 0 deletions