示例#1
0
/* compiler builtin: 
   void *__builtin_alloca(unsigned long);   */
void test_specifier_application(char const *allowed, char const *fmt,
                                int only_negative, char *at)
{
  size_t tmp;
  unsigned long __lengthof_format;
  __e_acsl_store_block((void *)(& __lengthof_format),(size_t)8);
  __e_acsl_store_block((void *)(& tmp),(size_t)8);
  __e_acsl_store_block((void *)(& at),(size_t)8);
  __e_acsl_store_block((void *)(& only_negative),(size_t)4);
  __e_acsl_store_block((void *)(& fmt),(size_t)8);
  __e_acsl_store_block((void *)(& allowed),(size_t)8);
  __e_acsl_full_init((void *)(& tmp));
  tmp = __gen_e_acsl_strlen(fmt);
  int len = (int)tmp;
  __e_acsl_store_block((void *)(& len),(size_t)4);
  __e_acsl_full_init((void *)(& len));
  /*@ assert
      alloca_bounds: 0 < sizeof(char) * (len + 1) ≤ 18446744073709551615;
  */
  {
    int __gen_e_acsl_and;
    if (0L < 1L * (len + 1L)) {
      __e_acsl_mpz_t __gen_e_acsl_;
      __e_acsl_mpz_t __gen_e_acsl__2;
      int __gen_e_acsl_le;
      __gmpz_init_set_si(__gen_e_acsl_,1L * (len + 1L));
      __gmpz_init_set_ui(__gen_e_acsl__2,18446744073709551615UL);
      __gen_e_acsl_le = __gmpz_cmp((__e_acsl_mpz_struct const *)(__gen_e_acsl_),
                                   (__e_acsl_mpz_struct const *)(__gen_e_acsl__2));
      __gen_e_acsl_and = __gen_e_acsl_le <= 0;
      __gmpz_clear(__gen_e_acsl_);
      __gmpz_clear(__gen_e_acsl__2);
    }
    else __gen_e_acsl_and = 0;
    __e_acsl_assert(__gen_e_acsl_and,(char *)"Assertion",
                    (char *)"test_specifier_application",
                    (char *)"alloca_bounds: 0 < sizeof(char) * (len + 1) <= 18446744073709551615",
                    82);
  }
  __e_acsl_full_init((void *)(& __lengthof_format));
  __lengthof_format = (unsigned long)(len + 1);
  char *format = __builtin_alloca(sizeof(char) * __lengthof_format);
  __e_acsl_store_block((void *)format,sizeof(char) * __lengthof_format);
  __e_acsl_store_block((void *)(& format),(size_t)8);
  __e_acsl_full_init((void *)(& format));
  __gen_e_acsl_strcpy(format,fmt);
  {
    int i_0 = 0;
    __e_acsl_store_block((void *)(& i_0),(size_t)4);
    __e_acsl_full_init((void *)(& i_0));
    while (1) {
      size_t tmp_3;
      __e_acsl_store_block((void *)(& tmp_3),(size_t)8);
      __e_acsl_full_init((void *)(& tmp_3));
      tmp_3 = __gen_e_acsl_strlen(valid_specifiers);
      ;
      if (! ((size_t)i_0 < tmp_3)) {
        __e_acsl_delete_block((void *)(& tmp_3));
        break;
      }
      {
        char *tmp_2;
        __e_acsl_store_block((void *)(& tmp_2),(size_t)8);
        int c = (int)*(valid_specifiers + i_0);
        __e_acsl_store_block((void *)(& c),(size_t)4);
        __e_acsl_full_init((void *)(& c));
        __e_acsl_initialize((void *)(format + (len - 1)),sizeof(char));
        *(format + (len - 1)) = (char)c;
        __e_acsl_full_init((void *)(& tmp_2));
        tmp_2 = __gen_e_acsl_strchr(allowed,c);
        if (tmp_2) {
          if (! only_negative) {
            {
              pid_t pid = fork();
              __e_acsl_store_block((void *)(& pid),(size_t)4);
              __e_acsl_full_init((void *)(& pid));
              if (! pid) {
                apply_specifier(format,c);
                __gen_e_acsl_exit(0);
              }
              else {
                int process_status;
                __e_acsl_store_block((void *)(& process_status),(size_t)4);
                waitpid(pid,& process_status,0);
                signal_eval(process_status,0,(char const *)at);
                __e_acsl_delete_block((void *)(& process_status));
              }
              __e_acsl_delete_block((void *)(& pid));
            }
          }
        }
        else {
          {
            pid_t pid_0 = fork();
            __e_acsl_store_block((void *)(& pid_0),(size_t)4);
            __e_acsl_full_init((void *)(& pid_0));
            if (! pid_0) {
              apply_specifier(format,c);
              __gen_e_acsl_exit(0);
            }
            else {
              int process_status_0;
              __e_acsl_store_block((void *)(& process_status_0),(size_t)4);
              waitpid(pid_0,& process_status_0,0);
              signal_eval(process_status_0,1,(char const *)at);
              __e_acsl_delete_block((void *)(& process_status_0));
            }
            __e_acsl_delete_block((void *)(& pid_0));
          }
        }
        __e_acsl_delete_block((void *)(& tmp_2));
        __e_acsl_delete_block((void *)(& c));
      }
      __e_acsl_full_init((void *)(& i_0));
      i_0 ++;
      __e_acsl_delete_block((void *)(& tmp_3));
    }
    __e_acsl_delete_block((void *)(& i_0));
  }
  __e_acsl_delete_block((void *)format);
  __e_acsl_delete_block((void *)(& at));
  __e_acsl_delete_block((void *)(& only_negative));
  __e_acsl_delete_block((void *)(& fmt));
  __e_acsl_delete_block((void *)(& allowed));
  __e_acsl_delete_block((void *)(& __lengthof_format));
  __e_acsl_delete_block((void *)(& format));
  __e_acsl_delete_block((void *)(& tmp));
  __e_acsl_delete_block((void *)(& len));
  return;
}
示例#2
0
int __gen_e_acsl_main(int argc, char **argv)
{
  int __retres;
  int i;
  /*@ assert ∀ int k; 0 ≤ k < argc ⇒ \valid(argv + k); */
  {
    int __gen_e_acsl_forall;
    int __gen_e_acsl_k;
    __e_acsl_store_block((void *)(& argv),(size_t)8);
    __gen_e_acsl_forall = 1;
    __gen_e_acsl_k = 0;
    while (1) {
      if (__gen_e_acsl_k < argc) ; else break;
      {
        int __gen_e_acsl_valid;
        __gen_e_acsl_valid = __e_acsl_valid((void *)(argv + __gen_e_acsl_k),
                                            sizeof(char *),(void *)argv,
                                            (void *)(& argv));
        if (__gen_e_acsl_valid) ;
        else {
          __gen_e_acsl_forall = 0;
          goto e_acsl_end_loop1;
        }
      }
      __gen_e_acsl_k ++;
    }
    e_acsl_end_loop1: ;
    __e_acsl_assert(__gen_e_acsl_forall,(char *)"Assertion",(char *)"main",
                    (char *)"\\forall int k; 0 <= k < argc ==> \\valid(argv + k)",
                    12);
  }
  /*@ assert \block_length(argv) ≡ (argc + 1) * sizeof(char *); */
  {
    unsigned long __gen_e_acsl_block_length;
    __e_acsl_mpz_t __gen_e_acsl_block_length_2;
    __e_acsl_mpz_t __gen_e_acsl_;
    int __gen_e_acsl_eq;
    __gen_e_acsl_block_length = __e_acsl_block_length((void *)argv);
    __gmpz_init_set_ui(__gen_e_acsl_block_length_2,__gen_e_acsl_block_length);
    __gmpz_init_set_si(__gen_e_acsl_,(argc + 1L) * 8);
    __gen_e_acsl_eq = __gmpz_cmp((__e_acsl_mpz_struct const *)(__gen_e_acsl_block_length_2),
                                 (__e_acsl_mpz_struct const *)(__gen_e_acsl_));
    __e_acsl_assert(__gen_e_acsl_eq == 0,(char *)"Assertion",(char *)"main",
                    (char *)"\\block_length(argv) == (argc + 1) * sizeof(char *)",
                    13);
    __gmpz_clear(__gen_e_acsl_block_length_2);
    __gmpz_clear(__gen_e_acsl_);
  }
  /*@ assert *(argv + argc) ≡ \null; */
  {
    int __gen_e_acsl_valid_read;
    __gen_e_acsl_valid_read = __e_acsl_valid_read((void *)(argv + argc),
                                                  sizeof(char *),
                                                  (void *)argv,
                                                  (void *)(& argv));
    __e_acsl_assert(__gen_e_acsl_valid_read,(char *)"RTE",(char *)"main",
                    (char *)"mem_access: \\valid_read(argv + argc)",15);
    /*@ assert Eva: mem_access: \valid_read(argv + argc); */
    __e_acsl_assert(*(argv + argc) == (char *)0,(char *)"Assertion",
                    (char *)"main",(char *)"*(argv + argc) == \\null",15);
  }
  /*@ assert ¬\valid(*(argv + argc)); */
  {
    int __gen_e_acsl_initialized;
    int __gen_e_acsl_and;
    __gen_e_acsl_initialized = __e_acsl_initialized((void *)(argv + argc),
                                                    sizeof(char *));
    if (__gen_e_acsl_initialized) {
      int __gen_e_acsl_valid_read_2;
      int __gen_e_acsl_valid_2;
      __gen_e_acsl_valid_read_2 = __e_acsl_valid_read((void *)(argv + argc),
                                                      sizeof(char *),
                                                      (void *)argv,
                                                      (void *)(& argv));
      __e_acsl_assert(__gen_e_acsl_valid_read_2,(char *)"RTE",(char *)"main",
                      (char *)"mem_access: \\valid_read(argv + argc)",16);
      /*@ assert Eva: mem_access: \valid_read(argv + argc); */
      __gen_e_acsl_valid_2 = __e_acsl_valid((void *)*(argv + argc),
                                            sizeof(char),
                                            (void *)*(argv + argc),
                                            (void *)(argv + argc));
      __gen_e_acsl_and = __gen_e_acsl_valid_2;
    }
    else __gen_e_acsl_and = 0;
    __e_acsl_assert(! __gen_e_acsl_and,(char *)"Assertion",(char *)"main",
                    (char *)"!\\valid(*(argv + argc))",16);
  }
  i = 0;
  while (i < argc) {
    {
      size_t tmp;
      tmp = __gen_e_acsl_strlen((char const *)*(argv + i));
      int len = (int)tmp;
      /*@ assert \valid(*(argv + i)); */
      {
        int __gen_e_acsl_initialized_2;
        int __gen_e_acsl_and_2;
        __gen_e_acsl_initialized_2 = __e_acsl_initialized((void *)(argv + i),
                                                          sizeof(char *));
        if (__gen_e_acsl_initialized_2) {
          int __gen_e_acsl_valid_read_3;
          int __gen_e_acsl_valid_3;
          __gen_e_acsl_valid_read_3 = __e_acsl_valid_read((void *)(argv + i),
                                                          sizeof(char *),
                                                          (void *)argv,
                                                          (void *)(& argv));
          __e_acsl_assert(__gen_e_acsl_valid_read_3,(char *)"RTE",
                          (char *)"main",
                          (char *)"mem_access: \\valid_read(argv + i)",19);
          __gen_e_acsl_valid_3 = __e_acsl_valid((void *)*(argv + i),
                                                sizeof(char),
                                                (void *)*(argv + i),
                                                (void *)(argv + i));
          __gen_e_acsl_and_2 = __gen_e_acsl_valid_3;
        }
        else __gen_e_acsl_and_2 = 0;
        __e_acsl_assert(__gen_e_acsl_and_2,(char *)"Assertion",
                        (char *)"main",(char *)"\\valid(*(argv + i))",19);
      }
      /*@ assert ∀ int k; 0 ≤ k ≤ len ⇒ \valid(*(argv + i) + k); */
      {
        int __gen_e_acsl_forall_2;
        long __gen_e_acsl_k_2;
        __gen_e_acsl_forall_2 = 1;
        __gen_e_acsl_k_2 = 0;
        while (1) {
          if (__gen_e_acsl_k_2 <= (long)len) ; else break;
          {
            int __gen_e_acsl_valid_read_4;
            int __gen_e_acsl_valid_4;
            __gen_e_acsl_valid_read_4 = __e_acsl_valid_read((void *)(
                                                            argv + i),
                                                            sizeof(char *),
                                                            (void *)argv,
                                                            (void *)(& argv));
            __e_acsl_assert(__gen_e_acsl_valid_read_4,(char *)"RTE",
                            (char *)"main",
                            (char *)"mem_access: \\valid_read(argv + i)",20);
            __gen_e_acsl_valid_4 = __e_acsl_valid((void *)(*(argv + i) + __gen_e_acsl_k_2),
                                                  sizeof(char),
                                                  (void *)*(argv + i),
                                                  (void *)(argv + i));
            if (__gen_e_acsl_valid_4) ;
            else {
              __gen_e_acsl_forall_2 = 0;
              goto e_acsl_end_loop2;
            }
          }
          __gen_e_acsl_k_2 ++;
        }
        e_acsl_end_loop2: ;
        __e_acsl_assert(__gen_e_acsl_forall_2,(char *)"Assertion",
                        (char *)"main",
                        (char *)"\\forall int k; 0 <= k <= len ==> \\valid(*(argv + i) + k)",
                        20);
      }
    }
    i ++;
  }
  __retres = 0;
  __e_acsl_delete_block((void *)(& argv));
  return __retres;
}