From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D34223AA9C1E; Wed, 21 Apr 2021 08:08:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D34223AA9C1E From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/100130] R section flag handling doesn't cope with intervening decls Date: Wed, 21 Apr 2021 08:08:55 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rsandifo at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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: Wed, 21 Apr 2021 08:08:55 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100130 --- Comment #2 from CVS Commits --- The master branch has been updated by Richard Sandiford : https://gcc.gnu.org/g:b67778b59932fdc64dc89a97550349e973ca0352 commit r12-17-gb67778b59932fdc64dc89a97550349e973ca0352 Author: Richard Sandiford Date: Wed Apr 21 09:08:44 2021 +0100 varasm: Two SECTION_RETAIN fixes [PR100130] switch_to_section warns if we try to output a retain decl in a section without a retain flag, or if we try to output a non-retain decl in a section with a retain flag. However, the warning only applied if we were trying to =C3=A2switch=C3=A2 to the current section. This works if all decls that use a section are generated consecutively, but not if there is an unrelated decl in between. This patch makes the check unconditional, but suppresses the warning if we're writing the section's named.decl (i.e. the decl from which the section name and original flags were derived). Also, the warning didn't fire for -fsection-anchors, for two reasons: we allowed retain and non-retain decls to be put into the same block, and we didn't pass a decl to switch_to_section. Although these are arguably separate bugs, it isn't easy to fix them independently without temporarily regressing -fsection-anchor targets. gcc/ PR middle-end/100130 * varasm.c (get_block_for_decl): Make sure that any use of the retain attribute matches the section's retain flag. (switch_to_section): Check for retain mismatches even when changing sections, but do not warn if the given decl is the section's named.decl. (output_object_block): Pass the first decl in the block (if any) to switch_to_section. gcc/testsuite/ PR middle-end/100130 * c-c++-common/attr-retain-10.c: New test. * c-c++-common/attr-retain-11.c: Likewise.=