From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 79444 invoked by alias); 26 Feb 2015 17:23:22 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 76198 invoked by uid 48); 26 Feb 2015 17:22:49 -0000 From: "ktietz at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/35330] [4.8/4.9/5 regression] ICE with invalid pragma weak Date: Thu, 26 Feb 2015 18:22:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 4.4.0 X-Bugzilla-Keywords: error-recovery, ice-on-invalid-code, monitored X-Bugzilla-Severity: normal X-Bugzilla-Who: ktietz at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P5 X-Bugzilla-Assigned-To: ktietz at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.8.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-02/txt/msg02957.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=35330 --- Comment #12 from Kai Tietz --- issue seems to be that in declare_weak we don't check that DECL is actually either a function, or a variable declaration. Fix would be to add an error-message in declare_weak (). Index: varasm.c =================================================================== @@ -5398,6 +5399,12 @@ void declare_weak (tree decl) { gcc_assert (TREE_CODE (decl) != FUNCTION_DECL || !TREE_ASM_WRITTEN (decl)); + if (TREE_CODE (decl) != FUNCTION_DECL && TREE_CODE (decl) != VAR_DECL) + { + error ("weak declaration of %q+D has to be either a function," + " or a variable declaration", decl); + return; + } if (! TREE_PUBLIC (decl)) error ("weak declaration of %q+D must be public", decl); else if (!TARGET_SUPPORTS_WEAK)