public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102933] New: Can't use CTAD in template argument
@ 2021-10-25 17:11 johelegp at gmail dot com
2021-10-26 12:48 ` [Bug c++/102933] " ppalka at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: johelegp at gmail dot com @ 2021-10-25 17:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102933
Bug ID: 102933
Summary: Can't use CTAD in template argument
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
Target Milestone: ---
See https://godbolt.org/z/P8xq8h9M1.
```C++
template<class T> struct X { T t; };
template<X> void f();
template<class T> void g() {
f<X{T{0}}>();
}
int main() {
g<int>();
}
```
```
<source>: In function 'void g()':
<source>:7:5: error: invalid use of 'X<...auto...>' in template argument
7 | f<X{T{0}}>();
| ^
Compiler returned: 1
```
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/102933] Can't use CTAD in template argument
2021-10-25 17:11 [Bug c++/102933] New: Can't use CTAD in template argument johelegp at gmail dot com
@ 2021-10-26 12:48 ` ppalka at gcc dot gnu.org
2021-10-28 14:46 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-10-26 12:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102933
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
Last reconfirmed| |2021-10-26
Target Milestone|--- |11.3
Status|UNCONFIRMED |ASSIGNED
CC| |ppalka at gcc dot gnu.org
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/102933] Can't use CTAD in template argument
2021-10-25 17:11 [Bug c++/102933] New: Can't use CTAD in template argument johelegp at gmail dot com
2021-10-26 12:48 ` [Bug c++/102933] " ppalka at gcc dot gnu.org
@ 2021-10-28 14:46 ` cvs-commit at gcc dot gnu.org
2021-12-15 19:55 ` cvs-commit at gcc dot gnu.org
2021-12-15 19:55 ` ppalka at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-10-28 14:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102933
--- Comment #1 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:f70f17d03630fd948bc15a646ebe7e784125c4d4
commit r12-4772-gf70f17d03630fd948bc15a646ebe7e784125c4d4
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu Oct 28 10:46:46 2021 -0400
c++: CTAD within template argument [PR102933]
Here when checking for erroneous occurrences of 'auto' inside a template
argument (which is allowed by the concepts TS for class templates),
extract_autos_r picks up the CTAD placeholder for X{T{0}} which causes
check_auto_in_tmpl_args to reject this valid template argument. This
patch fixes this by making extract_autos_r ignore CTAD placeholders.
However, it seems we don't need to call check_auto_in_tmpl_args at all
outside of the concepts TS since using 'auto' as a type-id is otherwise
rejected more generally at parse time. So this patch makes the function
just exit early if !flag_concepts_ts.
Similarly, I think the concepts code paths in do_auto_deduction and
type_uses_auto are only necessary for the concepts TS, so this patch
also restricts these code paths accordingly.
PR c++/102933
gcc/cp/ChangeLog:
* parser.c (cp_parser_simple_type_specifier): Adjust diagnostic
for using auto in parameter declaration.
* pt.c (extract_autos_r): Ignore CTAD placeholders.
(extract_autos): Use range-based for.
(do_auto_deduction): Use extract_autos only for the concepts TS
and not also for standard concepts.
(type_uses_auto): Likewise with for_each_template_parm.
(check_auto_in_tmpl_args): Just return false outside of the
concepts TS. Simplify.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/nontype-class50.C: New test.
* g++.dg/cpp2a/nontype-class50a.C: New test.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/102933] Can't use CTAD in template argument
2021-10-25 17:11 [Bug c++/102933] New: Can't use CTAD in template argument johelegp at gmail dot com
2021-10-26 12:48 ` [Bug c++/102933] " ppalka at gcc dot gnu.org
2021-10-28 14:46 ` cvs-commit at gcc dot gnu.org
@ 2021-12-15 19:55 ` cvs-commit at gcc dot gnu.org
2021-12-15 19:55 ` ppalka at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-12-15 19:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102933
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:76c730cbf051281ff088ec18ee4f89fee4a8305a
commit r11-9387-g76c730cbf051281ff088ec18ee4f89fee4a8305a
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu Oct 28 10:46:46 2021 -0400
c++: CTAD within template argument [PR102933]
Here when checking for erroneous occurrences of 'auto' inside a template
argument (which is allowed by the concepts TS for class templates),
extract_autos_r picks up the CTAD placeholder for X{T{0}} which causes
check_auto_in_tmpl_args to reject this valid template argument. This
patch fixes this by making extract_autos_r ignore CTAD placeholders.
However, it seems we don't need to call check_auto_in_tmpl_args at all
outside of the concepts TS since using 'auto' as a type-id is otherwise
rejected more generally at parse time. So this patch makes the function
just exit early if !flag_concepts_ts.
Similarly, I think the concepts code paths in do_auto_deduction and
type_uses_auto are only necessary for the concepts TS, so this patch
also restricts these code paths accordingly.
PR c++/102933
gcc/cp/ChangeLog:
* parser.c (cp_parser_simple_type_specifier): Adjust diagnostic
for using auto in parameter declaration.
* pt.c (extract_autos_r): Ignore CTAD placeholders.
(extract_autos): Use range-based for.
(do_auto_deduction): Use extract_autos only for the concepts TS
and not also for standard concepts.
(type_uses_auto): Likewise with for_each_template_parm.
(check_auto_in_tmpl_args): Just return false outside of the
concepts TS. Simplify.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/nontype-class50.C: New test.
* g++.dg/cpp2a/nontype-class50a.C: New test.
(cherry picked from commit f70f17d03630fd948bc15a646ebe7e784125c4d4)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/102933] Can't use CTAD in template argument
2021-10-25 17:11 [Bug c++/102933] New: Can't use CTAD in template argument johelegp at gmail dot com
` (2 preceding siblings ...)
2021-12-15 19:55 ` cvs-commit at gcc dot gnu.org
@ 2021-12-15 19:55 ` ppalka at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-12-15 19:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102933
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 11.3/12.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-12-15 19:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-25 17:11 [Bug c++/102933] New: Can't use CTAD in template argument johelegp at gmail dot com
2021-10-26 12:48 ` [Bug c++/102933] " ppalka at gcc dot gnu.org
2021-10-28 14:46 ` cvs-commit at gcc dot gnu.org
2021-12-15 19:55 ` cvs-commit at gcc dot gnu.org
2021-12-15 19:55 ` 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).