public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/112482] New: error when auto(x) is used in a variable initializer (block scope) @ 2023-11-11 0:01 mpolacek at gcc dot gnu.org 2023-11-11 0:01 ` [Bug c++/112482] " mpolacek at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: mpolacek at gcc dot gnu.org @ 2023-11-11 0:01 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112482 Bug ID: 112482 Summary: error when auto(x) is used in a variable initializer (block scope) Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mpolacek at gcc dot gnu.org Target Milestone: --- Discovered while working on bug 112410. It's very similar, but the underlying issue is different. // { dg-do compile { target c++23 } } struct A { A(int,int); }; void g (int a) { A b2(auto(a), 42); } $ xg++ -c auto-fncast15.C -std=c++23 auto-fncast15.C: In function ‘void g(int)’: auto-fncast15.C:10:8: error: ‘auto’ parameter not permitted in this context 10 | A b2(auto(a), 42); | ^~~~ ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/112482] error when auto(x) is used in a variable initializer (block scope) 2023-11-11 0:01 [Bug c++/112482] New: error when auto(x) is used in a variable initializer (block scope) mpolacek at gcc dot gnu.org @ 2023-11-11 0:01 ` mpolacek at gcc dot gnu.org 2023-12-14 21:40 ` cvs-commit at gcc dot gnu.org 2023-12-14 21:42 ` mpolacek at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: mpolacek at gcc dot gnu.org @ 2023-11-11 0:01 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112482 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |rejects-valid Status|UNCONFIRMED |ASSIGNED Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org Ever confirmed|0 |1 Last reconfirmed| |2023-11-11 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/112482] error when auto(x) is used in a variable initializer (block scope) 2023-11-11 0:01 [Bug c++/112482] New: error when auto(x) is used in a variable initializer (block scope) mpolacek at gcc dot gnu.org 2023-11-11 0:01 ` [Bug c++/112482] " mpolacek at gcc dot gnu.org @ 2023-12-14 21:40 ` cvs-commit at gcc dot gnu.org 2023-12-14 21:42 ` mpolacek at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2023-12-14 21:40 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112482 --- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>: https://gcc.gnu.org/g:1ae71269890f532a2bb06b84fc49f474c16e230d commit r14-6563-g1ae71269890f532a2bb06b84fc49f474c16e230d Author: Marek Polacek <polacek@redhat.com> Date: Thu Dec 14 12:01:21 2023 -0500 c++: fix parsing with auto(x) at block scope [PR112482] This is sort of like r14-5514, but at block scope. Consider struct A { A(int, int); }; void g (int a) { A bar(auto(a), 42); // not a fn decl } where we emit error: 'auto' parameter not permitted in this context which is bogus -- bar doesn't declare a function, so the auto is OK, but we don't know it till we've seen the second argument. The error comes from grokdeclarator invoked just after we've parsed the auto(a). A possible approach seems to be to delay the auto parameter checking and only check once we know we are indeed dealing with a function declaration. For tparms, we should still emit the error right away. PR c++/112482 gcc/cp/ChangeLog: * decl.cc (grokdeclarator): Do not issue the auto parameter error while tentatively parsing a function parameter. * parser.cc (cp_parser_parameter_declaration_clause): Check it here. gcc/testsuite/ChangeLog: * g++.dg/cpp23/auto-fncast15.C: New test. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/112482] error when auto(x) is used in a variable initializer (block scope) 2023-11-11 0:01 [Bug c++/112482] New: error when auto(x) is used in a variable initializer (block scope) mpolacek at gcc dot gnu.org 2023-11-11 0:01 ` [Bug c++/112482] " mpolacek at gcc dot gnu.org 2023-12-14 21:40 ` cvs-commit at gcc dot gnu.org @ 2023-12-14 21:42 ` mpolacek at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: mpolacek at gcc dot gnu.org @ 2023-12-14 21:42 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112482 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution|--- |FIXED --- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Fixed for GCC 14. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-12-14 21:42 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-11-11 0:01 [Bug c++/112482] New: error when auto(x) is used in a variable initializer (block scope) mpolacek at gcc dot gnu.org 2023-11-11 0:01 ` [Bug c++/112482] " mpolacek at gcc dot gnu.org 2023-12-14 21:40 ` cvs-commit at gcc dot gnu.org 2023-12-14 21:42 ` mpolacek 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).