diff mbox series

[mips,committed] Wrap ASM_OUTPUT_LABELREF in do {} while (0)

Message ID 260a1abd-a80c-124f-c60d-8935bf90c081@mentor.com
State New
Headers show
Series [mips,committed] Wrap ASM_OUTPUT_LABELREF in do {} while (0) | expand

Commit Message

Tom de Vries Nov. 8, 2017, 9:05 a.m. UTC
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
diff mbox series

Patch

[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)
 
 /* Flag to mark a function decl symbol that requires a long call.  */
 #define SYMBOL_FLAG_LONG_CALL	(SYMBOL_FLAG_MACH_DEP << 0)