From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8727E3858D39; Thu, 30 Dec 2021 19:57:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8727E3858D39 From: "egallager at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/103869] New: better diagnostics surrounding uses of -fms-extensions Date: Thu, 30 Dec 2021 19:57:22 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: diagnostic, documentation X-Bugzilla-Severity: normal X-Bugzilla-Who: egallager at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Dec 2021 19:57:22 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103869 Bug ID: 103869 Summary: better diagnostics surrounding uses of -fms-extensions Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: diagnostic, documentation Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: egallager at gcc dot gnu.org Target Milestone: --- I am putting this under the "C" component because the option is documented under the list of C Dialect Options: https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html#C-Dialect-Options However, it could also be considered a C++ bug as per bug 71283. Let's start with the example code provided for the option: $ cat ms-extensions.c typedef int UOW; struct ABC { UOW UOW; }; $ The manual says, "In C++ code, this allows member names in structures to be similar to previous types declarations." However, when compiling with the C front-end, -Wc++-compat doesn't say anything about -fms-extensions allowing= it, nor does explicitly providing -fms-extensions silence it: $ /usr/local/bin/gcc -c -Wall -Wextra -pedantic -Wshadow -Wc++-compat ms-extensions.c ms-extensions.c:3:7: warning: using 'UOW' as both field and typedef name is invalid in C++ [-Wc++-compat] 3 | UOW UOW; | ^~~ $ /usr/local/bin/gcc -c -Wall -Wextra -pedantic -Wshadow -Wc++-compat -fms-extensions ms-extensions.c ms-extensions.c:3:7: warning: using 'UOW' as both field and typedef name is invalid in C++ [-Wc++-compat] 3 | UOW UOW; | ^~~ $ Meanwhile, with the C++ front-end, the error message only notes -fpermissiv= e as a way to allow it, but not -fms-extensions: $ /usr/local/bin/g++ -c -Wall -Wextra -pedantic -Wshadow ms-extensions.c ms-extensions.c:3:7: error: declaration of 'UOW ABC::UOW' changes meaning of 'UOW' [-fpermissive] 3 | UOW UOW; | ^~~ ms-extensions.c:1:13: note: 'UOW' declared here as 'typedef int UOW' 1 | typedef int UOW; | ^~~ $ -fpermissive turns the error into a warning, but providing -fms-extensions removes even the warning: $ /usr/local/bin/g++ -c -Wall -Wextra -pedantic -Wshadow -fpermissive ms-extensions.c ms-extensions.c:3:7: warning: declaration of 'UOW ABC::UOW' changes meaning= of 'UOW' [-fpermissive] 3 | UOW UOW; | ^~~ ms-extensions.c:1:13: note: 'UOW' declared here as 'typedef int UOW' 1 | typedef int UOW; | ^~~ $ /usr/local/bin/g++ -c -Wall -Wextra -pedantic -Wshadow -fpermissive -fms-extensions ms-extensions.c $ /usr/local/bin/g++ -c -Wall -Wextra -pedantic -Wshadow -fms-extensions ms-extensions.c $ IMO there should be a separate pedwarn even with -fms-extensions controlled= by a separate -Wms-extensions to complain in the -pedantic -fms-extensions cas= e, which could then be disabled with -pedantic -fms-extensions -Wno-ms-extensi= ons (or just -Wno-pedantic), e.g.: $ /usr/local/bin/g++ -c -Wall -Wextra -pedantic -Wshadow -fms-extensions ms-extensions.c ms-extensions.c:3:7: warning: declaration of 'UOW ABC::UOW' is only being allowed due to -fms-extensions [-Wms-extensions] 3 | UOW UOW; | ^~~ ms-extensions.c:1:13: note: 'UOW' declared here as 'typedef int UOW' 1 | typedef int UOW; | ^~~ $ Alternatively, the additional complaint could come from -Wshadow instead. Anyways, there are lots of possibilities here; let's try to come up with a consensus as to what would work best.=