Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Abstract Syntax Tree for C programs Date: Tue, 04 Jun 2019 14:46:59 -0700 Organization: None to speak of Lines: 33 Message-ID: References: <475067fe-369c-4246-84a1-05b1a3a0c6be@googlegroups.com> <5dd4672f-a571-40bc-bb1a-c14f6c631eb7@googlegroups.com> <8d90e6a8-097d-4573-a88a-1f5f56dda26d@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="a9f7c3b5d2b438cdfd64a899e3119473"; logging-data="13029"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18UycIysso0zlyeseHJEFOR" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:UPRN7AuxKq5+xoLsjY71FRJgb14= sha1:nNwUYv6kzXWNBWXzwtIYJPcyAH4= Xref: csiph.com comp.lang.c:144432 James Kuyper writes: > On Tuesday, June 4, 2019 at 6:24:44 AM UTC-4, Bart wrote: [...] >> How difficult can it be? For example: >> >> int main (void) { >> fn(1,2,3,4); >> fn("hello world"); >> } >> >> There are no declarations of 'fn' visible; should this code pass or >> fail? Apparently gcc passes this unless I do: > > It should pass, if you're compiling for a language like C90 or Gnu90 > which does not require functions to be declared in advance. It should > fail if compiling for a language like C99 or any version of C++ where > functions are required to be declared in advance. If you refuse to tell > gcc which of those languages you want it to compile, how can you > reasonably expect it to guess? The developers of gcc being also the > developers of GnuC, that is, quite reasonably, the language that it > compiles by default. Just to be clear, none of the differences between ISO C and GNU C are relevant to this example. In both C90 and GNU C90, the program does not require a compile-time diagnostic but its run-time behavior is undefined. In C99, C11, GNU C99, and GNU C11, a diagnostic is required, and recent versions of gcc do in fact emit a diagnostic, even in default mode. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */