From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 25D57392AC36; Sun, 11 Dec 2022 12:36:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 25D57392AC36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670762200; bh=6yHDSHvAS/9p9AtxpQkCRLlb1wIdigUb0Be6OWSHMns=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZWY+agIMhBgmSFHniuBcu5HqPrO1T2xF6sQKwbv+XqfUmyxwfB9PgjeYMAVjvF/j2 kIqsejAXCOgR790EVD1/0WSoW2G/3qiPuNx8AlKjGrFc65W/fv1P7cb1H5GHfSdU6O BSlwuypIp8PUJQ4Wc4I+v0NQzymOfd+DDzw1mp5Q= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/108042] [10/11/12/13 Regression] weakref on an extern decl is incorrectly ignored Date: Sun, 11 Dec 2022 12:36:36 +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: 13.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: WAITING X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cf_reconfirmed_on everconfirmed cc target_milestone bug_status 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108042 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2022-12-11 Ever confirmed|0 |1 CC| |hubicka at gcc dot gnu.org, | |rguenth at gcc dot gnu.org Target Milestone|--- |10.5 Status|UNCONFIRMED |WAITING --- Comment #2 from Richard Biener --- t2.c:1:6: warning: 'weakref' attribute should be accompanied with an 'alias' attribute [-Wattributes] 1 | void KNOWNNOTOBEAFUNCTION(void) __attribute__((weakref)); | ^~~~~~~~~~~~~~~~~~~~ did you want to use __attribute__((weak)) here? I think this works as designed. Note handle_weakref_attribute has /* The idea here is that `weakref("name")' mutates into `weakref, alias("name")', and weakref without arguments, in turn, implicitly adds weak. */ if (args) {=20 attr =3D tree_cons (get_identifier ("alias"), args, attr);=20 attr =3D tree_cons (get_identifier ("weakref"), NULL_TREE, attr); *no_add_attrs =3D true; decl_attributes (node, attr, flags); } else {=20 if (lookup_attribute ("alias", DECL_ATTRIBUTES (*node))) error_at (DECL_SOURCE_LOCATION (*node), "%qE attribute must appear before %qs attribute", name, "alias"); /* Can't call declare_weak because it wants this to be TREE_PUBLIC, and that isn't supported; and because it wants to add it to the list of weak decls, which isn't helpful. */ DECL_WEAK (*node) =3D 1; but then process_common_attributes does tree weakref =3D lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)); if (weakref && !lookup_attribute ("alias", DECL_ATTRIBUTES (decl))) { warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wattributes,=20 "% attribute should be accompanied with" " an % attribute"); DECL_WEAK (decl) =3D 0; DECL_ATTRIBUTES (decl) =3D remove_attribute ("weakref", DECL_ATTRIBUTES (decl)); } this diagnostic does not match the documentation which gives the plain 'weakref' semantics of 'weak'.=