From: borutr Date: Fri, 24 Nov 2006 20:01:34 +0000 (+0000) Subject: * src/SDCC.y: enabled compilation of empty source file X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=c34489596731dbac89d1f3c42c583b9649f54e6e;p=fw%2Fsdcc * src/SDCC.y: enabled compilation of empty source file * support/Util/SDCCerr.[ch]: added sdcc warning 190 - "ISO C forbids an empty source file" * device/lib/_startup.c, device/lib/printf_tiny.c: disable warning 190 if all the code is ifdefed out. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4483 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/device/lib/_startup.c b/device/lib/_startup.c index ab2d4d58..0f9995d9 100644 --- a/device/lib/_startup.c +++ b/device/lib/_startup.c @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------- - _startup.c - startup routine for sdcc + _startup.c - startup routine for sdcc Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999) @@ -7,19 +7,19 @@ under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - + You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - + In other words, you are welcome to use, share and improve this program. You are forbidden to forbid anyone else to use, share and improve - what you give them. Help stamp out software-hoarding! + what you give them. Help stamp out software-hoarding! -------------------------------------------------------------------------*/ /* External startup code can be written in C @@ -34,5 +34,9 @@ unsigned char _sdcc_external_startup () return 0; } -#endif +#else + +/* Disable "ISO C forbids an empty source file" wraning message */ +#pragma disable_warning 190 +#endif diff --git a/device/lib/printf_tiny.c b/device/lib/printf_tiny.c index 46ef05fb..4d854385 100644 --- a/device/lib/printf_tiny.c +++ b/device/lib/printf_tiny.c @@ -22,7 +22,7 @@ * interrupt routine). Code size is under 270 bytes. Only one library * function is called (_gptrget, 41 bytes), in addition to calls to * putchar(). - * + * * Five simple formats are supported * * %d signed 16 bit integer decimal (-32768 to 32767) @@ -33,7 +33,7 @@ * * For a more complete printf that supports longs, floating point and * field width, try using printf_fast() or printf_large(). - */ + */ // This removes the negative number code, causing "%d" to be the same @@ -61,6 +61,9 @@ #warning "printf_tiny not built, does not support --xstack" #elif defined(_SDCC_NO_ASM_LIB_FUNCS) #warning "printf_tiny not built, _SDCC_NO_ASM_LIB_FUNCS defined" +#else +/* Disable "ISO C forbids an empty source file" wraning message */ +#pragma disable_warning 190 #endif #else // defines are compatible with printf_tiny diff --git a/src/SDCC.y b/src/SDCC.y index 49788ecb..db108592 100644 --- a/src/SDCC.y +++ b/src/SDCC.y @@ -133,8 +133,16 @@ bool uselessDecl = TRUE; %% file + : /* empty */ + { if (!options.lessPedantic) + werror(W_EMPTY_SOURCE_FILE); + } + | program + ; + +program : external_definition - | file external_definition + | program external_definition ; external_definition diff --git a/support/Util/SDCCerr.c b/support/Util/SDCCerr.c index 6839b417..08240025 100644 --- a/support/Util/SDCCerr.c +++ b/support/Util/SDCCerr.c @@ -432,6 +432,8 @@ struct "flexible array member not at end of struct" }, { E_FLEXARRAY_INEMPTYSTRCT, ERROR_LEVEL_ERROR, "flexible array in otherwise empty struct" }, +{ W_EMPTY_SOURCE_FILE, ERROR_LEVEL_WARNING, + "ISO C forbids an empty source file" }, }; /* diff --git a/support/Util/SDCCerr.h b/support/Util/SDCCerr.h index c1e357ee..927998cc 100644 --- a/support/Util/SDCCerr.h +++ b/support/Util/SDCCerr.h @@ -205,6 +205,7 @@ SDCCERR - SDCC Standard error handler #define W_C89_NO_FLEXARRAY 187 /* ISO C90 does not support flexible array members */ #define E_FLEXARRAY_NOTATEND 188 /* flexible array member not at end of struct */ #define E_FLEXARRAY_INEMPTYSTRCT 189 /* flexible array in otherwise empty struct */ +#define W_EMPTY_SOURCE_FILE 190 /* ISO C forbids an empty source file */ #define MAX_ERROR_WARNING 256 /* size of disable warnings array */