diff mbox series

c++: parameter pack inside static_assert [PR99893]

Message ID 20210527150517.3398785-1-ppalka@redhat.com
State New
Headers show
Series c++: parameter pack inside static_assert [PR99893] | expand

Commit Message

Patrick Palka May 27, 2021, 3:05 p.m. UTC
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

Comments

Jason Merrill May 27, 2021, 5:40 p.m. UTC | #1
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, ""); }...);
> +}
>
diff mbox series

Patch

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, ""); }...);
+}