(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
analyzer/
isatty-1.c
       1  /* { dg-skip-if "" { powerpc*-*-aix* } } */
       2  
       3  #include <errno.h>
       4  #include "analyzer-decls.h"
       5  
       6  extern int isatty(int fd);
       7  extern int close(int fd);
       8  
       9  int test_pass_through (int fd)
      10  {
      11    return isatty (fd);
      12  }
      13  
      14  void test_merging (int fd)
      15  {
      16    isatty (fd);
      17    __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */
      18  }
      19  
      20  int test_outcomes (int fd)
      21  {
      22    errno = 0;
      23    int result = isatty (fd);
      24    switch (result)
      25      {
      26      default:
      27        __analyzer_dump_path (); /* { dg-bogus "path" } */
      28        break;
      29      case 0:
      30        __analyzer_dump_path (); /* { dg-message "path" } */
      31        __analyzer_eval (errno > 0); /* { dg-warning "TRUE" } */
      32        break;
      33      case 1:
      34        __analyzer_dump_path (); /* { dg-message "path" } */
      35        __analyzer_eval (errno == 0); /* { dg-warning "TRUE" } */
      36        break;
      37      }
      38    return result;
      39  }
      40  
      41  int test_isatty_on_invalid_fd (void)
      42  {
      43    errno = 0;
      44    int result = isatty (-1);
      45    __analyzer_eval (result == 0); /* { dg-warning "TRUE" } */
      46    __analyzer_eval (errno > 0); /* { dg-warning "TRUE" } */
      47    return result;
      48  }
      49  
      50  int test_isatty_on_closed_fd (int fd)
      51  {
      52    close (fd);
      53    errno = 0;
      54    int result = isatty (fd);
      55    __analyzer_eval (result == 0); /* { dg-warning "TRUE" } */
      56    __analyzer_eval (errno > 0); /* { dg-warning "TRUE" } */
      57    return result;
      58  }