From 7e80e55b6d12138024d44557ed878fa3c50c6fda Mon Sep 17 00:00:00 2001 From: acqn Date: Sat, 13 Jan 2024 16:40:44 +0800 Subject: [PATCH] Added a warning on implicit int in typedefs. --- src/cc65/declare.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/cc65/declare.c b/src/cc65/declare.c index f93305f01..7f1d8b948 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -2388,16 +2388,26 @@ int ParseDecl (DeclSpec* Spec, Declarator* D, declmode_t Mode) GetFuncDesc (D->Type)->Flags |= FD_OLDSTYLE_INTRET; } - /* For anything that is not a function or typedef, check for an implicit - ** int declaration. + /* For anything that is not a function, check for an implicit int + ** declaration. */ - if (!IsTypeFunc (D->Type) && - (D->StorageClass & SC_TYPEMASK) != SC_TYPEDEF) { - /* If the standard was not set explicitly to C89, print a warning - ** for variables with implicit int type. - */ - if (IS_Get (&Standard) >= STD_C99) { - Warning ("Implicit 'int' is an obsolete feature"); + if (!IsTypeFunc (D->Type) && IsRankInt (D->Type)) { + if ((D->StorageClass & SC_TYPEMASK) != SC_TYPEDEF) { + /* If the standard was not set explicitly to C89, print a warning + ** for variables with implicit int type. + */ + if (IS_Get (&Standard) >= STD_C99) { + Warning ("Implicit 'int' is an obsolete feature"); + } + } else { + /* If the standard was not set explicitly to C89, print a warning + ** for typedefs with implicit int type. + */ + if (IS_Get (&Standard) >= STD_C99) { + Warning ("Type defaults to 'int' in typedef of '%s'", + D->Ident); + Note ("Implicit 'int' is an obsolete feature"); + } } } }