From ce0f237c7561ffb526c85f89844b1fb483d924fe Mon Sep 17 00:00:00 2001 From: Dan White Date: Tue, 14 May 2013 13:16:32 -0500 Subject: [PATCH] msp4th: macro to suppress pointer size cast warnings --- msp4th/msp4th.c | 12 ++++++++++++ msp4th/msp4th.h | 25 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/msp4th/msp4th.c b/msp4th/msp4th.c index 432ea15..d81ce65 100644 --- a/msp4th/msp4th.c +++ b/msp4th/msp4th.c @@ -1380,13 +1380,17 @@ void execN(int16_t opcode) case 59: // call0 ( &func -- *func() ) i = TOS; +GCC_DIAG_OFF(int-to-pointer-cast); TOS = (*(int16_t(*)(void)) i) (); +GCC_DIAG_ON(int-to-pointer-cast); break; case 60: // call1 ( a &func -- *func(a) ) i = TOS; j = NOS; +GCC_DIAG_OFF(int-to-pointer-cast); NOS = (*(int16_t(*)(int16_t)) i) (j); +GCC_DIAG_ON(int-to-pointer-cast); popMathStack(); break; @@ -1394,7 +1398,9 @@ void execN(int16_t opcode) i = TOS; j = NOS; k = STACK(2); +GCC_DIAG_OFF(int-to-pointer-cast); STACK(2) = (*(int16_t(*)(int16_t, int16_t)) i) (k, j); +GCC_DIAG_ON(int-to-pointer-cast); TOS = 1; ndropFunc(); break; @@ -1404,7 +1410,9 @@ void execN(int16_t opcode) j = NOS; k = STACK(2); m = STACK(3); +GCC_DIAG_OFF(int-to-pointer-cast); STACK(3) = (*(int16_t(*)(int16_t, int16_t, int16_t)) i) (m, k, j); +GCC_DIAG_ON(int-to-pointer-cast); TOS = 2; ndropFunc(); break; @@ -1415,7 +1423,9 @@ void execN(int16_t opcode) k = STACK(2); m = STACK(3); n = STACK(4); +GCC_DIAG_OFF(int-to-pointer-cast); STACK(4) = (*(int16_t(*)(int16_t, int16_t, int16_t, int16_t)) i) (n, m, k, j); +GCC_DIAG_ON(int-to-pointer-cast); TOS = 3; ndropFunc(); break; @@ -1501,7 +1511,9 @@ void execN(int16_t opcode) case 76: // init ( &config -- ) \ clears buffers and calls msp4th_init *lineBuffer = 0; // if location is same, the call is recursive otherwise +GCC_DIAG_OFF(int-to-pointer-cast); msp4th_init((struct msp4th_config *)popMathStack()); +GCC_DIAG_ON(int-to-pointer-cast); break; case 77: // o2w ( opcode -- ) \ leaves name of opcode in wordBuffer diff --git a/msp4th/msp4th.h b/msp4th/msp4th.h index 2abd4f5..7297f41 100644 --- a/msp4th/msp4th.h +++ b/msp4th/msp4th.h @@ -24,4 +24,29 @@ struct msp4th_config { void msp4th_init(struct msp4th_config *); void msp4th_processLoop(void); +/* Suppress specific warnings (callX words use function pointers) + * + * from: + * Suppressing GCC Warnings, by Patrick Horgan + * http://dbp-consulting.com/tutorials/SuppressingGCCWarnings.html + */ + +#if !defined(MSP430) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402 +#define GCC_DIAG_STR(s) #s +#define GCC_DIAG_JOINSTR(x,y) GCC_DIAG_STR(x ## y) +# define GCC_DIAG_DO_PRAGMA(x) _Pragma (#x) +# define GCC_DIAG_PRAGMA(x) GCC_DIAG_DO_PRAGMA(GCC diagnostic x) +# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406 +# define GCC_DIAG_OFF(x) GCC_DIAG_PRAGMA(push) \ + GCC_DIAG_PRAGMA(ignored GCC_DIAG_JOINSTR(-W,x)) +# define GCC_DIAG_ON(x) GCC_DIAG_PRAGMA(pop) +# else +# define GCC_DIAG_OFF(x) GCC_DIAG_PRAGMA(ignored GCC_DIAG_JOINSTR(-W,x)) +# define GCC_DIAG_ON(x) GCC_DIAG_PRAGMA(warning GCC_DIAG_JOINSTR(-W,x)) +# endif +#else +# define GCC_DIAG_OFF(x) +# define GCC_DIAG_ON(x) +#endif + #endif -- 2.25.1