[Bug preprocessor/81364] Bogus -Wmultistatement-macros warning

hjl.tools at gmail dot com gcc-bugzilla@gcc.gnu.org
Sat Jul 8 22:09:00 GMT 2017


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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-07-08
   Target Milestone|---                         |8.0
     Ever confirmed|0                           |1

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
Another one:

[hjl@gnu-tools-1 tmp]$ cat y.c 
#define TST_DO_REC(rec) \
  for (rec=0; rec < 10; ++rec)

#define TST_FUNC_ISW \
int \
tst_isw##_func_ (int debug_flg) \
{ \
  TST_DO_REC (debug_flg) \
  { \
  } \
}

TST_FUNC_ISW
[hjl@gnu-tools-1 tmp]$
/export/build/gnu/gcc-cet/release/usr/gcc-8.0.0-cet/bin/gcc
-Wmultistatement-macros -S y.c 
y.c: In function ‘tst_isw_func_’:
y.c:9:3: warning: macro expands to multiple statements
[-Wmultistatement-macros]
   { \
   ^
y.c:13:1: note: in expansion of macro ‘TST_FUNC_ISW’
 TST_FUNC_ISW
 ^~~~~~~~~~~~
y.c:2:3: note: some parts of macro expansion are not guarded by this ‘for’
clause
   for (rec=0; rec < 10; ++rec)
   ^
y.c:8:3: note: in expansion of macro ‘TST_DO_REC’
   TST_DO_REC (debug_flg) \
   ^~~~~~~~~~
y.c:13:1: note: in expansion of macro ‘TST_FUNC_ISW’
 TST_FUNC_ISW
 ^~~~~~~~~~~~
[hjl@gnu-tools-1 tmp]$


More information about the Gcc-bugs mailing list