public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "joseph at codesourcery dot com" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-67386-4-n6FwpDOaXY@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-67386-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67386

--- Comment #1 from joseph at codesourcery dot com <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.


  reply	other threads:[~2015-08-28 17:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-28 16:21 [Bug c/67386] New: " msebor at gcc dot gnu.org
2015-08-28 17:55 ` joseph at codesourcery dot com [this message]
2015-08-28 23:04 ` [Bug c/67386] " msebor at gcc dot gnu.org
2015-08-30 16:50 ` msebor at gcc dot gnu.org
2015-08-31 10:59 ` joseph at codesourcery dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-67386-4-n6FwpDOaXY@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).