From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 75255 invoked by alias); 28 Aug 2015 17:55:38 -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 75192 invoked by uid 55); 28 Aug 2015 17:55:34 -0000 From: "joseph at codesourcery dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/67386] missing diagnostic on a use of an undeclared function Date: Fri, 28 Aug 2015 17:55: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: 5.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: joseph at codesourcery dot com 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: 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-08/txt/msg01964.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67386 --- Comment #1 from joseph at codesourcery dot com --- On Fri, 28 Aug 2015, msebor at gcc dot gnu.org wrote: > GCC isn't completely consistent in diagnosing references to undeclared > functions. In the test case below, it issues an error for only the last three > out of the four definitions of foo. It issues a warning for the first one, > even though it too references an undeclared identifier. This is a consequence of C90 implicit declarations being accepted as an extension in C11 mode. The implicit declaration from the call in the first case is in scope for the non-call reference. In no other case is there a declaration, even implicit, in scope for such a reference. > Versions prior to 5.1 diagnosed only the second and fourth forms. Previous versions defaulted to gnu89. In C99 and later, each half of an if statement has its own scope; before C99, the scope of the implicit declaration in case 3 would have been the whole of the body of the function.