public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103347] [9/10/11/12 Regression] Non-static data member initialization is erroneously allowed in C++03 with assignment to NULL Date: Wed, 24 Nov 2021 05:24:18 +0000 [thread overview] Message-ID: <bug-103347-4-x3SNfFAu1Q@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-103347-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103347 --- Comment #10 from CVS 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:d71d019f63ed5d3fdb34579023bafa4dcf323f2c commit r12-5488-gd71d019f63ed5d3fdb34579023bafa4dcf323f2c Author: Marek Polacek <polacek@redhat.com> Date: Mon Nov 22 14:09:25 2021 -0500 c++: Fix missing NSDMI diagnostic in C++98 [PR103347] Here the problem is that we aren't detecting a NSDMI in C++98: struct A { void *x = NULL; }; because maybe_warn_cpp0x uses input_location and that happens to point to NULL which comes from a system header. Jakub suggested changing the location to the '=', thereby avoiding the system header problem. To that end, I've added a new location_t member into cp_declarator. This member is used when this declarator is part of an init-declarator. The rest of the changes is obvious. I've also taken the liberty of adding loc_or_input_loc, since I want to avoid checking for UNKNOWN_LOCATION. PR c++/103347 gcc/cp/ChangeLog: * cp-tree.h (struct cp_declarator): Add a location_t member. (maybe_warn_cpp0x): Add a location_t parameter with a default argument. (loc_or_input_loc): New. * decl.c (grokdeclarator): Use loc_or_input_loc. Pass init_loc down to maybe_warn_cpp0x. * error.c (maybe_warn_cpp0x): Add a location_t parameter. Use it. * parser.c (make_declarator): Initialize init_loc. (cp_parser_member_declaration): Set init_loc. (cp_parser_condition): Likewise. (cp_parser_init_declarator): Likewise. (cp_parser_parameter_declaration): Likewise. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/nsdmi-warn1.C: New test. * g++.dg/cpp0x/nsdmi-warn1.h: New file.
next prev parent reply other threads:[~2021-11-24 5:24 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-21 12:13 [Bug c++/103347] New: Non-static data member initialization is erroneously allowed in C++03 mode fchelnokov at gmail dot com 2021-11-21 14:50 ` [Bug c++/103347] " pinskia at gcc dot gnu.org 2021-11-21 14:52 ` pinskia at gcc dot gnu.org 2021-11-21 14:54 ` pinskia at gcc dot gnu.org 2021-11-21 17:02 ` redi at gcc dot gnu.org 2021-11-22 9:37 ` pinskia at gcc dot gnu.org 2021-11-22 9:38 ` pinskia at gcc dot gnu.org 2021-11-22 9:47 ` pinskia at gcc dot gnu.org 2021-11-22 9:53 ` [Bug c++/103347] [9/10/11/12 Regression] Non-static data member initialization is erroneously allowed in C++03 with assignment to NULL pinskia at gcc dot gnu.org 2021-11-22 16:43 ` jakub at gcc dot gnu.org 2021-11-22 18:19 ` mpolacek at gcc dot gnu.org 2021-11-24 5:24 ` cvs-commit at gcc dot gnu.org [this message] 2021-11-24 5:26 ` [Bug c++/103347] [9/10/11 " mpolacek at gcc dot gnu.org 2021-12-01 2:51 ` ensadc at mailnesia dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-103347-4-x3SNfFAu1Q@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).