]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++ modules: handle CONCEPT_DECL in node_template_info [PR102963]
authorPatrick Palka <ppalka@redhat.com>
Thu, 20 Oct 2022 15:33:39 +0000 (11:33 -0400)
committerPatrick Palka <ppalka@redhat.com>
Thu, 20 Oct 2022 15:33:39 +0000 (11:33 -0400)
Here node_template_info is overlooking that CONCEPT_DECL has TEMPLATE_INFO
too, which causes get_originating_module_decl for the CONCEPT_DECL to not
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 static assert failure elaboration.

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
gcc/testsuite/g++.dg/modules/concept-7_a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/concept-7_b.C [new file with mode: 0644]

index 2c2f9a9a8cb5233f5a944ae540db0bed1122400b..73971e7ff47388b2f8637fa9fa95c2720a475a9e 100644 (file)
@@ -4046,6 +4046,7 @@ 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) == CONCEPT_DECL
               || TREE_CODE (decl) == TEMPLATE_DECL))
     {
       use_tpl = DECL_USE_TEMPLATE (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 (file)
index 0000000..a39b31b
--- /dev/null
@@ -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 (file)
index 0000000..1f81208
--- /dev/null
@@ -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" }