(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
analyzer/
null-deref-pr105755.c
       1  /* { dg-additional-options "-Wno-analyzer-too-complex -O2" } */
       2  
       3  typedef long int ptrdiff_t;
       4  typedef long int EMACS_INT;
       5  typedef long int intmax_t;
       6  
       7  enum Lisp_Type
       8    {
       9      Lisp_Symbol = 0,
      10      Lisp_Vectorlike = 5,
      11    };
      12  typedef struct Lisp_X *Lisp_Object;
      13  
      14  static inline EMACS_INT
      15  XLI (Lisp_Object o)
      16  {
      17    return (EMACS_INT) o;
      18  }
      19  
      20  static inline void *
      21  XLP (Lisp_Object o)
      22  {
      23    return (void *) o;
      24  }
      25  
      26  struct Lisp_Symbol
      27  {
      28    Lisp_Object name;
      29    Lisp_Object value;
      30  };
      31  extern struct Lisp_Symbol lispsym[1455];
      32  
      33  union vectorlike_header
      34    {
      35      ptrdiff_t size;
      36    };
      37  static inline _Bool
      38  TAGGEDP (Lisp_Object a, enum Lisp_Type tag)
      39  {
      40    return (! (((unsigned) XLI (a) - (unsigned) (tag)) & 7));
      41  }
      42  
      43  struct Lisp_Symbol_With_Pos
      44  {
      45    union vectorlike_header header;
      46    Lisp_Object sym;
      47    Lisp_Object pos;
      48  };
      49  
      50  static inline _Bool
      51  PSEUDOVECTORP (Lisp_Object a, int code)
      52  {
      53    return (TAGGEDP (a, Lisp_Vectorlike)
      54  	  && ((((union vectorlike_header *)
      55  		((char *) XLP ((a)) - Lisp_Vectorlike))->size
      56  	       & 0x400000003f000000)
      57  	      == (0x4000000000000000 | (code << 24))));
      58  }
      59  
      60  static inline _Bool
      61  BARE_SYMBOL_P (Lisp_Object x)
      62  {
      63    return TAGGEDP (x, Lisp_Symbol);
      64  }
      65  
      66  static inline _Bool
      67  SYMBOL_WITH_POS_P (Lisp_Object x)
      68  {
      69    return PSEUDOVECTORP (x, 6);
      70  }
      71  
      72  static inline struct Lisp_Symbol_With_Pos *
      73  XSYMBOL_WITH_POS (Lisp_Object a)
      74  {
      75    return (struct Lisp_Symbol_With_Pos *) ((char *) XLP (a) - Lisp_Vectorlike);
      76  }
      77  
      78  static inline Lisp_Object
      79  make_lisp_symbol (struct Lisp_Symbol *sym)
      80  {
      81    return (Lisp_Object) ((char *) sym - (char *) lispsym);
      82  }
      83  
      84  static inline Lisp_Object
      85  builtin_lisp_symbol (int index)
      86  {
      87    return make_lisp_symbol (&lispsym[index]);
      88  }
      89  
      90  static inline _Bool
      91  BASE_EQ (Lisp_Object x, Lisp_Object y)
      92  {
      93    return XLI (x) == XLI (y);
      94  }
      95  
      96  extern _Bool symbols_with_pos_enabled;
      97  
      98  static inline _Bool
      99  EQ (Lisp_Object x, Lisp_Object y)
     100  {
     101    return (XLI (x) == XLI (y)
     102  	  || (symbols_with_pos_enabled
     103  	      && (SYMBOL_WITH_POS_P (x)
     104  		  ? (BARE_SYMBOL_P (y)
     105  		     ? XLI (XSYMBOL_WITH_POS(x)->sym) == XLI (y)
     106  		     : (SYMBOL_WITH_POS_P(y)
     107  			&& (XLI (XSYMBOL_WITH_POS(x)->sym)
     108  			    == XLI (XSYMBOL_WITH_POS(y)->sym))))
     109  		  : (SYMBOL_WITH_POS_P (y) && BARE_SYMBOL_P (x)
     110  		     && (XLI (x) == XLI ((XSYMBOL_WITH_POS (y))->sym))))));
     111  }
     112  
     113  static inline _Bool
     114  NILP (Lisp_Object x)
     115  {
     116    return BASE_EQ (x, builtin_lisp_symbol (0));
     117  }
     118  
     119  static inline _Bool
     120  ASCII_CHAR_P (intmax_t c)
     121  {
     122    return 0 <= c && c < 0x80;
     123  }
     124  
     125  struct Lisp_Char_Table
     126    {
     127      union vectorlike_header header;
     128      Lisp_Object defalt;
     129      Lisp_Object parent;
     130      Lisp_Object ascii;
     131  };
     132  
     133  extern Lisp_Object char_table_ref (Lisp_Object, int);
     134  
     135  static inline _Bool
     136  CHAR_TABLE_P (Lisp_Object a)
     137  {
     138    return PSEUDOVECTORP (a, 28);
     139  }
     140  
     141  static inline struct Lisp_Char_Table *
     142  XCHAR_TABLE (Lisp_Object a)
     143  {
     144    return (struct Lisp_Char_Table *) ((char *) XLP (a) - Lisp_Vectorlike);
     145  }
     146  
     147  struct Lisp_Sub_Char_Table
     148  {
     149    union vectorlike_header header;
     150    Lisp_Object contents[];
     151  };
     152  
     153  static inline _Bool
     154  SUB_CHAR_TABLE_P (Lisp_Object a)
     155  {
     156    return PSEUDOVECTORP (a, 29);
     157  }
     158  
     159  static inline struct Lisp_Sub_Char_Table *
     160  XSUB_CHAR_TABLE (Lisp_Object a)
     161  {
     162    return (struct Lisp_Sub_Char_Table *) ((char *) XLP (a) - Lisp_Vectorlike);
     163  }
     164  
     165  static inline Lisp_Object
     166  CHAR_TABLE_REF_ASCII (Lisp_Object ct, ptrdiff_t idx)
     167  {
     168    for (struct Lisp_Char_Table *tbl = XCHAR_TABLE (ct); ;
     169         tbl = XCHAR_TABLE (tbl->parent))
     170      {
     171        Lisp_Object val = (! SUB_CHAR_TABLE_P (tbl->ascii) ? tbl->ascii
     172  			 : XSUB_CHAR_TABLE (tbl->ascii)->contents[idx]);
     173        if (NILP (val))
     174  	val = tbl->defalt;
     175        if (!NILP (val) || NILP (tbl->parent))
     176  	return val;
     177      }
     178  }
     179  
     180  static inline Lisp_Object
     181  CHAR_TABLE_REF (Lisp_Object ct, int idx)
     182  {
     183    return (ASCII_CHAR_P (idx)
     184  	  ? CHAR_TABLE_REF_ASCII (ct, idx)
     185  	  : char_table_ref (ct, idx));
     186  }
     187  
     188  _Bool
     189  word_boundary_p (Lisp_Object char_script_table, int c1, int c2)
     190  {
     191    return EQ (CHAR_TABLE_REF (char_script_table, c1),
     192  	     CHAR_TABLE_REF (char_script_table, c2));
     193  }