diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 7a61abfa703..592ce95b571 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -24044,10 +24044,6 @@ cp_parser_class_specifier_1 (cp_parser* parser) = parser->in_unbraced_linkage_specification_p; parser->in_unbraced_linkage_specification_p = false; - // Associate constraints with the type. - if (flag_concepts) - type = associate_classtype_constraints (type); - /* Start the class. */ if (nested_name_specifier_p) { @@ -24815,6 +24811,10 @@ cp_parser_class_head (cp_parser* parser, fixup_attribute_variants (type); } + /* Associate constraints with the type. */ + if (flag_concepts) + type = associate_classtype_constraints (type); + /* We will have entered the scope containing the class; the names of base classes should be looked up in that context. For example: diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d9cc7766a59..fc4b9bb7c7f 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -8127,9 +8127,10 @@ canonicalize_expr_argument (tree arg, tsubst_flags_t complain) return canon; } -// A template declaration can be substituted for a constrained -// template template parameter only when the argument is more -// constrained than the parameter. +/* A template declaration can be substituted for a constrained + template template parameter only when the argument is no more + constrained than the parameter. */ + static bool is_compatible_template_arg (tree parm, tree arg) { diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-class2.C b/gcc/testsuite/g++.dg/cpp2a/concepts-class2.C new file mode 100644 index 00000000000..0ed9eb0a386 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-class2.C @@ -0,0 +1,11 @@ +// PR c++/96229 +// { dg-do compile { target c++20 } } + +template concept Int = requires { T{0}; }; +template