1  /* PR c/80116 */
       2  /* { dg-options "-Wmultistatement-macros" } */
       3  /* { dg-do compile } */
       4  
       5  #define SWAP(X, Y)	\
       6    tmp = X; /* { dg-warning "macro expands to multiple statements" } */ \
       7    X = Y;		\
       8    Y = tmp
       9  
      10  #define STUFF		\
      11    if (0) {} else x = y
      12  
      13  #define STUFF2		\
      14    if (0) {} else x = y; x++
      15  
      16  #define STUFF3		\
      17    if (x)		\
      18      {}			\
      19    else /* { dg-message "not guarded by this 'else' clause" } */ \
      20      SWAP(x, y) /* { dg-message "in expansion of macro .SWAP." } */
      21  
      22  #define SET(X, Y)	\
      23    (X) = (Y)
      24  
      25  #define STUFF4		\
      26    if (x)		\
      27      {}			\
      28    else			\
      29      SET(x, y);		\
      30    SET(x, y)
      31  
      32  #define STUFF5		\
      33    { tmp = x; x = y; }
      34  
      35  #define STUFF6		\
      36    x++;;
      37  
      38  int x, y, tmp;
      39  
      40  void
      41  fn1 (void)
      42  {
      43    if (x)
      44     {
      45     }
      46    else /* { dg-message "not guarded by this 'else' clause" } */
      47      SWAP(x, y); /* { dg-message "in expansion of macro .SWAP." } */
      48  }
      49  
      50  void
      51  fn2 (void)
      52  {
      53    SWAP(x, y);
      54  }
      55  
      56  void
      57  fn3 (void)
      58  {
      59    if (x)
      60      {
      61      }
      62    else
      63      {
      64        SWAP(x, y);
      65      }
      66  }
      67  
      68  void
      69  fn4 (void)
      70  {
      71    if (x)
      72      {
      73      }
      74    else
      75      ({ x = 10; x++; });
      76  }
      77  
      78  void
      79  fn5 (void)
      80  {
      81    if (x)
      82      {
      83      }
      84    else /* { dg-message "not guarded by this 'else' clause" } */
      85  L1:
      86      SWAP (x, y); /* { dg-message "in expansion of macro .SWAP." } */
      87    goto L1;
      88  }
      89  
      90  void
      91  fn6 (void)
      92  {
      93    if (x)
      94      {
      95      }
      96    else
      97      SET (x, y);
      98    SET (tmp, x);
      99  }
     100  
     101  void
     102  fn7 (void)
     103  {
     104    STUFF;
     105  }
     106  
     107  void
     108  fn8 (void)
     109  {
     110    STUFF2;
     111  }
     112  
     113  void
     114  fn9 (void)
     115  {
     116    STUFF3; /* { dg-message "in expansion of macro .STUFF3." } */
     117  }
     118  
     119  void
     120  fn10 (void)
     121  {
     122    STUFF4;
     123  }
     124  
     125  void
     126  fn11 (void)
     127  {
     128    if (x)
     129      STUFF5;
     130  }
     131  
     132  void
     133  fn12 (void)
     134  {
     135    if (x)
     136      STUFF6;
     137  }