diff --git a/src/cc65/compile.c b/src/cc65/compile.c index bfec3eda5..411c31357 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -151,7 +151,10 @@ static void Parse (void) SymFlags = Spec.StorageClass; if (IsTypeFunc (Decl.Type)) { SymFlags |= SC_FUNC; - } else { + } else if ((SymFlags & SC_TYPEDEF) == 0) { + if ((Spec.Flags & DS_DEF_TYPE) != 0 && IS_Get (&Standard) >= STD_C99) { + Warning ("Implicit `int' is an obsolete feature"); + } if (NeedStorage) { /* We will allocate storage, variable is defined */ SymFlags |= SC_STORAGE | SC_DEF; diff --git a/src/cc65/declare.c b/src/cc65/declare.c index 44b8ddf05..1ba1ace6c 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 1998-2004 Ullrich von Bassewitz */ +/* (C) 1998-2005 Ullrich von Bassewitz */ /* Römerstraße 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -843,7 +843,12 @@ static FuncDesc* ParseFuncDecl (const DeclSpec* Spec) if ((Spec->Flags & DS_DEF_TYPE) != 0 && Spec->Type[0] == T_INT && Spec->Type[1] == T_END) { - /* Function has an implicit int return */ + /* Function has an implicit int return. Output a warning if we don't + * have the C89 standard enabled explicitly. + */ + if (IS_Get (&Standard) >= STD_C99) { + Warning ("Implicit `int' return type is an obsolete feature"); + } F->Flags |= FD_OLDSTYLE_INTRET; } @@ -906,9 +911,9 @@ static unsigned FunctionModifierFlags (void) /* Get the flag bit for the next token */ unsigned F = FD_NONE; switch (CurTok.Tok) { - case TOK_FASTCALL: F = FD_FASTCALL; break; - case TOK_NEAR: F = FD_NEAR; break; - case TOK_FAR: F = FD_FAR; break; + case TOK_FASTCALL: F = FD_FASTCALL; break; + case TOK_NEAR: F = FD_NEAR; break; + case TOK_FAR: F = FD_FAR; break; default: Internal ("Unexpected token: %d", CurTok.Tok); } diff --git a/src/cc65/locals.c b/src/cc65/locals.c index 80f27cd71..b4afef0f6 100644 --- a/src/cc65/locals.c +++ b/src/cc65/locals.c @@ -49,6 +49,7 @@ #include "loadexpr.h" #include "locals.h" #include "stackptr.h" +#include "standard.h" #include "symtab.h" #include "typeconv.h" @@ -379,7 +380,7 @@ static unsigned ParseStaticDecl (Declaration* Decl, unsigned* SC) static void ParseOneDecl (const DeclSpec* Spec) /* Parse one variable declaration */ { - unsigned SC; /* Storage class for symbol */ + unsigned SC; /* Storage class for symbol */ unsigned SymData = 0; /* Symbol data (offset, label name, ...) */ Declaration Decl; /* Declaration data structure */ @@ -432,6 +433,13 @@ static void ParseOneDecl (const DeclSpec* Spec) } else { Internal ("Invalid storage class in ParseOneDecl: %04X", SC); } + + /* If the standard was not set explicitly to C89, print a warning + * for variables with implicit int type. + */ + if ((Spec->Flags & DS_DEF_TYPE) != 0 && IS_Get (&Standard) >= STD_C99) { + Warning ("Implicit `int' is an obsolete feature"); + } } /* If the symbol is not marked as external, it will be defined now */