[PATCH 4/4] Suppress "statement not reached" warnings under Sun Studio
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Dec 21, 2011, 01:18 UTC
- Message-ID
- <1324430302-22441-5-git-send-email-avarab@gmail.com>
- In-Reply-To
- <1324430302-22441-1-git-send-email-avarab@gmail.com>
Sun Studio 12 Update 1's brain will melt on these two occurances of using "goto" to jump into a loop. It'll emit these warnings:
"read-cache.c", line 761: warning: statement not reached (E_STATEMENT_NOT_REACHED)
"xdiff/xutils.c", line 194: warning: statement not reached (E_STATEMENT_NOT_REACHED)Suppress these warnings by using a Sun Studio specific pragma directive to turn them off, but only do so if __sun is defined, which is the macro Sun Studio uses to identify itself under both its C and C++ variants, see http://developers.sun.com/sunstudio/products/faqs/cpp.html
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- read-cache.c | 6 ++++++ xdiff/xutils.c | 6 ++++++ 2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/read-cache.c b/read-cache.c index a51bba1..0a4e895 100644 --- a/read-cache.c +++ b/read-cache.c @@ -758,7 +758,13 @@ int verify_path(const char *path) return 0; goto inside; +#ifdef __sun +# pragma error_messages (off, E_STATEMENT_NOT_REACHED) +#endif for (;;) { +#ifdef __sun +# pragma error_messages (on, E_STATEMENT_NOT_REACHED) +#endif if (!c) return 1; if (is_dir_sep(c)) { diff --git a/xdiff/xutils.c b/xdiff/xutils.c index 0de084e..62c3567 100644 --- a/xdiff/xutils.c +++ b/xdiff/xutils.c @@ -191,7 +191,13 @@ int xdl_recmatch(const char *l1, long s1, const char *l2, long s2, long flags) */ if (flags & XDF_IGNORE_WHITESPACE) { goto skip_ws; +#ifdef __sun +# pragma error_messages (off, E_STATEMENT_NOT_REACHED) +#endif while (i1 < s1 && i2 < s2) { +#ifdef __sun +# pragma error_messages (on, E_STATEMENT_NOT_REACHED) +#endif if (l1[i1++] != l2[i2++]) return 0; skip_ws:
-- 1.7.7.3