* [PATCH] c++: parameter pack inside static_assert [PR99893]
@ 2021-05-27 15:05 Patrick Palka
2021-05-27 17:40 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Patrick Palka @ 2021-05-27 15:05 UTC (permalink / raw)
To: gcc-patches
Here, we're not finding the parameter pack inside the static_assert because
STATIC_ASSERT trees are tcc_exceptional, and we weren't explicitly walking
them in cp_walk_subtrees.
Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for
trunk?
gcc/cp/ChangeLog:
PR c++/99893
* tree.c (cp_walk_subtrees) <case STATIC_ASSERT>: New case.
gcc/testsuite/ChangeLog:
PR c++/99893
* g++.dg/cpp0x/static_assert17.C: New test.
---
gcc/cp/tree.c | 5 +++++
gcc/testsuite/g++.dg/cpp0x/static_assert17.C | 9 +++++++++
2 files changed, 14 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/cpp0x/static_assert17.C
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 372d89fa9ed..fec5afaa2be 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -5446,6 +5446,11 @@ cp_walk_subtrees (tree *tp, int *walk_subtrees_p, walk_tree_fn func,
}
break;
+ case STATIC_ASSERT:
+ WALK_SUBTREE (STATIC_ASSERT_CONDITION (*tp));
+ WALK_SUBTREE (STATIC_ASSERT_MESSAGE (*tp));
+ break;
+
default:
return NULL_TREE;
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/static_assert17.C b/gcc/testsuite/g++.dg/cpp0x/static_assert17.C
new file mode 100644
index 00000000000..64843c60edd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/static_assert17.C
@@ -0,0 +1,9 @@
+// PR c++/99893
+// { dg-do compile { target c++11 } }
+
+void f(...);
+
+template <class... Ts>
+void g() {
+ f([] { static_assert(Ts::value, ""); }...);
+}
--
2.32.0.rc0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] c++: parameter pack inside static_assert [PR99893]
2021-05-27 15:05 [PATCH] c++: parameter pack inside static_assert [PR99893] Patrick Palka
@ 2021-05-27 17:40 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2021-05-27 17:40 UTC (permalink / raw)
To: Patrick Palka, gcc-patches
On 5/27/21 11:05 AM, Patrick Palka wrote:
> Here, we're not finding the parameter pack inside the static_assert because
> STATIC_ASSERT trees are tcc_exceptional, and we weren't explicitly walking
> them in cp_walk_subtrees.
>
> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for
> trunk?
OK.
> gcc/cp/ChangeLog:
>
> PR c++/99893
> * tree.c (cp_walk_subtrees) <case STATIC_ASSERT>: New case.
>
> gcc/testsuite/ChangeLog:
>
> PR c++/99893
> * g++.dg/cpp0x/static_assert17.C: New test.
> ---
> gcc/cp/tree.c | 5 +++++
> gcc/testsuite/g++.dg/cpp0x/static_assert17.C | 9 +++++++++
> 2 files changed, 14 insertions(+)
> create mode 100644 gcc/testsuite/g++.dg/cpp0x/static_assert17.C
>
> diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
> index 372d89fa9ed..fec5afaa2be 100644
> --- a/gcc/cp/tree.c
> +++ b/gcc/cp/tree.c
> @@ -5446,6 +5446,11 @@ cp_walk_subtrees (tree *tp, int *walk_subtrees_p, walk_tree_fn func,
> }
> break;
>
> + case STATIC_ASSERT:
> + WALK_SUBTREE (STATIC_ASSERT_CONDITION (*tp));
> + WALK_SUBTREE (STATIC_ASSERT_MESSAGE (*tp));
> + break;
> +
> default:
> return NULL_TREE;
> }
> diff --git a/gcc/testsuite/g++.dg/cpp0x/static_assert17.C b/gcc/testsuite/g++.dg/cpp0x/static_assert17.C
> new file mode 100644
> index 00000000000..64843c60edd
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp0x/static_assert17.C
> @@ -0,0 +1,9 @@
> +// PR c++/99893
> +// { dg-do compile { target c++11 } }
> +
> +void f(...);
> +
> +template <class... Ts>
> +void g() {
> + f([] { static_assert(Ts::value, ""); }...);
> +}
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-05-27 17:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-27 15:05 [PATCH] c++: parameter pack inside static_assert [PR99893] Patrick Palka
2021-05-27 17:40 ` 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).