PVS-Studio tool complained about this and it's right, macros shouldn't expand
to multiple statements like this.

Bootstrapped/regtested on x86_64-linux, applying to trunk.

2017-03-20  Marek Polacek  <pola...@redhat.com>

        PR sanitizer/80063
        * asan.c (DEF_SANITIZER_BUILTIN): Use do { } while (0).

diff --git gcc/asan.c gcc/asan.c
index edcc6ea..a13679d 100644
--- gcc/asan.c
+++ gcc/asan.c
@@ -2567,10 +2567,12 @@ initialize_sanitizer_builtins (void)
 #define DEF_BUILTIN_STUB(ENUM, NAME)
 #undef DEF_SANITIZER_BUILTIN
 #define DEF_SANITIZER_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
-  decl = add_builtin_function ("__builtin_" NAME, TYPE, ENUM,          \
-                              BUILT_IN_NORMAL, NAME, NULL_TREE);       \
-  set_call_expr_flags (decl, ATTRS);                                   \
-  set_builtin_decl (ENUM, decl, true);
+  do {                                                                 \
+    decl = add_builtin_function ("__builtin_" NAME, TYPE, ENUM,                
\
+                                BUILT_IN_NORMAL, NAME, NULL_TREE);     \
+    set_call_expr_flags (decl, ATTRS);                                 \
+    set_builtin_decl (ENUM, decl, true);                               \
+  } while (0);
 
 #include "sanitizer.def"
 

        Marek

Reply via email to