1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-22 12:30:41 +00:00

Output warnings for implicit int types if std >= C99.

git-svn-id: svn://svn.cc65.org/cc65/trunk@3361 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2005-01-09 18:03:55 +00:00
parent 9cd0b7705c
commit 5c1bc2d740
3 changed files with 23 additions and 7 deletions

View File

@ -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;

View File

@ -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);
}

View File

@ -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 */