https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81364

            Bug ID: 81364
           Summary: Bogus -Wmultistatement-macros warning
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: preprocessor
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
                CC: polacek at redhat dot com
  Target Milestone: ---

[hjl@gnu-tools-1 tmp]$ cat x.c
#define  TST_IF_RETURN(_s_func_) \
 if (_s_func_) \
 { \
 }  \
 else

#define TST_FUNC_ISW(_FUNC_, _func_) \
int \
tst_isw##_func_ (int debug_flg) \
{ \
  TST_IF_RETURN (_FUNC_) \
  { \
  } \
}

extern int LOWER;

TST_FUNC_ISW (LOWER, lower);
[hjl@gnu-tools-1 tmp]$
/export/build/gnu/gcc-cet/release/usr/gcc-8.0.0-cet/bin/gcc
-Wmultistatement-macros -S x.c 
x.c: In function ‘tst_iswlower’:
x.c:12:3: warning: macro expands to multiple statements
[-Wmultistatement-macros]
   { \
   ^
x.c:18:1: note: in expansion of macro ‘TST_FUNC_ISW’
 TST_FUNC_ISW (LOWER, lower);
 ^~~~~~~~~~~~
x.c:5:2: note: some parts of macro expansion are not guarded by this ‘else’
clause
  else
  ^
x.c:11:3: note: in expansion of macro ‘TST_IF_RETURN’
   TST_IF_RETURN (_FUNC_) \
   ^~~~~~~~~~~~~
x.c:18:1: note: in expansion of macro ‘TST_FUNC_ISW’
 TST_FUNC_ISW (LOWER, lower);
 ^~~~~~~~~~~~
[hjl@gnu-tools-1 tmp]$

Reply via email to