From 93fe09cb5fbf68e473d5514adc069d2f6115cc23 Mon Sep 17 00:00:00 2001 From: Carlos O'Donell Date: Sat, 29 Oct 2016 23:45:40 -0400 Subject: Bug 20729: Fix building with -Os. This commit adds a new DIAG_IGNORE_Os_NEEDS_COMMENT which is only enabled when compiling with -Os. This allows developers working on -Os enabled builds to mark false-positive warnings without impacting the warnings emitted at -O2. Then using the new DIAG_IGNORE_Os_NEEDS_COMMENT we fix 6 warnings generated with GCC 5 to get -Os builds working again. --- include/libc-internal.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include') diff --git a/include/libc-internal.h b/include/libc-internal.h index 7a185bbdc7..e4395dd5c5 100644 --- a/include/libc-internal.h +++ b/include/libc-internal.h @@ -111,4 +111,19 @@ extern __typeof (__profile_frequency) __profile_frequency attribute_hidden; #define DIAG_IGNORE_NEEDS_COMMENT(version, option) \ _Pragma (_DIAG_STR (GCC diagnostic ignored option)) +/* Similar to DIAG_IGNORE_NEEDS_COMMENT the following macro ignores the + diagnostic OPTION but only if optimizations for size are enabled. + This is required because different warnings may be generated for + different optimization levels. For example a key piece of code may + only generate a warning when compiled at -Os, but at -O2 you could + still want the warning to be enabled to catch errors. In this case + you would use DIAG_IGNORE_Os_NEEDS_COMMENT to disable the warning + only for -Os. */ +#ifdef __OPTIMIZE_SIZE__ +# define DIAG_IGNORE_Os_NEEDS_COMMENT(version, option) \ + _Pragma (_DIAG_STR (GCC diagnostic ignored option)) +#else +# define DIAG_IGNORE_Os_NEEDS_COMMENT(version, option) +#endif + #endif /* _LIBC_INTERNAL */ -- cgit v1.2.3