(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
arm/
pr59858.c
       1  /* { dg-do compile } */
       2  /* { dg-options "-march=armv5te -fno-builtin -mfloat-abi=soft -mthumb -fno-stack-protector -Os -fno-tree-loop-optimize -fno-tree-dominator-opts -fPIC -w" } */
       3  /* { dg-require-effective-target fpic } */
       4  /* { dg-skip-if "Incompatible command line options: -mfloat-abi=soft -mfloat-abi=hard" { *-*-* } { "-mfloat-abi=hard" } { "" } } */
       5  /* { dg-require-effective-target arm_arch_v5te_thumb_ok } */
       6  
       7  typedef enum {
       8   REG_ENOSYS = -1,
       9  } reg_errcode_t;
      10  typedef unsigned long int bitset_word_t;
      11  typedef bitset_word_t bitset_t[(256 / (sizeof (bitset_word_t) * 8))];
      12  typedef bitset_word_t *re_bitset_ptr_t;
      13  typedef const bitset_word_t *re_const_bitset_ptr_t;
      14  typedef struct {
      15   int nelem;
      16   int *elems;
      17  } re_node_set;
      18  typedef enum {
      19   CHARACTER = 1,
      20  } re_token_type_t;
      21  typedef struct {
      22   re_token_type_t type:8;
      23   unsigned int word_char:1;
      24  } re_token_t;
      25  struct re_string_t {
      26   const unsigned char *raw_mbs;
      27   int raw_mbs_idx;
      28   int cur_idx;
      29   unsigned int tip_context;
      30   re_const_bitset_ptr_t word_char;
      31  };
      32  typedef struct re_string_t re_string_t;
      33  typedef struct re_dfa_t re_dfa_t;
      34  struct re_dfastate_t {
      35   re_node_set nodes;
      36  };
      37  typedef struct re_dfastate_t re_dfastate_t;
      38  typedef struct {
      39   re_dfastate_t **array;
      40  } state_array_t;
      41  typedef struct {
      42   state_array_t path;
      43  } re_sub_match_last_t;
      44  typedef struct {
      45   int nlasts;
      46   re_sub_match_last_t **lasts;
      47  } re_sub_match_top_t;
      48  typedef struct {
      49   re_string_t input;
      50   const re_dfa_t *dfa;
      51   int nsub_tops;
      52   re_sub_match_top_t **sub_tops;
      53  } re_match_context_t;
      54  struct re_dfa_t {
      55   re_token_t *nodes;
      56   re_bitset_ptr_t sb_char;
      57   int mb_cur_max;
      58   bitset_t word_char;
      59  } bracket_elem_t;
      60  static reg_errcode_t
      61  re_string_reconstruct (
      62   re_string_t * pstr,
      63   int idx,
      64   int eflags
      65  )
      66  {
      67   int offset = idx - pstr->raw_mbs_idx;
      68   int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1];
      69   pstr->tip_context = ((pstr->word_char[c] & ((bitset_word_t) 1)) ? : (c));
      70  }
      71  
      72  static void match_ctx_clean (
      73   re_match_context_t *
      74  );
      75  static int check_matching (
      76  );
      77  static re_dfastate_t *transit_state (
      78  );
      79  static int build_trtable (
      80  );
      81  re_search_internal (int eflags
      82  )
      83  {
      84   reg_errcode_t err;
      85   int incr;
      86   int
      87    match_first,
      88    match_last = -1;
      89   re_match_context_t mctx;
      90   err = re_string_allocate (&mctx.input);
      91   for (;; match_first += incr)
      92    {
      93     err = re_string_reconstruct (&mctx.input, match_first, eflags);
      94     err = re_string_reconstruct (&mctx.input, match_first, eflags);
      95     match_last = check_matching (&mctx, &match_first);
      96     match_ctx_clean (&mctx);
      97    }
      98  }
      99  
     100  check_matching (re_match_context_t * mctx, int *p_match_first
     101  )
     102  {
     103   int cur_str_idx = ((&mctx->input)->cur_idx);
     104   re_dfastate_t *cur_state;
     105   int next_start_idx = cur_str_idx;
     106   cur_state = transit_state (mctx, cur_state);
     107   *p_match_first += next_start_idx;
     108  }
     109  
     110  static re_dfastate_t *
     111  transit_state (
     112   re_match_context_t * mctx,
     113   re_dfastate_t * state
     114  )
     115  {
     116   if (!build_trtable (mctx->dfa, state))
     117    {
     118    }
     119  }
     120  
     121  build_trtable (const re_dfa_t * dfa,
     122  	             re_dfastate_t * state
     123  )
     124  {
     125   int i,
     126    j;
     127   bitset_t accepts;
     128   const re_node_set *cur_nodes = &state->nodes;
     129   for (i = 0; i < cur_nodes->nelem; ++i)
     130    {
     131     re_token_t *node = &dfa->nodes[cur_nodes->elems[i]];
     132     re_token_type_t type = node->type;
     133     {
     134      if (dfa->mb_cur_max > 1)
     135       bitset_merge (accepts, dfa->sb_char);
     136      {
     137       bitset_word_t any_set = 0;
     138       if (type == CHARACTER && !node->word_char)
     139        any_set |= (accepts[j] &= (dfa->word_char[j] | ~dfa->sb_char[j]));
     140       else
     141        for (j = 0; j < (256 / (sizeof (bitset_word_t) * 8)); ++j)
     142         any_set |= (accepts[j] &= dfa->word_char[j]);
     143      }
     144     }
     145    }
     146  }
     147  
     148  static void
     149  match_ctx_clean (
     150   re_match_context_t * mctx
     151  )
     152  {
     153   int st_idx;
     154   for (st_idx = 0; st_idx < mctx->nsub_tops; ++st_idx)
     155    {
     156     int sl_idx;
     157     re_sub_match_top_t *top = mctx->sub_tops[st_idx];
     158     for (sl_idx = 0; sl_idx < top->nlasts; ++sl_idx)
     159      {
     160       re_sub_match_last_t *last = top->lasts[sl_idx];
     161       free (last->path.array);
     162      }
     163    }
     164  }
     165