Message ID | 20221020140740.415427-1-ppalka@redhat.com |
---|---|
State | New |
Headers | show |
Series | c++ modules: handle CONCEPT_DECL in node_template_info [PR102963] | expand |
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" }
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" }