public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c++ modules: handle CONCEPT_DECL in node_template_info [PR102963]
@ 2022-10-20 14:07 Patrick Palka
  2022-10-20 14:51 ` Nathan Sidwell
  0 siblings, 1 reply; 2+ messages in thread
From: Patrick Palka @ 2022-10-20 14:07 UTC (permalink / raw)
  To: gcc-patches; +Cc: jason, nathan, Patrick Palka

Here node_template_info is overlooking that CONCEPT_DECL has TEMPLATE_INFO
too, which makes get_originating_module_decl for the CONCEPT_DECL fail to
return the corresponding TEMPLATE_DECL, which leads to an ICE from
import_entity_index while pretty printing the CONCEPT_DECL's module
suffix as part of the failed static assert diagnostic.

Tested on x86_64-pc-linux-gnu, does this look OK for trunk?

	PR c++/102963

gcc/cp/ChangeLog:

	* module.cc (node_template_info): Handle CONCEPT_DECL.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/concept-7_a.C: New test.
	* g++.dg/modules/concept-7_b.C: New test.
---
 gcc/cp/module.cc                           | 3 ++-
 gcc/testsuite/g++.dg/modules/concept-7_a.C | 7 +++++++
 gcc/testsuite/g++.dg/modules/concept-7_b.C | 7 +++++++
 3 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/modules/concept-7_a.C
 create mode 100644 gcc/testsuite/g++.dg/modules/concept-7_b.C

diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index bb406a5cf01..dfed0a5ef89 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -4046,7 +4046,8 @@ node_template_info (tree decl, int &use)
 	       || TREE_CODE (decl) == TYPE_DECL
 	       || TREE_CODE (decl) == FUNCTION_DECL
 	       || TREE_CODE (decl) == FIELD_DECL
-	       || TREE_CODE (decl) == TEMPLATE_DECL))
+	       || TREE_CODE (decl) == TEMPLATE_DECL
+	       || TREE_CODE (decl) == CONCEPT_DECL))
     {
       use_tpl = DECL_USE_TEMPLATE (decl);
       ti = DECL_TEMPLATE_INFO (decl);
diff --git a/gcc/testsuite/g++.dg/modules/concept-7_a.C b/gcc/testsuite/g++.dg/modules/concept-7_a.C
new file mode 100644
index 00000000000..a39b31bf7f0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/concept-7_a.C
@@ -0,0 +1,7 @@
+// PR c++/102963
+// { dg-additional-options "-fmodules-ts -fconcepts" }
+// { dg-module-cmi pr102963 }
+
+export module pr102963;
+
+export template<class T> concept C = __is_same(T, int);
diff --git a/gcc/testsuite/g++.dg/modules/concept-7_b.C b/gcc/testsuite/g++.dg/modules/concept-7_b.C
new file mode 100644
index 00000000000..1f81208ebd5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/concept-7_b.C
@@ -0,0 +1,7 @@
+// PR c++/102963
+// { dg-additional-options "-fmodules-ts -fconcepts" }
+
+import pr102963;
+
+static_assert(C<int>);
+static_assert(C<void>); // { dg-error "static assert" }
-- 
2.38.1.130.g45c9f05c44


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] c++ modules: handle CONCEPT_DECL in node_template_info [PR102963]
  2022-10-20 14:07 [PATCH] c++ modules: handle CONCEPT_DECL in node_template_info [PR102963] Patrick Palka
@ 2022-10-20 14:51 ` Nathan Sidwell
  0 siblings, 0 replies; 2+ messages in thread
From: Nathan Sidwell @ 2022-10-20 14:51 UTC (permalink / raw)
  To: Patrick Palka, gcc-patches; +Cc: jason

On 10/20/22 10:07, Patrick Palka wrote:
> Here node_template_info is overlooking that CONCEPT_DECL has TEMPLATE_INFO
> too, which makes get_originating_module_decl for the CONCEPT_DECL fail to
> return the corresponding TEMPLATE_DECL, which leads to an ICE from
> import_entity_index while pretty printing the CONCEPT_DECL's module
> suffix as part of the failed static assert diagnostic.

ok

> 
> Tested on x86_64-pc-linux-gnu, does this look OK for trunk?
> 
> 	PR c++/102963
> 
> gcc/cp/ChangeLog:
> 
> 	* module.cc (node_template_info): Handle CONCEPT_DECL.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* g++.dg/modules/concept-7_a.C: New test.
> 	* g++.dg/modules/concept-7_b.C: New test.
> ---
>   gcc/cp/module.cc                           | 3 ++-
>   gcc/testsuite/g++.dg/modules/concept-7_a.C | 7 +++++++
>   gcc/testsuite/g++.dg/modules/concept-7_b.C | 7 +++++++
>   3 files changed, 16 insertions(+), 1 deletion(-)
>   create mode 100644 gcc/testsuite/g++.dg/modules/concept-7_a.C
>   create mode 100644 gcc/testsuite/g++.dg/modules/concept-7_b.C
> 
> diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
> index bb406a5cf01..dfed0a5ef89 100644
> --- a/gcc/cp/module.cc
> +++ b/gcc/cp/module.cc
> @@ -4046,7 +4046,8 @@ node_template_info (tree decl, int &use)
>   	       || TREE_CODE (decl) == TYPE_DECL
>   	       || TREE_CODE (decl) == FUNCTION_DECL
>   	       || TREE_CODE (decl) == FIELD_DECL
> -	       || TREE_CODE (decl) == TEMPLATE_DECL))
> +	       || TREE_CODE (decl) == TEMPLATE_DECL
> +	       || TREE_CODE (decl) == CONCEPT_DECL))
>       {
>         use_tpl = DECL_USE_TEMPLATE (decl);
>         ti = DECL_TEMPLATE_INFO (decl);
> diff --git a/gcc/testsuite/g++.dg/modules/concept-7_a.C b/gcc/testsuite/g++.dg/modules/concept-7_a.C
> new file mode 100644
> index 00000000000..a39b31bf7f0
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/modules/concept-7_a.C
> @@ -0,0 +1,7 @@
> +// PR c++/102963
> +// { dg-additional-options "-fmodules-ts -fconcepts" }
> +// { dg-module-cmi pr102963 }
> +
> +export module pr102963;
> +
> +export template<class T> concept C = __is_same(T, int);
> diff --git a/gcc/testsuite/g++.dg/modules/concept-7_b.C b/gcc/testsuite/g++.dg/modules/concept-7_b.C
> new file mode 100644
> index 00000000000..1f81208ebd5
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/modules/concept-7_b.C
> @@ -0,0 +1,7 @@
> +// PR c++/102963
> +// { dg-additional-options "-fmodules-ts -fconcepts" }
> +
> +import pr102963;
> +
> +static_assert(C<int>);
> +static_assert(C<void>); // { dg-error "static assert" }

-- 
Nathan Sidwell


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-20 14:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-20 14:07 [PATCH] c++ modules: handle CONCEPT_DECL in node_template_info [PR102963] Patrick Palka
2022-10-20 14:51 ` Nathan Sidwell

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).