public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96363] New: bogus error with constrained partial specialization
@ 2020-07-28 21:50 nathan at gcc dot gnu.org
2020-07-29 12:04 ` [Bug c++/96363] " ppalka at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: nathan at gcc dot gnu.org @ 2020-07-28 21:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96363
Bug ID: 96363
Summary: bogus error with constrained partial specialization
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: nathan at gcc dot gnu.org
Target Milestone: ---
template <typename T> class TPL;
template <typename T> struct Trait;
template <typename T>
requires (Trait<T>::val == 0)
class TPL<T>; // #1
template <typename T>
requires (Trait<T>::val == 1)
class TPL<T>; // #2 error here
cc1plus -quiet -std=c++20 par.cc
par.cc:11:7: error: ‘TPL<T>’ does not match original declaration
11 | class TPL<T>;
| ^~~~~~
par.cc:1:29: note: original template declaration here
1 | template <typename T> class TPL;
| ^~~
ICBW, but if #2 is rejected, why is #1 accepted. Aren't these just two partial
specializations with different constraints?
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/96363] bogus error with constrained partial specialization
2020-07-28 21:50 [Bug c++/96363] New: bogus error with constrained partial specialization nathan at gcc dot gnu.org
@ 2020-07-29 12:04 ` ppalka at gcc dot gnu.org
2020-07-29 13:32 ` redi at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-07-29 12:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96363
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ppalka at gcc dot gnu.org
--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
PR92944 looks related.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/96363] bogus error with constrained partial specialization
2020-07-28 21:50 [Bug c++/96363] New: bogus error with constrained partial specialization nathan at gcc dot gnu.org
2020-07-29 12:04 ` [Bug c++/96363] " ppalka at gcc dot gnu.org
@ 2020-07-29 13:32 ` redi at gcc dot gnu.org
2022-05-24 16:52 ` ppalka at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2020-07-29 13:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96363
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2020-07-29
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=92944
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Blocks| |67491
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67491
[Bug 67491] [meta-bug] concepts issues
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/96363] bogus error with constrained partial specialization
2020-07-28 21:50 [Bug c++/96363] New: bogus error with constrained partial specialization nathan at gcc dot gnu.org
2020-07-29 12:04 ` [Bug c++/96363] " ppalka at gcc dot gnu.org
2020-07-29 13:32 ` redi at gcc dot gnu.org
@ 2022-05-24 16:52 ` ppalka at gcc dot gnu.org
2022-05-24 16:53 ` ppalka at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-05-24 16:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96363
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mate.kelemen.12 at gmail dot com
--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
*** Bug 105718 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/96363] bogus error with constrained partial specialization
2020-07-28 21:50 [Bug c++/96363] New: bogus error with constrained partial specialization nathan at gcc dot gnu.org
` (2 preceding siblings ...)
2022-05-24 16:52 ` ppalka at gcc dot gnu.org
@ 2022-05-24 16:53 ` ppalka at gcc dot gnu.org
2022-05-25 16:20 ` [Bug c++/96363] bogus error with multiple constrained partial specialization forward declarations ppalka at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-05-24 16:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96363
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |johelegp at gmail dot com
--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
*** Bug 99501 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/96363] bogus error with multiple constrained partial specialization forward declarations
2020-07-28 21:50 [Bug c++/96363] New: bogus error with constrained partial specialization nathan at gcc dot gnu.org
` (3 preceding siblings ...)
2022-05-24 16:53 ` ppalka at gcc dot gnu.org
@ 2022-05-25 16:20 ` ppalka at gcc dot gnu.org
2022-05-26 13:43 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-05-25 16:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96363
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/96363] bogus error with multiple constrained partial specialization forward declarations
2020-07-28 21:50 [Bug c++/96363] New: bogus error with constrained partial specialization nathan at gcc dot gnu.org
` (4 preceding siblings ...)
2022-05-25 16:20 ` [Bug c++/96363] bogus error with multiple constrained partial specialization forward declarations ppalka at gcc dot gnu.org
@ 2022-05-26 13:43 ` cvs-commit at gcc dot gnu.org
2022-05-26 13:45 ` ppalka at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-26 13:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96363
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:97dc78d705a90c1ae83c78a7f2e24942cc3a6257
commit r13-779-g97dc78d705a90c1ae83c78a7f2e24942cc3a6257
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu May 26 09:43:14 2022 -0400
c++: constrained partial spec forward decl [PR96363]
Here during cp_parser_single_declaration for #2, we were calling
associate_classtype_constraints for TPL<T> (the primary template type)
before maybe_process_partial_specialization could get a chance to
notice that we're in fact declaring a distinct constrained partial
spec and not redeclaring the primary template. This caused us to
emit a bogus error about differing constraints b/t the primary template
and #2's constraints. This patch fixes this by moving the call to
associate_classtype_constraints after the call to shadow_tag (which
calls maybe_process_partial_specialization) and adjusting shadow_tag to
use the return value of m_p_p_s.
Moreover, if we later try to define a constrained partial specialization
that's been declared earlier (as in the third testcase), then
maybe_new_partial_specialization correctly notices it's a redeclaration
and returns NULL_TREE. But in this case we also need to update TYPE to
point to the redeclared partial spec (it'll otherwise continue pointing
to the primary template type, eventually leading to a bogus error).
PR c++/96363
gcc/cp/ChangeLog:
* decl.cc (shadow_tag): Use the return value of
maybe_process_partial_specialization.
* parser.cc (cp_parser_single_declaration): Call shadow_tag
before associate_classtype_constraints.
* pt.cc (maybe_new_partial_specialization): Change return type
to bool. Take 'type' argument by mutable reference. Set 'type'
to point to the correct constrained specialization when
appropriate.
(maybe_process_partial_specialization): Adjust accordingly.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-partial-spec12.C: New test.
* g++.dg/cpp2a/concepts-partial-spec12a.C: New test.
* g++.dg/cpp2a/concepts-partial-spec13.C: New test.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/96363] bogus error with multiple constrained partial specialization forward declarations
2020-07-28 21:50 [Bug c++/96363] New: bogus error with constrained partial specialization nathan at gcc dot gnu.org
` (5 preceding siblings ...)
2022-05-26 13:43 ` cvs-commit at gcc dot gnu.org
@ 2022-05-26 13:45 ` ppalka at gcc dot gnu.org
2022-07-21 16:47 ` cvs-commit at gcc dot gnu.org
2022-07-21 16:48 ` ppalka at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-05-26 13:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96363
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |12.2
--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed on trunk so far.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/96363] bogus error with multiple constrained partial specialization forward declarations
2020-07-28 21:50 [Bug c++/96363] New: bogus error with constrained partial specialization nathan at gcc dot gnu.org
` (6 preceding siblings ...)
2022-05-26 13:45 ` ppalka at gcc dot gnu.org
@ 2022-07-21 16:47 ` cvs-commit at gcc dot gnu.org
2022-07-21 16:48 ` ppalka at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-21 16:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96363
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:12d8a4a0fb26729290a184c40956329bb614625f
commit r12-8600-g12d8a4a0fb26729290a184c40956329bb614625f
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu May 26 09:43:14 2022 -0400
c++: constrained partial spec forward decl [PR96363]
Here during cp_parser_single_declaration for #2, we were calling
associate_classtype_constraints for TPL<T> (the primary template type)
before maybe_process_partial_specialization could get a chance to
notice that we're in fact declaring a distinct constrained partial
spec and not redeclaring the primary template. This caused us to
emit a bogus error about differing constraints b/t the primary template
and #2's constraints. This patch fixes this by moving the call to
associate_classtype_constraints after the call to shadow_tag (which
calls maybe_process_partial_specialization) and adjusting shadow_tag to
use the return value of m_p_p_s.
Moreover, if we later try to define a constrained partial specialization
that's been declared earlier (as in the third testcase), then
maybe_new_partial_specialization correctly notices it's a redeclaration
and returns NULL_TREE. But in this case we also need to update TYPE to
point to the redeclared partial spec (it'll otherwise continue pointing
to the primary template type, eventually leading to a bogus error).
PR c++/96363
gcc/cp/ChangeLog:
* decl.cc (shadow_tag): Use the return value of
maybe_process_partial_specialization.
* parser.cc (cp_parser_single_declaration): Call shadow_tag
before associate_classtype_constraints.
* pt.cc (maybe_new_partial_specialization): Change return type
to bool. Take 'type' argument by mutable reference. Set 'type'
to point to the correct constrained specialization when
appropriate.
(maybe_process_partial_specialization): Adjust accordingly.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-partial-spec12.C: New test.
* g++.dg/cpp2a/concepts-partial-spec12a.C: New test.
* g++.dg/cpp2a/concepts-partial-spec13.C: New test.
(cherry picked from commit 97dc78d705a90c1ae83c78a7f2e24942cc3a6257)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/96363] bogus error with multiple constrained partial specialization forward declarations
2020-07-28 21:50 [Bug c++/96363] New: bogus error with constrained partial specialization nathan at gcc dot gnu.org
` (7 preceding siblings ...)
2022-07-21 16:47 ` cvs-commit at gcc dot gnu.org
@ 2022-07-21 16:48 ` ppalka at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-07-21 16:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96363
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #7 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 12.2/13
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-07-21 16:48 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-28 21:50 [Bug c++/96363] New: bogus error with constrained partial specialization nathan at gcc dot gnu.org
2020-07-29 12:04 ` [Bug c++/96363] " ppalka at gcc dot gnu.org
2020-07-29 13:32 ` redi at gcc dot gnu.org
2022-05-24 16:52 ` ppalka at gcc dot gnu.org
2022-05-24 16:53 ` ppalka at gcc dot gnu.org
2022-05-25 16:20 ` [Bug c++/96363] bogus error with multiple constrained partial specialization forward declarations ppalka at gcc dot gnu.org
2022-05-26 13:43 ` cvs-commit at gcc dot gnu.org
2022-05-26 13:45 ` ppalka at gcc dot gnu.org
2022-07-21 16:47 ` cvs-commit at gcc dot gnu.org
2022-07-21 16:48 ` ppalka at gcc dot gnu.org
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).