From: cuz Date: Thu, 31 Jul 2008 18:30:33 +0000 (+0000) Subject: Calling an undefined function is an error in C99. X-Git-Tag: V2.12.0~4 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=52c0c284da47ccca97661356975a3927e3ce0cf5;p=cc65 Calling an undefined function is an error in C99. git-svn-id: svn://svn.cc65.org/cc65/trunk@3857 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 6ddb685e5..8ce49b765 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -31,6 +31,7 @@ #include "scanner.h" #include "shiftexpr.h" #include "stackptr.h" +#include "standard.h" #include "stdfunc.h" #include "symtab.h" #include "typecmp.h" @@ -688,11 +689,17 @@ static void Primary (ExprDesc* E) /* IDENT is either an auto-declared function or an undefined variable. */ if (CurTok.Tok == TOK_LPAREN) { - /* Declare a function returning int. For that purpose, prepare a + /* C99 doesn't allow calls to undefined functions, so + * generate an error and otherwise a warning. Declare a + * function returning int. For that purpose, prepare a * function signature for a function having an empty param list * and returning int. */ - Warning ("Function call without a prototype"); + if (IS_Get (&Standard) >= STD_C99) { + Error ("Call to undefined function `%s'", Ident); + } else { + Warning ("Call to undefined function `%s'", Ident); + } Sym = AddGlobalSym (Ident, GetImplicitFuncType(), SC_EXTERN | SC_REF | SC_FUNC); E->Type = Sym->Type; E->Flags = E_LOC_GLOBAL | E_RTYPE_RVAL;