1  #include "analyzer-decls.h"
       2  
       3  #define NULL ((void *)0)
       4  
       5  struct s1
       6  {
       7    int f1;
       8  };
       9  
      10  static struct s1 *p1_glob = NULL;
      11  
      12  void test_1 (struct s1 **pp1, struct s1 *p1_parm)
      13  {
      14    struct s1 *init_p1_glob = p1_glob;
      15  
      16    __analyzer_eval (p1_glob == init_p1_glob); /* { dg-warning "TRUE" } */
      17  
      18    if (!p1_glob)
      19      return;
      20  
      21    __analyzer_eval (p1_glob == init_p1_glob); /* { dg-warning "TRUE" } */
      22    __analyzer_eval (p1_glob != NULL); /* { dg-warning "TRUE" } */
      23  
      24    *pp1 = p1_parm;
      25  
      26    /* The write through *pp1 can't have changed p1_glob, because
      27       we never take a pointer to p1_glob (and it's static to this TU).  */
      28    __analyzer_eval (p1_glob == init_p1_glob); /* { dg-warning "TRUE" } */
      29    __analyzer_eval (p1_glob != NULL); /* { dg-warning "TRUE" } */
      30  }
      31  
      32  struct s2
      33  {
      34    int f1;
      35  };
      36  
      37  static struct s2 *p2_glob = NULL;
      38  
      39  void test_2 (struct s2 **pp2, struct s2 *p2_parm)
      40  {
      41    /* Ensure that p2_glob is modified.  */
      42    p2_glob = __builtin_malloc (sizeof (struct s2));
      43    if (!p2_glob)
      44      return;
      45  
      46    __analyzer_eval (p2_glob != NULL); /* { dg-warning "TRUE" } */
      47  
      48    *pp2 = p2_parm;
      49  
      50    /* The write through *pp2 can't have changed p2_glob, because
      51       we never take a pointer to p2_glob (and it's static to this TU).  */
      52    __analyzer_eval (p2_glob != NULL); /* { dg-warning "TRUE" } */
      53  }
      54  
      55  struct s3
      56  {
      57    int f1;
      58  };
      59  
      60  struct s3 *p3_glob = NULL;
      61  
      62  void test_3 (struct s3 **pp3, struct s3 *p3_parm)
      63  {
      64    p3_glob = __builtin_malloc (sizeof (struct s3));
      65    if (!p3_glob)
      66      return;
      67  
      68    __analyzer_eval (p3_glob != NULL); /* { dg-warning "TRUE" } */
      69  
      70    *pp3 = p3_parm;
      71  
      72    /* The write through *pp3 could have changed p3_glob, because
      73       another TU could take a pointer to p3_glob.  */
      74    __analyzer_eval (p3_glob != NULL); /* { dg-warning "UNKNOWN" } */
      75  }