(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
tree-ssa/
pr33172.c
       1  /* { dg-do compile } */
       2  /* { dg-options "-O2 -fdump-tree-optimized" } */
       3  
       4  struct abc {
       5      void (*abc_call)(void);
       6  };
       7  
       8  /*
       9   * Use only any one of the three definitions below at a time:
      10   *
      11   * 1. nothing optimized away. Good.
      12   * 2. call_func() _not_ optimized away, but struct xyz is. gcc disappoints.
      13   * 3. both call_func() and struct xyz optimized away. Nice.
      14   */
      15  
      16  /* 1 */
      17  /*extern int do_register(struct abc *xyz);*/
      18  
      19  /* 2 */
      20  static inline int do_register(struct abc *xyz)
      21  {
      22      return 0;
      23  }
      24  
      25  /* 3 */
      26  /*#define do_register(xyz)    do { (void)(xyz); } while (0)*/
      27  
      28  static void call_func(void)
      29  {
      30  }
      31  
      32  static struct abc xyz = {
      33      .abc_call = call_func,
      34  };
      35  
      36  void func(void)
      37  {
      38      do_register(&xyz);
      39  }
      40  
      41  /* { dg-final { scan-tree-dump-not "call_func" "optimized"} } */