* [mips, committed] Wrap ASM_OUTPUT_LABELREF in do {} while (0)
@ 2017-11-08 9:39 Tom de Vries
0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2017-11-08 9:39 UTC (permalink / raw)
To: GCC Patches; +Cc: Matthew Fortune
[-- Attachment #1: Type: text/plain, Size: 554 bytes --]
Hi,
this patch wraps ASM_OUTPUT_LABELREF in a "do {} while (0)".
Without, we can run into a dangling else, generating this kind of warning:
...
$ cat test.c
void bar (int);
int c;
#define barc \
if (c) \
bar (1); \
else \
bar (2)
void
foo (int d)
{
if (d)
barc;
}
$ gcc test.c -S -Wall
test.c: In function âfooâ:
test.c:14:6: warning: suggest explicit braces to avoid ambiguous âelseâ
[-Wparentheses]
if (d)
^
...
Build for mips target.
Committed as obvious.
Thanks,
- Tom
[-- Attachment #2: 0002-mips-Wrap-ASM_OUTPUT_LABELREF-in-do-while-0.patch --]
[-- Type: text/x-patch, Size: 1325 bytes --]
[mips] Wrap ASM_OUTPUT_LABELREF in do {} while (0)
2017-11-07 Tom de Vries <tom@codesourcery.com>
* config/mips/mips.h (ASM_OUTPUT_LABELREF): Wrap in "do {} while (0)".
---
gcc/config/mips/mips.h | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
index c1fcb86..bea2ce8 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.h
@@ -2566,12 +2566,15 @@ typedef struct mips_args {
/* This handles the magic '..CURRENT_FUNCTION' symbol, which means
'the start of the function that this code is output in'. */
-#define ASM_OUTPUT_LABELREF(FILE,NAME) \
- if (strcmp (NAME, "..CURRENT_FUNCTION") == 0) \
- asm_fprintf ((FILE), "%U%s", \
- XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); \
- else \
- asm_fprintf ((FILE), "%U%s", (NAME))
+#define ASM_OUTPUT_LABELREF(FILE,NAME) \
+ do { \
+ if (strcmp (NAME, "..CURRENT_FUNCTION") == 0) \
+ asm_fprintf ((FILE), "%U%s", \
+ XSTR (XEXP (DECL_RTL (current_function_decl), \
+ 0), 0)); \
+ else \
+ asm_fprintf ((FILE), "%U%s", (NAME)); \
+ } while (0)
\f
/* Flag to mark a function decl symbol that requires a long call. */
#define SYMBOL_FLAG_LONG_CALL (SYMBOL_FLAG_MACH_DEP << 0)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-11-08 9:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-08 9:39 [mips, committed] Wrap ASM_OUTPUT_LABELREF in do {} while (0) Tom de Vries
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).