(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
ipa/
pr96040.c
       1  /* { dg-do run } */
       2  /* { dg-options "-O2 -std=c99" } */
       3  
       4  
       5  int puts(const char *);
       6  int snprintf(char *, unsigned long, const char *, ...);
       7  unsigned long strspn(const char *, const char *);
       8  
       9  struct TValue {
      10    union {
      11      long long i;
      12      double n;
      13    } value_;
      14    unsigned char tt_;
      15  };
      16  
      17  static int tostringbuff (struct TValue *num, char *str) {
      18    int len;
      19    if (num->tt_ == 3) {
      20      len = snprintf(str,50,"%lld",num->value_.i);
      21    } else {
      22      len = snprintf(str,50,"%.14g",num->value_.n);
      23      if (str[strspn(str, "-0123456789")] == '\0') {
      24        str[len++] = '.';
      25        str[len++] = '0';
      26      }
      27    }
      28    return len;
      29  }
      30  
      31  void unused (int *buff, struct TValue *num) {
      32    char junk[50];
      33    *buff += tostringbuff(num, junk);
      34  }
      35  
      36  char space[400];
      37  
      38  void addnum2buff (int *buff, struct TValue *num) __attribute__((__noinline__));
      39  void addnum2buff (int *buff, struct TValue *num) {
      40    *buff += tostringbuff(num, space);
      41  }
      42  
      43  int __attribute__((noipa)) check_space (char *s)
      44  {
      45    return (s[0] == '1' && s[1] == '.' && s[2] =='0' && s[3] == '\0');
      46  }
      47  
      48  int main(void) {
      49      int buff = 0;
      50      struct TValue num;
      51      num.value_.n = 1.0;
      52      num.tt_ = 19;
      53      addnum2buff(&buff, &num);
      54      if (!check_space(space))
      55        __builtin_abort ();
      56      return 0;
      57  }