diff --git a/.gitignore b/.gitignore index 065769eeba111c28e7250e496aec936c81b7db4f..633a7d72b4f6a96980eec0d1d508467a17ddfa92 100644 --- a/.gitignore +++ b/.gitignore @@ -204,3 +204,4 @@ hello-*.tar.gz /src/plugins/gui/gtk_compat.ml /src/plugins/gui/GSourceView.ml /src/plugins/gui/GSourceView.mli +/tests/crowbar/integer_bb_pretty diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 96c52af374c82f1c0bc8524cda90c91437398ab7..0f54bad033530b3a48bbc86e9e541750c5ac9676 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,225 +1,248 @@ stages: - - update_docker - - lint - - frama_c_and_plugins + - git-update + - build + - tests - distrib_and_compatibility -variables: - OPAM_PACKAGES: ocamlfind zarith ocamlgraph ocp-indent - -# update the cache -update_docker: - stage: update_docker - image: ocaml/opam:debian - variables: - GIT_STRATEGY: none - before_script: - - sudo apt-get install -y -qq rsync - - mkdir -p .gitlab_oci_cache/.opam/ - - rsync -a .gitlab_oci_cache/.opam/ /home/opam/.opam/ - - opam list - - opam depext -i $OPAM_PACKAGES - after_script: - - rsync -a --delete /home/opam/.opam/ .gitlab_oci_cache/.opam/ - cache: - key: "frama-c" - paths: - - .gitlab_oci_cache/ - script: - - exit 0 - tags: - - docker - -#lint uses the cache but doesn't modify it -lint: - stage: lint - image: ocaml/opam:debian - before_script: - - sudo apt-get install -y -qq rsync autoconf build-essential bc - - mkdir -p .gitlab_oci_cache/.opam/ - - rsync -a .gitlab_oci_cache/.opam/ /home/opam/.opam/ - - opam list - - opam depext -i $OPAM_PACKAGES - cache: - key: "frama-c" - paths: - - .gitlab_oci_cache/ - script: - - autoconf - - ./configure - - make lint - - make stats-lint -# - make check-headers OPEN_SOURCE=yes STRICT_HEADERS=yes - coverage: '/lint coverage: \d+\.\d+/' - tags: - - docker - - -frama-c-external: - stage: frama_c_and_plugins +#avoid a nix error https://github.com/NixOS/nix/issues/2087 +git-update: + stage: git-update + variables: + CURRENT: $CI_COMMIT_REF_NAME + DEFAULT: "master" + OCAML: "4_05" + FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA" script: - - ~oci/oci/bin/bf_client.native run --socket ~oci/data/oci-data/oci.socket --frama-c $CI_BUILD_REF --branch $CI_BUILD_REF_NAME frama-c-external --cppo 07d2bcee50670aecae7e094d92f68fd18314073a --ocamlgraph 9286b375c005d1d504a1def0c5986f54c7f12251 --url ocamlfind,git@git.frama-c.com:bobot/ocamlfind.git + - nix/frama-ci.sh instantiate --eval -A frama-c.src.outPath tags: - except: - - tags - retry: 2 + - nix frama-c: - stage: frama_c_and_plugins + stage: build + variables: + CURRENT: $CI_COMMIT_REF_NAME + DEFAULT: "master" + OCAML: "4_05" + FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA" script: - - ~oci/oci/bin/bf_client.native run --socket ~oci/data/oci-data/oci.socket --frama-c $CI_BUILD_REF --branch $CI_BUILD_REF_NAME frama-c --cppo 07d2bcee50670aecae7e094d92f68fd18314073a --ocamlgraph 9286b375c005d1d504a1def0c5986f54c7f12251 --url ocamlfind,git@git.frama-c.com:bobot/ocamlfind.git + - nix/frama-ci.sh build -A frama-c.installed tags: - except: - - tags - retry: 2 + - nix -frama-c-ocaml-4.03: - stage: distrib_and_compatibility +lint: + stage: build + variables: + CURRENT: $CI_COMMIT_REF_NAME + DEFAULT: "master" + OCAML: "4_05" + FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA" script: - - ~oci/oci/bin/bf_client.native run --socket ~oci/data/oci-data/oci.socket --ocaml 4.03 --camlp4 4.03 --frama-c $CI_BUILD_REF --branch $CI_BUILD_REF_NAME frama-c --cppo 07d2bcee50670aecae7e094d92f68fd18314073a --ocamlgraph 9286b375c005d1d504a1def0c5986f54c7f12251 --url ocamlfind,git@git.frama-c.com:bobot/ocamlfind.git + - nix/frama-ci.sh build -A frama-c.lint + coverage: '/lint coverage: \d+\.\d+/' tags: - except: - - tags - retry: 2 + - nix -frama-c-ocaml-4.04: - stage: distrib_and_compatibility +tests: + stage: tests + variables: + CURRENT: $CI_COMMIT_REF_NAME + DEFAULT: "master" + OCAML: "4_05" + FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA" script: - - ~oci/oci/bin/bf_client.native run --socket ~oci/data/oci-data/oci.socket --ocaml 4.04 --camlp4 4.04 --lablgtk 4bbd5cf1990aa8b775cf247fbfe5be321e13cc61 --frama-c $CI_BUILD_REF --branch $CI_BUILD_REF_NAME frama-c --cppo 07d2bcee50670aecae7e094d92f68fd18314073a --ocamlgraph 9286b375c005d1d504a1def0c5986f54c7f12251 --url ocamlfind,git@git.frama-c.com:bobot/ocamlfind.git + - nix/frama-ci.sh build -A frama-c.tests tags: - except: - - tags - retry: 2 + - nix -frama-c-ocaml-4.05: - stage: distrib_and_compatibility +wp-qualif: + stage: tests + variables: + CURRENT: $CI_COMMIT_REF_NAME + DEFAULT: "master" + OCAML: "4_05" + FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA" script: - - ~oci/oci/bin/bf_client.native run --socket ~oci/data/oci-data/oci.socket --ocaml 4.05 --camlp4 4.05 --lablgtk 4bbd5cf1990aa8b775cf247fbfe5be321e13cc61 --camomile 3f4d657d50c17213f3338ca75efb30d728704df3 --frama-c $CI_BUILD_REF --branch $CI_BUILD_REF_NAME frama-c --cppo 07d2bcee50670aecae7e094d92f68fd18314073a --ocamlgraph 9286b375c005d1d504a1def0c5986f54c7f12251 --url ocamlfind,git@git.frama-c.com:bobot/ocamlfind.git + - nix/frama-ci.sh build -A frama-c.wp-qualif tags: - except: - - tags - retry: 2 + - nix allow_failure: true -frama-c-internal: - stage: distrib_and_compatibility - script: - - ~oci/oci/bin/bf_client.native run --socket ~oci/data/oci-data/oci.socket --frama-c $CI_BUILD_REF --branch $CI_BUILD_REF_NAME frama-c-internal --cppo 07d2bcee50670aecae7e094d92f68fd18314073a --ocamlgraph 9286b375c005d1d504a1def0c5986f54c7f12251 --url ocamlfind,git@git.frama-c.com:bobot/ocamlfind.git - tags: - only: - - master - - stable/silicium - except: - - tags - retry: 2 - -frama-c-distrib: - stage: distrib_and_compatibility +genassigns: + stage: tests + variables: + CURRENT: $CI_COMMIT_REF_NAME + DEFAULT: "master" + OCAML: "4_05" + FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA" script: - - ~oci/oci/bin/bf_client.native run --socket ~oci/data/oci-data/oci.socket --frama-c $CI_BUILD_REF --branch $CI_BUILD_REF_NAME frama-c-distrib --cppo 07d2bcee50670aecae7e094d92f68fd18314073a --ocamlgraph 9286b375c005d1d504a1def0c5986f54c7f12251 --url ocamlfind,git@git.frama-c.com:bobot/ocamlfind.git + - nix/frama-ci.sh build -A genassigns.tests tags: - except: - - tags - retry: 2 + - nix - -Genassigns: - stage: frama_c_and_plugins +counter-examples: + stage: tests + variables: + CURRENT: $CI_COMMIT_REF_NAME + DEFAULT: "master" + OCAML: "4_05" + FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA" script: - - ~oci/oci/bin/bf_client.native run --socket ~oci/data/oci-data/oci.socket --frama-c $CI_BUILD_REF --branch $CI_BUILD_REF_NAME Genassigns --cppo 07d2bcee50670aecae7e094d92f68fd18314073a --ocamlgraph 9286b375c005d1d504a1def0c5986f54c7f12251 --url ocamlfind,git@git.frama-c.com:bobot/ocamlfind.git + - nix/frama-ci.sh build -A counter-examples.tests tags: - except: - - tags - retry: 2 + - nix -Mthread: - stage: frama_c_and_plugins +acsl-importer: + stage: tests + variables: + CURRENT: $CI_COMMIT_REF_NAME + DEFAULT: "master" + OCAML: "4_05" + FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA" script: - - ~oci/oci/bin/bf_client.native run --socket ~oci/data/oci-data/oci.socket --frama-c $CI_BUILD_REF --branch $CI_BUILD_REF_NAME Mthread --cppo 07d2bcee50670aecae7e094d92f68fd18314073a --ocamlgraph 9286b375c005d1d504a1def0c5986f54c7f12251 --url ocamlfind,git@git.frama-c.com:bobot/ocamlfind.git + - nix/frama-ci.sh build -A acsl-importer.tests tags: - except: - - tags - retry: 2 + - nix -a3export: - stage: frama_c_and_plugins +volatile: + stage: tests + variables: + CURRENT: $CI_COMMIT_REF_NAME + DEFAULT: "master" + OCAML: "4_05" + FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA" script: - - ~oci/oci/bin/bf_client.native run --socket ~oci/data/oci-data/oci.socket --frama-c $CI_BUILD_REF --branch $CI_BUILD_REF_NAME a3export --cppo 07d2bcee50670aecae7e094d92f68fd18314073a --ocamlgraph 9286b375c005d1d504a1def0c5986f54c7f12251 --url ocamlfind,git@git.frama-c.com:bobot/ocamlfind.git + - nix/frama-ci.sh build -A volatile.tests tags: - except: - - tags - retry: 2 + - nix -PathCrawler: - stage: frama_c_and_plugins +E-ACSL: + stage: tests + variables: + CURRENT: $CI_COMMIT_REF_NAME + DEFAULT: "master" + OCAML: "4_05" + FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA" script: - - ~oci/oci/bin/bf_client.native run --socket ~oci/data/oci-data/oci.socket --frama-c $CI_BUILD_REF --branch $CI_BUILD_REF_NAME PathCrawler --cppo 07d2bcee50670aecae7e094d92f68fd18314073a --ocamlgraph 9286b375c005d1d504a1def0c5986f54c7f12251 --url ocamlfind,git@git.frama-c.com:bobot/ocamlfind.git + - nix/frama-ci.sh build -A e-acsl.tests tags: - except: - - tags - retry: 2 + - nix Security: - stage: frama_c_and_plugins + stage: tests + variables: + CURRENT: $CI_COMMIT_REF_NAME + DEFAULT: "master" + OCAML: "4_05" + FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA" script: - - ~oci/oci/bin/bf_client.native run --socket ~oci/data/oci-data/oci.socket --frama-c $CI_BUILD_REF --branch $CI_BUILD_REF_NAME Security --cppo 07d2bcee50670aecae7e094d92f68fd18314073a --ocamlgraph 9286b375c005d1d504a1def0c5986f54c7f12251 --url ocamlfind,git@git.frama-c.com:bobot/ocamlfind.git + - nix/frama-ci.sh build -A security.tests tags: - except: - - tags - retry: 2 + - nix -E-ACSL: - stage: frama_c_and_plugins +CFP: + stage: tests + variables: + CURRENT: $CI_COMMIT_REF_NAME + DEFAULT: "master" + OCAML: "4_05" + FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA" script: - - ~oci/oci/bin/bf_client.native run --socket ~oci/data/oci-data/oci.socket --frama-c $CI_BUILD_REF --branch $CI_BUILD_REF_NAME E-ACSL --cppo 07d2bcee50670aecae7e094d92f68fd18314073a --ocamlgraph 9286b375c005d1d504a1def0c5986f54c7f12251 --url ocamlfind,git@git.frama-c.com:bobot/ocamlfind.git + - nix/frama-ci.sh build -A context-from-precondition.tests tags: - except: - - tags - allow_failure: true - retry: 2 + - nix -context-from-precondition: - stage: frama_c_and_plugins +internal: + stage: distrib_and_compatibility + variables: + CURRENT: $CI_COMMIT_REF_NAME + DEFAULT: "master" + OCAML: "4_05" + FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA" script: - - ~oci/oci/bin/bf_client.native run --socket ~oci/data/oci-data/oci.socket --frama-c $CI_BUILD_REF --branch $CI_BUILD_REF_NAME context-from-precondition --cppo 07d2bcee50670aecae7e094d92f68fd18314073a --ocamlgraph 9286b375c005d1d504a1def0c5986f54c7f12251 --url ocamlfind,git@git.frama-c.com:bobot/ocamlfind.git + - nix/frama-ci.sh build -A frama-c.internal tags: - except: - - tags - retry: 2 + - nix -open-source-case-studies: - stage: frama_c_and_plugins +.build_template: &frama-c-ocaml + stage: distrib_and_compatibility script: - - ~oci/oci/bin/bf_client.native run --socket ~oci/data/oci-data/oci.socket --frama-c $CI_BUILD_REF --url open-source-case-studies,git@git.frama-c.com:frama-c/open-source-case-studies.git --commit open-source-case-studies,master open-source-case-studies --cppo 07d2bcee50670aecae7e094d92f68fd18314073a --ocamlgraph 9286b375c005d1d504a1def0c5986f54c7f12251 --url ocamlfind,git@git.frama-c.com:bobot/ocamlfind.git + - nix/frama-ci.sh build -A frama-c.installed tags: - except: - - tags - when: manual - retry: 2 + - nix + + +frama-c-ocaml-4.02: + variables: + CURRENT: $CI_COMMIT_REF_NAME + DEFAULT: "master" + OCAML: "4_02" + FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA" + <<: *frama-c-ocaml -ACSL-importer: - stage: frama_c_and_plugins +frama-c-ocaml-4.03: + variables: + CURRENT: $CI_COMMIT_REF_NAME + DEFAULT: "master" + OCAML: "4_03" + FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA" + <<: *frama-c-ocaml + +frama-c-ocaml-4.04: + variables: + CURRENT: $CI_COMMIT_REF_NAME + DEFAULT: "master" + OCAML: "4_04" + FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA" + <<: *frama-c-ocaml + +frama-c-ocaml-4.06: + variables: + CURRENT: $CI_COMMIT_REF_NAME + DEFAULT: "master" + OCAML: "4_06" + FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA" + <<: *frama-c-ocaml + +frama-c-ocaml-4.07: + variables: + CURRENT: $CI_COMMIT_REF_NAME + DEFAULT: "master" + OCAML: "4_07" + FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA" + <<: *frama-c-ocaml + +caveat-importer: + stage: tests + variables: + CURRENT: $CI_COMMIT_REF_NAME + DEFAULT: "master" + OCAML: "4_05" + FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA" script: - - ~oci/oci/bin/bf_client.native run --socket ~oci/data/oci-data/oci.socket --frama-c $CI_BUILD_REF --branch $CI_BUILD_REF_NAME ACSL-importer --cppo 07d2bcee50670aecae7e094d92f68fd18314073a --ocamlgraph 9286b375c005d1d504a1def0c5986f54c7f12251 --url ocamlfind,git@git.frama-c.com:bobot/ocamlfind.git + - nix/frama-ci.sh build -A caveat-importer.tests tags: - except: - - tags - retry: 2 + - nix -Caveat-importer: - stage: frama_c_and_plugins +mthread: + stage: tests + variables: + CURRENT: $CI_COMMIT_REF_NAME + DEFAULT: "master" + OCAML: "4_05" + FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA" script: - - ~oci/oci/bin/bf_client.native run --socket ~oci/data/oci-data/oci.socket --frama-c $CI_BUILD_REF --branch $CI_BUILD_REF_NAME Caveat-importer --cppo 07d2bcee50670aecae7e094d92f68fd18314073a --ocamlgraph 9286b375c005d1d504a1def0c5986f54c7f12251 --url ocamlfind,git@git.frama-c.com:bobot/ocamlfind.git + - nix/frama-ci.sh build -A mthread.tests tags: - except: - - tags - retry: 2 + - nix -Volatile: - stage: frama_c_and_plugins +pathcrawler: + stage: tests + variables: + CURRENT: $CI_COMMIT_REF_NAME + DEFAULT: "master" + OCAML: "4_05" + FRAMA_CI_OPT: "--override frama-c:$CI_COMMIT_REF_NAME,$CI_COMMIT_SHA" script: - - ~oci/oci/bin/bf_client.native run --socket ~oci/data/oci-data/oci.socket --frama-c $CI_BUILD_REF --branch $CI_BUILD_REF_NAME Volatile --cppo 07d2bcee50670aecae7e094d92f68fd18314073a --ocamlgraph 9286b375c005d1d504a1def0c5986f54c7f12251 --url ocamlfind,git@git.frama-c.com:bobot/ocamlfind.git + - nix/frama-ci.sh build -A pathcrawler.tests tags: - except: - - tags - retry: 2 + - nix diff --git a/Makefile b/Makefile index a578a6b1d9d259fd8c5a19ba1eb0df1b22f4d129..33a67f1597a66546ae488bd42802c6ff9c7ae115 100644 --- a/Makefile +++ b/Makefile @@ -374,7 +374,7 @@ ifeq ("$(DEVELOPMENT)","yes") all:: share/.gitignore endif -clean:: +clean_share_link: if test -f share/.gitignore; then \ for link in $$(cat share/.gitignore); do \ if test -L share$$link; then \ @@ -386,6 +386,8 @@ clean:: rm share/.gitignore; \ fi +clean:: clean_share_link + ############## # Ocamlgraph # ############## @@ -921,6 +923,7 @@ PLUGIN_GUI_CMO:=$(VALUE_GUI_AUX) gui_files/gui_callstacks_manager \ gui_files/gui_red gui_files/register_gui PLUGIN_INTERNAL_TEST:= yes +PLUGIN_TESTS_LIB=tests/float/fval_test.ml PLUGIN_DISTRIBUTED:=yes VALUE_TYPES:=$(addprefix src/plugins/value_types/,\ cilE cvalue precise_locs value_types widen_type) @@ -955,6 +958,11 @@ PLUGIN_CMO:= options generator rte visit register PLUGIN_DISTRIBUTED:=yes PLUGIN_INTERNAL_TEST:=yes PLUGIN_TESTS_DIRS:=rte rte_manual +PLUGIN_TESTS_LIB:=\ + tests/rte/my_annotation/my_annotation.ml \ + tests/rte/rte_api/rte_get_annot.ml \ + tests/rte/compute_annot/compute_annot.ml \ + tests/rte/my_annot_proxy/my_annot_proxy.ml $(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME))) ################# @@ -999,6 +1007,7 @@ $(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME))) PLUGIN_ENABLE:=$(ENABLE_CONSTANT_PROPAGATION) PLUGIN_NAME:=Constant_Propagation PLUGIN_DIR:=src/plugins/constant_propagation +PLUGIN_TESTS_LIB:=tests/constant_propagation/introduction_of_non_explicit_cast.ml PLUGIN_CMO:= propagationParameters \ api PLUGIN_DISTRIBUTED:=yes @@ -1062,6 +1071,8 @@ $(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME))) PLUGIN_ENABLE:=$(ENABLE_PDG) PLUGIN_NAME:=Pdg PLUGIN_DIR:=src/plugins/pdg +PLUGIN_TESTS_LIB:=tests/pdg/dyn_dpds.ml \ + tests/pdg/sets.ml PLUGIN_CMO:= pdg_parameters \ ctrlDpds \ pdg_state \ @@ -1090,6 +1101,8 @@ $(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME))) PLUGIN_ENABLE:=$(ENABLE_SCOPE) PLUGIN_NAME:=Scope PLUGIN_DIR:=src/plugins/scope +PLUGIN_TESTS_LIB:=tests/scope/bts971.ml \ + tests/scope/zones.ml PLUGIN_CMO:= datascope zones defs PLUGIN_GUI_CMO:=dpds_gui PLUGIN_DEPENDENCIES:=Eva Inout @@ -1221,6 +1234,16 @@ bin/toplevel.opt$(EXE): $(ALL_BATCH_CMX) $(GEN_OPT_LIBS) \ $(PRINT_LINKING) $@ $(OCAMLOPT) $(OLINKFLAGS) -o $@ $(OPT_LIBS) $(ALL_BATCH_CMX) +LIB_KERNEL_CMO= $(filter-out src/kernel_internals/runtime/gui_init.cmo, $(CMO)) +LIB_KERNEL_CMX= $(filter-out src/kernel_internals/runtime/gui_init.cmx, $(CMX)) + +lib/fc/frama-c.cma: $(LIB_KERNEL_CMO) $(GEN_OPT_LIBS) $(LIB_KERNEL_CMX) lib/fc/META.frama-c + $(PRINT_LINKING) $@ and lib/fc/frama-c.cmxa + $(MKDIR) $(FRAMAC_LIB) + $(OCAMLMKLIB) -o lib/fc/frama-c $(OPT_LIBS) $(LIB_KERNEL_CMO) $(LIB_KERNEL_CMX) + +lib/fc/frama-c.cmxa: lib/fc/frama-c.cma + #################### # (Ocaml) Toplevel # #################### @@ -1388,17 +1411,18 @@ acsl_tests: byte $(PRINT_EXEC) acsl_tests find doc/speclang -name \*.c -exec ./bin/toplevel.byte$(EXE) {} \; > /dev/null -LONELY_TESTS_ML_FILES=$(wildcard $(TEST_DIRS_AS_PLUGIN:%=tests/%/*.ml)) -LONELY_TESTS_BYTE_FILES=$(LONELY_TESTS_ML_FILES:%.ml=%.cmo) -LONELY_TESTS_OPT_FILES=$(LONELY_TESTS_ML_FILES:%.ml=%.cmx) -LONELY_TESTS_DYN_FILES=$(LONELY_TESTS_ML_FILES:%.ml=%.cmxs) -$(LONELY_TESTS_BYTE_FILES): BFLAGS+=$(TEST_DIRS_AS_PLUGIN:%=-I tests/%) -$(LONELY_TESTS_OPT_FILES): OFLAGS+=$(TEST_DIRS_AS_PLUGIN:%=-I tests/%) -$(LONELY_TESTS_DYN_FILES): OFLAGS+=$(TEST_DIRS_AS_PLUGIN:%=-I tests/%) -.PRECIOUS: $(LONELY_TESTS_OPT_FILES) \ - $(LONELY_TESTS_DYN_FILES) \ - $(LONELY_TESTS_BYTE_FILES) \ - $(LONELY_TESTS_BYTE_FILES:%.cmo=%.cmi) +LONELY_TESTS_ML_FILES:=\ + $(shell find $(TEST_DIRS_AS_PLUGIN:%=tests/%) -name '*.ml') +$(foreach file,$(LONELY_TESTS_ML_FILES),\ + $(eval $(file:%.ml=%.cmo): BFLAGS+=-I $(dir $(file)))) +$(foreach file,$(LONELY_TESTS_ML_FILES),\ + $(eval $(file:%.ml=%.cmx): OFLAGS+=-I $(dir $(file)))) +$(foreach file,$(LONELY_TESTS_ML_FILES),\ + $(eval $(file:%.ml=%.cmxs): OFLAGS+=-I $(dir $(file)))) +.PRECIOUS: $(LONELY_TESTS_ML_FILES:%.ml=%.cmx) \ + $(LONELY_TESTS_DYN_FILES:%.ml=%.cmxs) \ + $(LONELY_TESTS_BYTE_FILES:%.ml=%.cmo) \ + $(LONELY_TESTS_BYTE_FILES:%.ml=%.cmi) bin/ocamldep_transitive_closure: devel_tools/ocamldep_transitive_closure.ml $(OCAMLOPT) -package ocamlgraph -package str -linkpkg -o $@ $< @@ -1826,6 +1850,7 @@ install-lib: clean-install $(PRINT_INSTALL) kernel API $(MKDIR) $(FRAMAC_LIBDIR) $(CP) $(LIB_BYTE_TO_INSTALL) $(LIB_OPT_TO_INSTALL) $(FRAMAC_LIBDIR) + $(CP) $(addprefix lib/fc/,dllframa-c.so libframa-c.a frama-c.cma frama-c.a frama-c.cmxa META.frama-c) $(FRAMAC_LIBDIR) install-doc-code: $(PRINT_INSTALL) API documentation @@ -2398,15 +2423,15 @@ clean-distrib: dist-clean create_lib_to_install_list = $(addprefix $(FRAMAC_LIB)/,$(call map,notdir,$(1))) -byte:: bin/toplevel.byte$(EXE) share/Makefile.dynamic_config \ +byte:: bin/toplevel.byte$(EXE) lib/fc/frama-c.cma share/Makefile.dynamic_config \ $(call create_lib_to_install_list,$(LIB_BYTE_TO_INSTALL)) \ - $(PLUGIN_META_LIST) + $(PLUGIN_META_LIST) lib/fc/META.frama-c -opt:: bin/toplevel.opt$(EXE) share/Makefile.dynamic_config \ +opt:: bin/toplevel.opt$(EXE) lib/fc/frama-c.cmxa share/Makefile.dynamic_config \ $(call create_lib_to_install_list,$(LIB_OPT_TO_INSTALL)) \ $(filter %.o %.cmi,\ $(call create_lib_to_install_list,$(LIB_BYTE_TO_INSTALL))) \ - $(PLUGIN_META_LIST) + $(PLUGIN_META_LIST) lib/fc/META.frama-c top: bin/toplevel.top$(EXE) \ $(call create_lib_to_install_list,$(LIB_BYTE_TO_INSTALL)) \ diff --git a/Makefile.generating b/Makefile.generating index f6fc54a95d179d6920d44dd3a9f75cd6bf3ab557..174a2b7bd4944525c884101148b7d1bf947bdb41 100644 --- a/Makefile.generating +++ b/Makefile.generating @@ -209,6 +209,12 @@ ifeq ("$(DEVELOPMENT)","yes") all:: .merlin endif +lib/fc/META.frama-c: share/META.frama-c share/Makefile.config Makefile.generating + $(MKDIR) lib/fc/ + $(SED) $< -e "s/@REQUIRES/$(LIBRARY_NAMES)/" > $@ + +GENERATED += lib/fc/META.frama-c + # Local Variables: # mode: makefile diff --git a/default.nix b/default.nix new file mode 100644 index 0000000000000000000000000000000000000000..e64150378a86d1a128776f31ba1f5912ea77af15 --- /dev/null +++ b/default.nix @@ -0,0 +1,15 @@ +# standalone derivation, for nix-build, nix-shell, etc +{ pkgs ? import <nixpkgs> {} }: +let + src = builtins.fetchGit { + "url" = ./.git; + "name" = "frama-c"; + "rev" = "ffa925f404779a3a0c4aacff5bd78b1c502def11"; + "ref" = "test-nix-fetchGit"; + }; + in + +pkgs.callPackage ./nix/default.nix { + opam2nix = pkgs.callPackage ../Frama-CI/opam2nix-packages.nix {}; + src = src; +} diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 0000000000000000000000000000000000000000..3bc25269109649cda4fcd4975e348e46a170e8e7 --- /dev/null +++ b/nix/default.nix @@ -0,0 +1,238 @@ +# paramaterised derivation with dependencies injected (callPackage style) +{ pkgs, stdenv, src ? ../., opam2nix, ocaml_version ? "ocaml-ng.ocamlPackages_4_05.ocaml", plugins ? { } }: + +let mk_buildInputs = { opamPackages ? [] } : + [ pkgs.gnugrep pkgs.gnused pkgs.autoconf pkgs.gnumake pkgs.gcc pkgs.ncurses pkgs.time pkgs.python3 pkgs.perl] ++ opam2nix.build { + specs = opam2nix.toSpecs ([ "ocamlfind" "zarith" "ocamlgraph" + { name = "coq"; constraint = "=8.7.2"; } + ] ++ opamPackages ++ + (if ocaml_version == "pkgs.ocaml-ng.ocamlPackages_4_02.ocaml" + then [ { name = "ocamlbuild" ; constraint = "=0"; } ] else []) + ); + ocamlAttr = ocaml_version; + }; + +in + +rec { + inherit src; + buildInputs = mk_buildInputs {}; + installed = main.out; + main = stdenv.mkDerivation { + name = "frama-c"; + inherit src buildInputs; + outputs = [ "out" "build_dir" ]; + postPatch = '' + patchShebangs . + ''; + configurePhase = '' + unset CC + autoconf + ./configure --prefix=$out + ''; + buildPhase = '' + make -j 4 + ''; + installPhase = '' + make install + mkdir -p $build_dir + tar -cf $build_dir/dir.tar . + pwd > $build_dir/old_pwd + ''; + setupHook = pkgs.writeText "setupHook.sh" '' + addFramaCPath () { + if test -d "''$1/lib/frama-c/plugins"; then + export FRAMAC_PLUGIN="''${FRAMAC_PLUGIN}''${FRAMAC_PLUGIN:+:}''$1/lib/frama-c/plugins" + export OCAMLPATH="''${OCAMLPATH}''${OCAMLPATH:+:}''$1/lib/frama-c/plugins" + fi + + if test -d "''$1/lib/frama-c"; then + export OCAMLPATH="''${OCAMLPATH}''${OCAMLPATH:+:}''$1/lib/frama-c" + fi + + if test -d "''$1/share/frama-c/"; then + export FRAMAC_EXTRA_SHARE="''${FRAMAC_EXTRA_SHARE}''${FRAMAC_EXTRA_SHARE:+:}''$1/share/frama-c" + fi + + } + + addEnvHooks "$targetOffset" addFramaCPath + ''; + }; + + lint = stdenv.mkDerivation { + name = "frama-c-lint"; + inherit src; + buildInputs = (mk_buildInputs {opamPackages = [ "ocp-indent" ];} ) ++ [ pkgs.bc plugins.headache.installed pkgs.file ]; + outputs = [ "out" ]; + postPatch = '' + patchShebangs . + ''; + configurePhase = '' + unset CC + autoconf + ./configure --prefix=$out + ''; + buildPhase = '' + make lint + make stats-lint + make check-headers + ''; + installPhase = '' + true + ''; + }; + + tests = stdenv.mkDerivation { + name = "frama-c-test"; + inherit buildInputs; + build_dir = main.build_dir; + src = main.build_dir + "/dir.tar"; + sourceRoot = "."; + postUnpack = '' + find . \( -name "Makefile*" -or -name ".depend" -o -name "ptests_config" -o -name "config.status" \) -exec bash -c "t=\$(stat -c %y \"\$0\"); sed -i -e \"s&$(cat $build_dir/old_pwd)&$(pwd)&g\" \"\$0\"; touch -d \"\$t\" \"\$0\"" {} \; + ''; + configurePhase = '' + true + ''; + buildPhase = '' + make clean_share_link + make create_share_link + make tests -j4 PTESTS_OPTS="-error-code -j 4" + ''; + installPhase = '' + true + ''; + }; + + distrib = stdenv.mkDerivation { + name = "frama-c-distrib"; + inherit src; + buildInputs = buildInputs ++ [ plugins.headache.installed ]; + postPatch = '' + patchShebangs . + ''; + configurePhase = '' + unset CC + autoconf + ./configure --prefix=$out + ''; + buildPhase = '' + make DISTRIB="frama-c-archive" src-distrib + ''; + installPhase = '' + tar -C $out --strip-components=1 -xf frama-c-archive.tar.gz + ''; + }; + + tests-distrib = stdenv.mkDerivation { + name = "frama-c-tests-distrib"; + inherit distrib buildInputs; + outputs = [ "out" "build_dir" ]; + configurePhase = '' + unset CC + autoconf + ./configure --prefix=$out + ''; + buildPhase = '' + make -j 4 + make tests -j4 PTESTS_OPTS="-error-code -j 4" + ''; + installPhase = '' + make install + ''; + }; + + wp-qualif = stdenv.mkDerivation { + name = "frama-c-wp-qualif"; + buildInputs = mk_buildInputs { opamPackages = [ + { name = "alt-ergo"; constraint = "=2.0.0"; } + { name = "why3" ; constraint = "=0.88.3"; } + ]; }; + build_dir = main.build_dir; + src = main.build_dir + "/dir.tar"; + sourceRoot = "."; + postUnpack = '' + find . \( -name "Makefile*" -or -name ".depend" -o -name "ptests_config" -o -name "config.status" \) -exec bash -c "t=\$(stat -c %y \"\$0\"); sed -i -e \"s&$(cat $build_dir/old_pwd)&$(pwd)&g\" \"\$0\"; touch -d \"\$t\" \"\$0\"" {} \; + ''; + configurePhase = '' + true + ''; + buildPhase = '' + make clean_share_link + make create_share_link + mkdir home + HOME=$(pwd)/home + why3 config + bin/ptests.opt -error-code -config qualif src/plugins/wp/tests + ''; + installPhase = '' + true + ''; + }; + + internal = stdenv.mkDerivation { + name = "frama-c-internal"; + inherit src; + buildInputs = (mk_buildInputs { opamPackages = [ "xml-light" ];} ) ++ + [ pkgs.getopt pkgs.which + pkgs.libxslt pkgs.libxml2 pkgs.file pkgs.autoPatchelfHook stdenv.cc.cc.lib + ]; + counter_examples_src = plugins.counter-examples.src; + genassigns_src = plugins.genassigns.src; + pathcrawler_src = plugins.pathcrawler.src; + mthread_src = plugins.mthread.src; + caveat_importer_src = plugins.caveat-importer.src; + acsl_importer_src = plugins.acsl-importer.src; + volatile_src = plugins.volatile.src; + e_acsl_src = plugins.e-acsl.src; + security_src = plugins.security.src; + context_from_precondition_src = plugins.context-from-precondition.src; + postPatch = '' + patchShebangs . + ''; + postUnpack = '' + cp -r --preserve=mode "$counter_examples_src" "$sourceRoot/src/plugins/counter-examples" + chmod -R u+w -- "$sourceRoot/src/plugins/counter-examples" + cp -r --preserve=mode "$genassigns_src" "$sourceRoot/src/plugins/genassigns" + chmod -R u+w -- "$sourceRoot/src/plugins/genassigns" + cp -r --preserve=mode "$pathcrawler_src" "$sourceRoot/src/plugins/pathcrawler" + chmod -R u+w -- "$sourceRoot/src/plugins/pathcrawler" + cp -r --preserve=mode "$mthread_src" "$sourceRoot/src/plugins/mthread" + chmod -R u+w -- "$sourceRoot/src/plugins/mthread" + cp -r --preserve=mode "$caveat_importer_src" "$sourceRoot/src/plugins/caveat-importer" + chmod -R u+w -- "$sourceRoot/src/plugins/caveat-importer" + cp -r --preserve=mode "$volatile_src" "$sourceRoot/src/plugins/volatile" + chmod -R u+w -- "$sourceRoot/src/plugins/volatile" + cp -r --preserve=mode "$acsl_importer_src" "$sourceRoot/src/plugins/acsl-importer" + chmod -R u+w -- "$sourceRoot/src/plugins/acsl-importer" + cp -r --preserve=mode "$e_acsl_src" "$sourceRoot/src/plugins/e-acsl" + chmod -R u+w -- "$sourceRoot/src/plugins/e-acsl" + echo IN_FRAMA_CI=yes > "$sourceRoot/in_frama_ci" + cp -r --preserve=mode "$context_from_precondition_src" "$sourceRoot/src/plugins/context-from-precondition" + chmod -R u+w -- "$sourceRoot/src/plugins/context-from-precondition" + cp -r --preserve=mode "$security_src" "$sourceRoot/src/plugins/security" + chmod -R u+w -- "$sourceRoot/src/plugins/security" + ''; + + configurePhase = '' + unset CC + autoconf + ./configure --prefix=$out + ''; + buildPhase = '' + make unpack-eclipse + sed -i src/plugins/pathcrawler/extern/eclipseCLP/RUNME -e "s/chmod 2755/chmod 755/g" + rm src/plugins/pathcrawler/extern/eclipseCLP/lib/x86_64_linux/dbi_mysql.so + rm src/plugins/pathcrawler/extern/eclipseCLP/lib/x86_64_linux/ic.so + prefix="src/plugins/pathcrawler" autoPatchelf + make -j 4 + ln -sr src/plugins/pathcrawler/share share/pc + make tests -j4 PTESTS_OPTS="-error-code -j 4" + ''; + installPhase = '' + make install + ''; + }; + +} diff --git a/nix/empty b/nix/empty new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/nix/frama-ci.nix b/nix/frama-ci.nix new file mode 100644 index 0000000000000000000000000000000000000000..e26a55d0f058b25b43d59ddd40a3656c951ef440 --- /dev/null +++ b/nix/frama-ci.nix @@ -0,0 +1,15 @@ +#To copy in other repository +{ pkgs ? import <nixpkgs> {}, password}: + +let + src = builtins.fetchGit { + "url" = "https://bobot:${password}@git.frama-c.com/frama-c/Frama-CI.git"; + "name" = "Frama-CI"; + "rev" = "70045f4252e668e0facad12d7db2c6ab83fc813b"; + "ref" = "master"; + }; + in + { + src = src; + compiled = pkgs.callPackage "${src}/compile.nix" { inherit pkgs; }; + } diff --git a/nix/frama-ci.sh b/nix/frama-ci.sh new file mode 100755 index 0000000000000000000000000000000000000000..b4a69f90154968218273a70d50be6173a2909841 --- /dev/null +++ b/nix/frama-ci.sh @@ -0,0 +1,12 @@ +#!/bin/sh -eu + +DIR=$(dirname $0) + +export FRAMA_CI_NIX=$DIR/frama-ci.nix + +export FRAMA_CI=$(nix-instantiate --eval -E "((import <nixpkgs> {}).callPackage $FRAMA_CI_NIX { password = \"$TOKEN_FOR_API\";}).src.outPath") + +FRAMA_CI=${FRAMA_CI#\"} +FRAMA_CI=${FRAMA_CI%\"} + +$FRAMA_CI/compile.sh $@ diff --git a/share/META.frama-c b/share/META.frama-c new file mode 100644 index 0000000000000000000000000000000000000000..be05739fdfee70b426d186932e71a06352db62e4 --- /dev/null +++ b/share/META.frama-c @@ -0,0 +1,16 @@ +description="frama-c" +version="" +requires="" + +package "kernel" ( + description="The kernel library of frama-c" + version="" + requires="@REQUIRES" + archive(byte) = "frama-c.cma" + plugin(byte) = "frama-c.cma" + archive(native) = "frama-c.cmxa" + plugin(native) = "frama-c.cmxs" + directory="" +) + +directory="" diff --git a/share/Makefile.config.in b/share/Makefile.config.in index 13eda479d2ab98e0c3fcbd8be80b5646da605d1e..9d321679ed94e0bd3c09e788c50172408cd44421 100644 --- a/share/Makefile.config.in +++ b/share/Makefile.config.in @@ -38,10 +38,10 @@ prefix ?=@prefix@ exec_prefix ?=@exec_prefix@ datarootdir ?=@datarootdir@ datadir ?=@datadir@ -BINDIR ?="$(DESTDIR)@bindir@" -LIBDIR ?="$(DESTDIR)@libdir@" -DATADIR ?="$(DESTDIR)@datarootdir@" -MANDIR ?="$(DESTDIR)@mandir@" +BINDIR ?=$(DESTDIR)@bindir@ +LIBDIR ?=$(DESTDIR)@libdir@ +DATADIR ?=$(DESTDIR)@datarootdir@ +MANDIR ?=$(DESTDIR)@mandir@ FRAMAC_LIBDIR ?=$(LIBDIR)/frama-c FRAMAC_PLUGINDIR ?=$(FRAMAC_LIBDIR)/plugins @@ -65,6 +65,8 @@ OCAMLDEP ?=@OCAMLDEP@ -slash OCAMLLEX ?=@OCAMLLEX@ OCAMLYACC ?=@OCAMLYACC@ OCAMLMKTOP ?=@OCAMLMKTOP@ +OCAMLMKLIB ?=@OCAMLFIND@ ocamlmklib +OCAMLFIND ?=@OCAMLFIND@ OCAMLDOC ?=@OCAMLDOC@ OCAMLCP ?=@OCAMLCP@ diff --git a/share/Makefile.dynamic b/share/Makefile.dynamic index d67115ac9a983e357817f5254917ebb55a28acb3..4ebe6147bc6d2b7b10b77c5c0c9e035d93765a01 100644 --- a/share/Makefile.dynamic +++ b/share/Makefile.dynamic @@ -46,6 +46,7 @@ ifeq ($(FRAMAC_INTERNAL),yes) PLUGIN_RESET :=yes else + # The plugin is compiled from an installed frama-c PLUGIN_RESET :=no include $(MAKECONFIG_DIR)/Makefile.common @@ -186,11 +187,11 @@ $(eval $(call include_generic_plugin_Makefile,$(PLUGIN_NAME))) TARGETS := $(TARGET_META) $(TARGET_CMI) TARGETS_TOP := $(TARGET_TOP_CMO) $(TARGET_TOP_CMX) \ - $(TARGET_TOP_CMA) $(TARGET_TOP_CMXS) + $(TARGET_TOP_CMA) $(TARGET_TOP_CMXS) $(TARGET_TOP_O) TARGETS_GUI_BYTE := $(TARGET_GUI_CMI) $(TARGET_GUI_CMO) -TARGETS_GUI := $(TARGETS_GUI_BYTE) $(TARGET_GUI_CMX) $(TARGET_GUI_CMXS) +TARGETS_GUI := $(TARGETS_GUI_BYTE) $(TARGET_GUI_CMX) $(TARGET_GUI_CMXS) $(TARGET_GUI_O) TARGETS_BYTE:= $(TARGET_META) $(TARGET_CMI) $(TARGET_TOP_CMO) $(TARGET_TOP_CMA) -TARGETS_OPT:= $(TARGET_META) $(TARGET_CMI) $(TARGET_TOP_CMX) $(TARGET_TOP_CMXS) +TARGETS_OPT:= $(TARGET_META) $(TARGET_CMI) $(TARGET_TOP_CMX) $(TARGET_TOP_CMXS) $(TARGET_TOP_O) byte:: $(TARGETS_BYTE) opt:: $(TARGETS_OPT) diff --git a/share/Makefile.dynamic_config.external b/share/Makefile.dynamic_config.external index 5cb3d96418aa16cf410ee7a9b372fe8e2ea8797e..e76a1aa89899864ff5f1c29830e04a997b0f855c 100644 --- a/share/Makefile.dynamic_config.external +++ b/share/Makefile.dynamic_config.external @@ -29,13 +29,16 @@ export FRAMAC_INCLUDES=-I "$(FRAMAC_LIBDIR)" export PTESTS=$(BINDIR)/ptests.$(PTESTSBEST)$(EXE) -export FRAMAC_LIB="$(FRAMAC_LIBDIR)" +export FRAMAC_LIB=$(FRAMAC_LIBDIR) export DOC_DIR=$(FRAMAC_SHARE)/doc/code export PLUGIN_LIB_DIR=$(PLUGIN_DIR) export FRAMAC_COMPILED_PLUGINDIR=$(FRAMAC_LIBDIR)/plugins +export OCAMLPATH:=$(FRAMAC_LIB):$(FRAMAC_PLUGINDIR)$(if $(OCAMLPATH),:,)$(OCAMLPATH) +export OCAMLFIND_IGNORE_DUPS_IN:=$(FRAMAC_LIB):$(FRAMAC_PLUGINDIR)$(if $(OCAMLFIND_IGNORE_DUPS_IN),:,)$(OCAMLFIND_IGNORE_DUPS_IN) + # fake target corresponding to the clean-install of Frama-C's Makefile .PHONY: clean-install clean-install: ; diff --git a/share/Makefile.dynamic_config.internal b/share/Makefile.dynamic_config.internal index 75a0df9fbfd0f890cceffc8c7eaef42d2b96b4e9..6c50e7bba80c9ccea20a91c6c08111c773703ba3 100644 --- a/share/Makefile.dynamic_config.internal +++ b/share/Makefile.dynamic_config.internal @@ -36,6 +36,9 @@ export PLUGIN_LIB_DIR=$(FRAMAC_ROOT_SRCDIR)/lib/plugins export FRAMAC_COMPILED_PLUGINDIR=$(FRAMAC_ROOT_SRCDIR)/lib/plugins +export OCAMLPATH:=$(FRAMAC_LIB):$(PLUGIN_LIB_DIR)$(if $(OCAMLPATH),:,)$(OCAMLPATH) +export OCAMLFIND_IGNORE_DUPS_IN:=$(FRAMAC_LIB):$(PLUGIN_LIB_DIR)$(if $(OCAMLFIND_IGNORE_DUPS_IN),:,)$(OCAMLFIND_IGNORE_DUPS_IN) + ########################################################################## # Local Variables: # mode: makefile diff --git a/share/Makefile.plugin.template b/share/Makefile.plugin.template index efc8670691bc9d1d79d7bb8caa8dd829d05f3620..df7931022fe0916c4305b2b531a9c302032d2a14 100644 --- a/share/Makefile.plugin.template +++ b/share/Makefile.plugin.template @@ -183,18 +183,26 @@ PLUGIN_RESET?=yes # Set it to no in order to NOT reset plug-in variable. # ############################################################################### + +DEPEND_PKG := $(addprefix frama-c-, $(shell echo $(PLUGIN_DEPENDENCIES) | tr '[:upper:]' '[:lower:]')) + # Where the other plug-ins to load are already installed ifeq ($(FRAMAC_INTERNAL),yes) INSTALLED_PLUGIN_DIR:=$(FRAMAC_ROOT_SRCDIR)/lib/plugins # Also inform the main Makefile that there's another plug-in to be # considered PLUGIN_LIST+=$(PLUGIN_DIR)/@PLUGIN_NAME@ +PLUGIN_PACKAGES:=$(PLUGIN_REQUIRES) + else INSTALLED_PLUGIN_DIR:=$(PLUGIN_INSTALL_DIR) +PLUGIN_PACKAGES:=$(PLUGIN_REQUIRES) $(DEPEND_PKG) endif +PLUGIN_REQUIRES += $(DEPEND_PKG) + # The plugin types .cm* files PLUGIN_TYPES_CMO:=$(addsuffix .cmo,$(PLUGIN_TYPES_CMO)) PLUGIN_TYPES_CMX:=$(PLUGIN_TYPES_CMO:.cmo=.cmx) @@ -213,6 +221,8 @@ $(notdir $(patsubst %/,%,$(PLUGIN_DIR))))) PLUGIN_DEPENDS:=$(PLUGIN_DEPENDS) $(PLUGIN_DEPENDENCIES) + + ################ # ml sources # ################ @@ -389,6 +399,8 @@ endif # Some meta-variables for compilation flags NAME_BFLAGS :=@PLUGIN_NAME@_BFLAGS NAME_OFLAGS :=@PLUGIN_NAME@_OFLAGS +NAME_TEST_BFLAGS :=@PLUGIN_NAME@_TEST_BFLAGS +NAME_TEST_OFLAGS :=@PLUGIN_NAME@_TEST_OFLAGS TARGET_OFLAGS :=@PLUGIN_NAME@_TARGET_OFLAGS TARGET_BFLAGS :=@PLUGIN_NAME@_TARGET_BFLAGS ifeq ($(HAS_GUI),yes) @@ -424,12 +436,16 @@ endif PLUGIN_EXTRA_DIRS_INC:=$(patsubst %,-I $(PLUGIN_DIR)/% ,$(PLUGIN_EXTRA_DIRS)) # Set the compilation flags for the plugin -INCLUDE_FLAGS:=-I $(PLUGIN_DIR) -I $(INSTALLED_PLUGIN_DIR) \ - $(PLUGIN_EXTRA_DIRS_INC) \ - $(addprefix -package ,$(PLUGIN_REQUIRES) $(LIBRARY_NAMES)) - +INCLUDE_EXT_FLAGS:=-I $(INSTALLED_PLUGIN_DIR) \ + $(addprefix -package ,$(PLUGIN_PACKAGES) $(LIBRARY_NAMES)) +INCLUDE_FLAGS:=-I $(PLUGIN_DIR) $(PLUGIN_EXTRA_DIRS_INC) $(INCLUDE_EXT_FLAGS) $(NAME_BFLAGS):=$(BFLAGS) $(INCLUDE_FLAGS) $(PLUGIN_BFLAGS) $(NAME_OFLAGS):=$(OFLAGS) $(INCLUDE_FLAGS) $(PLUGIN_OFLAGS) +# DO NOT include the plugin's own directory as search path for compiling +# ml test scripts: they will be loaded in a separate phase, and will only see +# the plugin through its static API +$(NAME_TEST_BFLAGS):= $(BFLAGS) $(INCLUDE_EXT_FLAGS) $(PLUGIN_BFLAGS) +$(NAME_TEST_OFLAGS):= $(OFLAGS) $(INCLUDE_EXT_FLAGS) $(PLUGIN_OFLAGS) $(TARGET_BFLAGS):= $(PLUGIN_LINK_BFLAGS) $(TARGET_OFLAGS):= $(PLUGIN_LINK_OFLAGS) @@ -459,9 +475,8 @@ endif # META file PLUGIN_PKG :=$(shell echo frama-c-@PLUGIN_NAME@ | tr '[:upper:]' '[:lower:]') -DEPEND_PKG :=$(shell echo $(PLUGIN_DEPENDENCIES) | tr '[:upper:]' '[:lower:]') -PLUGIN_REQUIRES += $(addprefix frama-c-,$(DEPEND_PKG)) TARGET_META :=$(PLUGIN_LIB_DIR)/META.$(PLUGIN_PKG) +PLUGIN_GENERATED+= $(TARGET_META) ifneq ($(PLUGIN_HAS_META),yes) # generated META @@ -510,7 +525,7 @@ $(TARGET_META): $(RM) $@ $(ECHO) "description = \"$($(notdir $@).DESCRIPTION)\"" >> $@ $(ECHO) "version = \"$($(notdir $@).VERSION)\"" >> $@ - $(ECHO) "requires = \"$($(notdir $@).REQUIRES)\"" >> $@ + $(ECHO) "requires = \"frama-c.kernel $($(notdir $@).REQUIRES)\"" >> $@ $(ECHO) "archive(byte) = \"top/$($(notdir $@).BYTE)\"" >> $@ $(ECHO) "archive(native) = \"top/$($(notdir $@).NATIVE)\"" >> $@ $(ECHO) "plugin(native) = \"top/$($(notdir $@).PLUGIN)\"" >> $@ @@ -854,9 +869,9 @@ endif @PLUGIN_NAME@_TESTS_LIB_OPT_DYN:=$(PLUGIN_TESTS_LIB:%.ml=%.cmxs) @PLUGIN_NAME@_TESTS_LIB_BYTE:=$(PLUGIN_TESTS_LIB:%.ml=%.cmo) -$(@PLUGIN_NAME@_TESTS_LIB_OPT): OFLAGS:=$($(NAME_OFLAGS)) $(@PLUGIN_NAME@_TESTS_LIB_DIR_INCLUDE) -$(@PLUGIN_NAME@_TESTS_LIB_OPT_DYN): OFLAGS:=$($(NAME_OFLAGS)) $(@PLUGIN_NAME@_TESTS_LIB_DIR_INCLUDE) -$(@PLUGIN_NAME@_TESTS_LIB_BYTE): BFLAGS:=$($(NAME_BFLAGS)) $(@PLUGIN_NAME@_TESTS_LIB_DIR_INCLUDE) +$(@PLUGIN_NAME@_TESTS_LIB_OPT): OFLAGS:=$($(NAME_TEST_OFLAGS)) $(@PLUGIN_NAME@_TESTS_LIB_DIR_INCLUDE) +$(@PLUGIN_NAME@_TESTS_LIB_OPT_DYN): OFLAGS:=$($(NAME_TEST_OFLAGS)) $(@PLUGIN_NAME@_TESTS_LIB_DIR_INCLUDE) +$(@PLUGIN_NAME@_TESTS_LIB_BYTE): BFLAGS:=$($(NAME_TEST_BFLAGS)) $(@PLUGIN_NAME@_TESTS_LIB_DIR_INCLUDE) # [JS 2009/03/18] both .PRECIOUS are required in order to prevent 'make' # deletion of intermediate generated files. Such a deletion forces 'make' to @@ -981,7 +996,7 @@ endif #EXTRA_BYTE endif #HAS_GUI PLUGIN_DYN_DEP_GUI_CMX_LIST += $(PLUGIN_GUI_CMX) -PLUGIN_DYN_CMX_LIST += $(TARGET_TOP_CMXS) $(TARGET_TOP_CMX) +PLUGIN_DYN_CMX_LIST += $(TARGET_TOP_CMXS) $(TARGET_TOP_CMX) $(TARGET_TOP_O) # If P1 depends on P2, then dynamically link P1.cmxs requires to have # compiled P1's sources wrt the P2's .cmx. ifeq ($(HAS_GUI),yes) diff --git a/src/kernel_internals/runtime/config.ml.in b/src/kernel_internals/runtime/config.ml.in index 75a6064a73d0dfbea83c2f71659b94de53c11146..c0f5852814ae1f34681f122f7a672be1ee95ed92 100644 --- a/src/kernel_internals/runtime/config.ml.in +++ b/src/kernel_internals/runtime/config.ml.in @@ -36,28 +36,41 @@ let ocamlc = "@OCAMLC@" let ocamlopt = "@OCAMLOPT@" let ocaml_wflags = "@WARNINGS@" +let getenv_list name = + let path = Sys.getenv name in + Str.split (Str.regexp ":") path + +let add_symbolic_dir_list name = function + | [d] -> Filepath.add_symbolic_dir name d + | ds -> + List.iteri + (fun i d -> + let path = Printf.sprintf "%s#%d" name (succ i) in + Filepath.add_symbolic_dir path d) + ds + + let datadir = try Sys.getenv "FRAMAC_SHARE" with Not_found -> "@FRAMAC_DATADIR@" +let framac_libc = datadir ^ "/libc" +let extra_datadir = try getenv_list "FRAMAC_EXTRA_SHARE" with Not_found -> [] +let () = add_symbolic_dir_list "FRAMAC_EXTRA_SHARE" extra_datadir +(** After so that it has the priority for pretty printing *) let () = Filepath.add_symbolic_dir "FRAMAC_SHARE" datadir + +let datadirs = datadir::extra_datadir + let libdir = try Sys.getenv "FRAMAC_LIB" with Not_found -> "@FRAMAC_LIBDIR@" let () = Filepath.add_symbolic_dir "FRAMAC_LIB" libdir let plugin_dir = try - let path = Sys.getenv "FRAMAC_PLUGIN" in - Str.split (Str.regexp ":") path + getenv_list "FRAMAC_PLUGIN" with Not_found -> try [ Sys.getenv "FRAMAC_LIB" ^ "/plugins" ] with Not_found -> [ "@FRAMAC_PLUGINDIR@" ] let plugin_path = String.concat ":" plugin_dir -let () = match plugin_dir with - | [d] -> Filepath.add_symbolic_dir "FRAMAC_PLUGIN" d - | ds -> - Array.iteri - (fun i d -> - let path = Printf.sprintf "FRAMAC_PLUGIN#%d" (succ i) in - Filepath.add_symbolic_dir path d) - (Array.of_list ds) +let () = add_symbolic_dir_list "FRAMAC_PLUGIN" plugin_dir let default_cpp = "@FRAMAC_DEFAULT_CPP@" diff --git a/src/kernel_internals/runtime/config.mli b/src/kernel_internals/runtime/config.mli index ecdad0fbd184ddd7db887189689a1f4d0bcbb9c6..d223daf3b963e3919f947abc024a05619d04c9f4 100644 --- a/src/kernel_internals/runtime/config.mli +++ b/src/kernel_internals/runtime/config.mli @@ -59,7 +59,17 @@ val ocaml_wflags: string @since Chlorine-20180501 *) val datadir: string - (** Directory where architecture independent files are. *) + (** Directory where architecture independent files are. + Main directory, use {!datadirs} for the others *) + +val datadirs: string list + (** Directories where architecture independent files are in order of + priority. + @since Frama-C-trunk*) + +val framac_libc: string + (** Directory where Frama-C libc headers are. + @since Frama-C-trunk*) val libdir: string (** Directory where the Frama-C kernel library is. diff --git a/src/kernel_internals/typing/cabs2cil.ml b/src/kernel_internals/typing/cabs2cil.ml index 0bdc611ed92bee320148dfab22327c22d55d1de1..984fef51c452bc6ffd8b2cab48b3e9c352650d11 100644 --- a/src/kernel_internals/typing/cabs2cil.ml +++ b/src/kernel_internals/typing/cabs2cil.ml @@ -315,7 +315,7 @@ let process_stdlib_pragma name args = match args with | [ ACons ("pop",_) ] -> pop_stdheader (); None | [ ACons ("push",_); AStr s ] -> - let base_name = Config.datadir ^ "/libc" in + let base_name = Config.framac_libc in let relative_name = Filepath.relativize ~base_name s in push_stdheader relative_name; None diff --git a/src/kernel_services/ast_queries/file.ml b/src/kernel_services/ast_queries/file.ml index 94b276dd1dea4ff0be79d7eb93166cdad8fce598..cc22eb64b92a5628a90b5cb3d00c82b73c678fbd 100644 --- a/src/kernel_services/ast_queries/file.ml +++ b/src/kernel_services/ast_queries/file.ml @@ -477,7 +477,7 @@ let parse_cabs = function (* Hypothesis: the preprocessor is POSIX compliant, hence understands -I and -D. *) let include_args = - if Kernel.FramaCStdLib.get () then [Config.datadir ^ "/libc"] + if Kernel.FramaCStdLib.get () then [Config.framac_libc] else [] in let define_args = diff --git a/src/kernel_services/plugin_entry_points/dynamic.ml b/src/kernel_services/plugin_entry_points/dynamic.ml index 86c5091279c38e3f1fb11213df420506aff6acaa..5666e51558b4c86c74e925a73b5c5f36d71bb469 100644 --- a/src/kernel_services/plugin_entry_points/dynamic.ml +++ b/src/kernel_services/plugin_entry_points/dynamic.ml @@ -125,7 +125,7 @@ let is_object base = let packages = Hashtbl.create 64 -let () = List.iter (fun p -> Hashtbl.add packages p ()) Config.library_names +let () = List.iter (fun p -> Hashtbl.add packages p ()) ("frama-c.kernel"::Config.library_names) let missing pkg = not (Hashtbl.mem packages pkg) @@ -281,8 +281,9 @@ let set_module_load_path path = Klog.debug ~dkey "plugin_dir: %s" (String.concat ":" Config.plugin_dir); load_path := List.fold_right (add_dir ~user:true) path - (List.fold_right (add_dir ~user:false) Config.plugin_dir []); - let findlib_path = String.concat ":" !load_path in + (List.fold_right (add_dir ~user:false) (Config.libdir::Config.plugin_dir) []); + let env_ocamlpath = try Str.split (Str.regexp ":") (Sys.getenv "OCAMLPATH") with Not_found -> [] in + let findlib_path = String.concat ":" (!load_path@env_ocamlpath) in Klog.debug ~dkey "setting findlib path to %s" findlib_path; Findlib.init ~env_ocamlpath:findlib_path () diff --git a/src/kernel_services/plugin_entry_points/plugin.ml b/src/kernel_services/plugin_entry_points/plugin.ml index 0efe77903f6e9bf4a2a66eec578ac4e70f50eaf5..6048de1b0a82fa0d40d1a4205d38cd22201f09d9 100644 --- a/src/kernel_services/plugin_entry_points/plugin.ml +++ b/src/kernel_services/plugin_entry_points/plugin.ml @@ -277,10 +277,10 @@ struct include Parameter_builder.Make (struct - let shortname = P.shortname - module L = L - let messages_group = messages - let parameters = plugin.p_parameters + let shortname = P.shortname + module L = L + let messages_group = messages + let parameters = plugin.p_parameters end) let prefix = @@ -297,7 +297,7 @@ struct module Make_specific_dir (O: Parameter_sig.Input_with_arg) (D: sig - val dir: unit -> string + val dirs: unit -> string list val visible_ref: bool val force_dir: bool end) @@ -325,44 +325,54 @@ struct let mk_dir d = try - Unix.mkdir d 0o755; - L.warning "creating %s directory `%s'" O.option_name d; - d + Unix.mkdir d 0o755; + L.warning "creating %s directory `%s'" O.option_name d; + d with Unix.Unix_error _ -> - L.warning "cannot create %s directory `%s'" O.option_name d; - raise No_dir - - let get_and_check_dir ?(error=true) d = - (* DO NOT Filepath.normalize the argument, since it can transform an - absolute path into a relative one, leading to issues if a chdir occurs - at some point. *) - if (try Sys.is_directory d with Sys_error _ -> false) then d - else - if error then - L.abort "no %s directory `%s' for plug-in `%s'" - O.option_name - d - P.name - else begin - if force_dir then begin - (* create the parent, if it does not exist *) - let p = Filename.dirname d in - if not (try Sys.is_directory p with Sys_error _ -> false) then - ignore (mk_dir p); - mk_dir d - end else - raise No_dir - end + L.warning "cannot create %s directory `%s'" O.option_name d; + raise No_dir + + let rec get_and_check_dirs error = function + | [] -> + raise No_dir + | d::l -> + if (try Sys.is_directory d with Sys_error _ -> false) then d + else + get_and_check_dirs error l + + let get_and_check_dirs ?(error=true) = function + | [] -> + if error then + L.abort "no %s directories to look into" O.option_name + else + raise No_dir + | (first::_) as l -> + try + get_and_check_dirs error l + with + | No_dir when error -> + L.abort "no %s directory for plug-in `%s' among %a" + O.option_name + P.name + Pretty_utils.(pp_list ~sep:",@ " Format.pp_print_string) l + | No_dir when force_dir -> + (* create the parent, if it does not exist *) + let p = Filename.dirname first in + if not (try Sys.is_directory p with Sys_error _ -> false) then + ignore (mk_dir p); + mk_dir first let dir ?error () = (* get the specified dir if any *) let d = if is_visible then Dir_name.get () else empty_string in if d = empty_string then - (* no specified dir: look for the default one. *) - if is_kernel then get_and_check_dir ?error (D.dir ()) - else get_and_check_dir ?error (D.dir () ^ "/" ^ plugin_subpath) + (* no specified dir: look for the default one. *) + if is_kernel then get_and_check_dirs ?error (D.dirs ()) + else + let dirs = List.map (fun x -> x ^ "/" ^ plugin_subpath) (D.dirs ()) in + get_and_check_dirs ?error dirs else - get_and_check_dir ?error d + get_and_check_dirs ?error [d] let file ?error f = dir ?error () ^ "/" ^ f @@ -371,32 +381,32 @@ struct module Share = Make_specific_dir (struct - let option_name = "share" - let arg_name = "dir" - let help = "set the plug-in share directory to <dir> \ + let option_name = "share" + let arg_name = "dir" + let help = "set the plug-in share directory to <dir> \ (may be used if the plug-in is not installed at the same place as Frama-C)" end) (struct - let dir () = Config.datadir - let visible_ref = !share_visible_ref - let force_dir = false + let dirs () = Config.datadirs + let visible_ref = !share_visible_ref + let force_dir = false end) module Session = Make_specific_dir (struct - let option_name = "session" - let arg_name = "dir" - let help = "set the plug-in session directory to <dir>" + let option_name = "session" + let arg_name = "dir" + let help = "set the plug-in session directory to <dir>" end) (struct - let dir () = - if !session_is_set_ref () then !session_ref () - else - try Sys.getenv "FRAMAC_SESSION" - with Not_found -> "./.frama-c" - let visible_ref = !session_visible_ref - let force_dir = true + let dirs () = [ + if !session_is_set_ref () then !session_ref () + else + try Sys.getenv "FRAMAC_SESSION" + with Not_found -> "./.frama-c"] + let visible_ref = !session_visible_ref + let force_dir = true end) let () = if is_kernel () then Journal.get_session_file := Session.file ~error:false @@ -404,29 +414,30 @@ struct module Config = Make_specific_dir (struct - let option_name = "config" - let arg_name = "dir" - let help = "set the plug-in config directory to <dir> \ + let option_name = "config" + let arg_name = "dir" + let help = "set the plug-in config directory to <dir> \ (may be used on systems with no default user directory)" end) (struct - let dir () = - let d, vis = - if !config_is_set_ref () then !config_ref (), false - else - try Sys.getenv "FRAMAC_CONFIG", false - with Not_found -> - try Sys.getenv "USERPROFILE", false (* Win32 *) - with Not_found -> - (* Unix like *) - try Sys.getenv "XDG_CONFIG_HOME", true - with Not_found -> - try Sys.getenv "HOME" ^ "/.config", true - with Not_found -> ".", false - in - d ^ if vis then "/frama-c" else "/.frama-c" - let visible_ref = !config_visible_ref - let force_dir = true + let dirs () = [ + let d, vis = + if !config_is_set_ref () then !config_ref (), false + else + try Sys.getenv "FRAMAC_CONFIG", false + with Not_found -> + try Sys.getenv "USERPROFILE", false (* Win32 *) + with Not_found -> + (* Unix like *) + try Sys.getenv "XDG_CONFIG_HOME", true + with Not_found -> + try Sys.getenv "HOME" ^ "/.config", true + with Not_found -> ".", false + in + d ^ if vis then "/frama-c" else "/.frama-c" + ] + let visible_ref = !config_visible_ref + let force_dir = true end) let help = add_group "Getting Information" @@ -588,10 +599,10 @@ struct (* line order below matters *) set_range ~min:0 ~max:max_int; if is_kernel () then begin - Cmdline.kernel_verbose_atleast_ref := (fun n -> get () >= n); - match !Cmdline.Kernel_verbose_level.value_if_set with - | None -> () - | Some n -> set n + Cmdline.kernel_verbose_atleast_ref := (fun n -> get () >= n); + match !Cmdline.Kernel_verbose_level.value_if_set with + | None -> () + | Some n -> set n end end @@ -614,15 +625,15 @@ struct set_range ~min:0 ~max:max_int; add_set_hook (fun old n -> - (* the level of verbose is at least the level of debug *) - if n > Verbose.get () then Verbose.set n; + (* the level of verbose is at least the level of debug *) + if n > Verbose.get () then Verbose.set n; if n = 0 then Pervasives.decr positive_debug_ref else if old = 0 then Pervasives.incr positive_debug_ref); if is_kernel () then begin - Cmdline.kernel_debug_atleast_ref := (fun n -> get () >= n); - match !Cmdline.Kernel_debug_level.value_if_set with - | None -> () - | Some n -> set n + Cmdline.kernel_debug_atleast_ref := (fun n -> get () >= n); + match !Cmdline.Kernel_debug_level.value_if_set with + | None -> () + | Some n -> set n end end diff --git a/src/libraries/stdlib/integer.ml b/src/libraries/stdlib/integer.ml index 55d36122770094da3949f3540941b9fdc0bdccbd..1a7e593f79aede19b4ecddaf53d51964fa7020ce 100644 --- a/src/libraries/stdlib/integer.ml +++ b/src/libraries/stdlib/integer.ml @@ -109,17 +109,85 @@ let popcount = Z.popcount raises multiple [Failure _] exceptions *) failwith "Integer.of_string" - let max_int64 = of_int64 Int64.max_int let min_int64 = of_int64 Int64.min_int - let to_string = Z.to_string let to_float = Z.to_float let of_float z = try Z.of_float z with Z.Overflow -> raise Too_big + let bdigits = [| + "0000" ; (* 0 *) + "0001" ; (* 1 *) + "0010" ; (* 2 *) + "0011" ; (* 3 *) + "0100" ; (* 4 *) + "0101" ; (* 5 *) + "0110" ; (* 6 *) + "0111" ; (* 7 *) + "1000" ; (* 8 *) + "1001" ; (* 9 *) + "1010" ; (* 10 *) + "1011" ; (* 11 *) + "1100" ; (* 12 *) + "1101" ; (* 13 *) + "1110" ; (* 14 *) + "1111" ; (* 15 *) + |] + + let pp_bin_pos fmt r = Format.pp_print_string fmt bdigits.(r) + let pp_bin_neg fmt r = Format.pp_print_string fmt bdigits.(15-r) + + let pp_hex_pos fmt r = Format.fprintf fmt "%04X" r + let pp_hex_neg fmt r = Format.fprintf fmt "%04X" (0xFFFF-r) + + let bmask_bin = Z.of_int 0xF (* 4 bits mask *) + let bmask_hex = Z.of_int 0xFFFF (* 64 bits mask *) + + type digits = { + nbits : int ; (* max number of bits *) + bsize : int ; (* bits in each bloc *) + bmask : Z.t ; (* block mask, must be (1 << bsize) - 1 *) + sep : string ; + pp : Format.formatter -> int -> unit ; (* print one block *) + } + + let rec pp_digits d fmt n v = + if gt v zero || n < d.nbits then + begin + let r = Z.to_int (Z.logand v d.bmask) in + let k = d.bsize in + pp_digits d fmt (n + k) (Z.shift_right_trunc v k) ; + if gt v d.bmask || (n + k) < d.nbits + then Format.pp_print_string fmt d.sep ; + d.pp fmt r ; + end + + let pp_bin ?(nbits=1) ?(sep="") fmt v = + let nbits = if nbits <= 0 then 1 else nbits in + if le zero v then + ( Format.pp_print_string fmt "0b" ; + pp_digits { nbits ; sep ; bsize=4 ; + bmask = bmask_bin ; pp = pp_bin_pos } fmt 0 v ) + else + ( Format.pp_print_string fmt "1b" ; + pp_digits { nbits ; sep ; bsize=4 ; + bmask = bmask_bin ; pp = pp_bin_neg } fmt 0 (Z.lognot v) ) + + let pp_hex ?(nbits=1) ?(sep="") fmt v = + let nbits = if nbits <= 0 then 1 else nbits in + if le zero v then + ( Format.pp_print_string fmt "0x" ; + pp_digits { nbits ; sep ; bsize=16 ; + bmask = bmask_hex ; pp = pp_hex_pos } fmt 0 v ) + + else + ( Format.pp_print_string fmt "1x" ; + pp_digits { nbits ; sep ; bsize=16 ; + bmask = bmask_hex ; pp = pp_hex_neg } fmt 0 (Z.lognot v) ) + let pretty ?(hexa=false) fmt v = let rec aux v = if gt v two_power_60 then diff --git a/src/libraries/stdlib/integer.mli b/src/libraries/stdlib/integer.mli index 4e939382bf131017b673f534505420f04c0df94c..3ed0f1297471b8c393056437955eec4085c79363 100644 --- a/src/libraries/stdlib/integer.mli +++ b/src/libraries/stdlib/integer.mli @@ -150,8 +150,23 @@ val popcount: t -> int val pretty : ?hexa:bool -> t Pretty_utils.formatter - +val pp_bin : ?nbits:int -> ?sep:string -> t Pretty_utils.formatter +(** Print binary format. Digits are output by blocs of 4 bits + separated by [~sep] with at least [~nbits] total bits. If [nbits] is + non positive, it will be ignored. + + Positive values are prefixed with ["0b"] and negative values + are printed as their 2-complement ([lnot]) with prefix ["1b"]. *) + +val pp_hex : ?nbits:int -> ?sep:string -> t Pretty_utils.formatter +(** Print hexadecimal format. Digits are output by blocs of 16 bits + (4 hex digits) separated by [~sep] with at least [~nbits] total bits. + If [nbits] is non positive, it will be ignored. + + Positive values are preffixed with ["0x"] and negative values + are printed as their 2-complement ([lnot]) with prefix ["1x"]. *) (* + Local Variables: compile-command: "make -C ../../.." End: diff --git a/src/plugins/aorai/Makefile.in b/src/plugins/aorai/Makefile.in index 5478d009fa7e206bca7df4310e9062b357370d6a..423244b822a3af9883971dd6deabac001cfed778 100644 --- a/src/plugins/aorai/Makefile.in +++ b/src/plugins/aorai/Makefile.in @@ -80,7 +80,7 @@ PLUGIN_NO_DEFAULT_TEST:=yes endif PLUGIN_TESTS_DIRS:=aorai -PLUGIN_TESTS_LIB:=$(PLUGIN_DIR)/tests/aorai/Aorai_test.ml +PLUGIN_TESTS_LIB:=$(PLUGIN_DIR)/tests/aorai/Aorai_test.ml $(PLUGIN_DIR)/tests/aorai/name_projects.ml include $(FRAMAC_SHARE)/Makefile.dynamic @@ -101,7 +101,7 @@ $(Aorai_DIR)/tests/test_config_prove: \ $(SED) -e 's!@AORAI_WP_SHARE@!$(AORAI_WP_SHARE)!' $< > $@ $(CHMOD_RO) $@ -Aorai_DEFAULT_TESTS: $(Aorai_DIR)/tests/aorai/Aorai_test.cmxs $(Aorai_DIR)/tests/aorai/Aorai_test.cmo +Aorai_DEFAULT_TESTS: $(Aorai_DIR)/tests/aorai/Aorai_test.cmxs $(Aorai_DIR)/tests/aorai/Aorai_test.cmo $(Aorai_DIR)/tests/aorai/name_projects.cmxs $(Aorai_DIR)/tests/aorai/name_projects.cmo # Regenerating the Makefile on need diff --git a/src/plugins/aorai/tests/aorai/assigns.c b/src/plugins/aorai/tests/aorai/assigns.c index 7eb67e2087bbaa0ad8c729ab2efbf1bff2d8b1e9..c8d63fdb9dba75b9fb13a0021f32cf20f1435241 100644 --- a/src/plugins/aorai/tests/aorai/assigns.c +++ b/src/plugins/aorai/tests/aorai/assigns.c @@ -1,7 +1,8 @@ /* run.config* + EXECNOW: make -s @PTEST_DIR@/name_projects.cmxs OPT: -aorai-automata tests/aorai/assigns.ya -aorai-test 1 -load-module tests/aorai/Aorai_test.cmxs -aorai-test-number @PTEST_NUMBER@ @PROVE_OPTIONS@ OPT: -aorai-automata tests/aorai/assigns_det.ya -aorai-test 1 -load-module tests/aorai/Aorai_test.cmxs -aorai-test-number @PTEST_NUMBER@ @PROVE_OPTIONS@ - OPT: -aorai-automata tests/aorai/assigns.ya -load-script tests/aorai/name_projects.ml -aorai-test 1 -then -print + OPT: -aorai-automata tests/aorai/assigns.ya -load-module @PTEST_DIR@/name_projects -aorai-test 1 -then -print */ int X; diff --git a/src/plugins/qed/term.ml b/src/plugins/qed/term.ml index 045f0d2ff31bd97cf122a018ae543aa756bea6e3..99e54cad0af764e053ee1dafc7e361387e30b2e1 100644 --- a/src/plugins/qed/term.ml +++ b/src/plugins/qed/term.ml @@ -2540,7 +2540,8 @@ struct | (Bool|Prop) , (Bool|Prop) -> Prop | Int , Int -> Int | (Int|Real) , (Int|Real) -> Real - | _ -> raise Not_found + | _ -> + if Tau.equal a b then a else raise Not_found let rec merge_list t f = function | [] -> t diff --git a/src/plugins/wp/Cfloat.ml b/src/plugins/wp/Cfloat.ml index 6b98659afcd9cdbe5d55cd201c34ad8535ad708f..7c5a2c9f5a357dfe0080eb176d23012816b2740c 100644 --- a/src/plugins/wp/Cfloat.ml +++ b/src/plugins/wp/Cfloat.ml @@ -35,24 +35,29 @@ open Lang.F let library = "cfloat" -let result = Logic.Real -let params = [Logic.Sreal;Logic.Sreal] (* We can provide more parameters *) -let link f = Lang.infoprover (Qed.Engine.F_call f) +let f32 = datatype ~library "f32" +let f64 = datatype ~library "f64" -let make_fun_float name f = - extern_f ~library ~result ~params "%s_%a" name Ctypes.pp_float f +let t32 = Lang.(t_datatype f32 []) +let t64 = Lang.(t_datatype f64 []) -let make_pred_float name f = - extern_f ~library ~result:Logic.Prop ~params "%s_%a" name Ctypes.pp_float f +let ftau = function + | Float32 -> t32 + | Float64 -> t64 -let f_model = - extern_f ~library ~result ~params ~link:(link "model") "\\model" +let suffix fmt = function + | Float32 -> Format.pp_print_string fmt "f32" + | Float64 -> Format.pp_print_string fmt "f64" -let f_delta = - extern_f ~library ~result ~params ~link:(link "delta") "\\delta" +let link phi = Lang.infoprover (Qed.Engine.F_call phi) -let f_epsilon = - extern_f ~library ~result ~params ~link:(link "epsilon") "\\epsilon" +(* Qed exact representations, linked to f32/f64 *) +let fq32 = extern_f ~library ~result:t32 ~link:(link "to_f32") "q32" +let fq64 = extern_f ~library ~result:t64 ~link:(link "to_f64") "q64" + +let f_model ft = extern_f ~library ~result:(ftau ft) "model_%a" suffix ft +let f_delta ft = extern_f ~library ~result:(ftau ft) "delta_%a" suffix ft +let f_epsilon ft = extern_f ~library ~result:(ftau ft) "epsilon_%a" suffix ft (* -------------------------------------------------------------------------- *) (* --- Model Setting --- *) @@ -60,22 +65,83 @@ let f_epsilon = type model = Real | Float -let model = Context.create ~default:Real "Cfloat.model" +let model = Context.create ~default:Float "Cfloat.model" + +let tau_of_float f = + match Context.get model with + | Real -> Logic.Real + | Float -> ftau f + +(* -------------------------------------------------------------------------- *) +(* --- Operators --- *) +(* -------------------------------------------------------------------------- *) + +type op = + | LT + | EQ + | LE + | NE + | NEG + | ADD + | MUL + | DIV + | REAL + | ROUND + | EXACT + +[@@@ warning "-32"] +let op_name = function + | LT -> "flt" + | EQ -> "feq" + | LE -> "fle" + | NE -> "fne" + | NEG -> "fneg" + | ADD -> "fadd" + | MUL -> "fmul" + | DIV -> "fdiv" + | REAL -> "freal" + | ROUND -> "fround" + | EXACT -> "fexact" +[@@@ warning "+32"] (* -------------------------------------------------------------------------- *) -(* --- Literals --- *) +(* --- Registry --- *) (* -------------------------------------------------------------------------- *) -let code_lit = F.e_float +module REGISTRY = Model.Static + (struct + type key = lfun + type data = op * c_float + let name = "Wp.Cfloat.REGISTRY" + include Lang.Fun + end) + +let find = REGISTRY.find + +let () = Context.register + begin fun () -> + REGISTRY.define fq32 (EXACT,Float32) ; + REGISTRY.define fq64 (EXACT,Float64) ; + end + +(* -------------------------------------------------------------------------- *) +(* --- Literals --- *) +(* -------------------------------------------------------------------------- *) + +let rfloat = Floating_point.round_to_single_precision_float + +let fmake ulp value = match ulp with + | Float32 -> F.e_fun fq32 [F.e_float (rfloat value)] + | Float64 -> F.e_fun fq64 [F.e_float value] + +let qmake ulp q = fmake ulp (Transitioning.Q.to_float q) let mantissa = "\\([-+]?[0-9]*\\)" let comma = "\\(.\\(\\(0*[1-9]\\)*\\)0*\\)?" let exponent = "\\([eE]\\([-+]?[0-9]*\\)\\)?" let real = Str.regexp (mantissa ^ comma ^ exponent ^ "$") -let parse_literal l = - let open Cil_types in - let r = l.r_literal in +let parse_literal v r = try if Str.string_match real r 0 then let ma = Str.matched_group 1 r in @@ -88,120 +154,108 @@ let parse_literal l = let m = Q.of_string (ma ^ mb) in if n < 0 then Q.div m (d (-n)) else if n > 0 then Q.mul m (d n) else m - else Q.of_float l.r_nearest + else Q.of_float v with Failure _ -> - Warning.error ~source:"acsl" "Unexpected real literal %S" r + Warning.error "Unexpected constant literal %S" r -let acsl_lit l = F.e_real (parse_literal l) +let acsl_lit l = + let open Cil_types in + F.e_real (parse_literal l.r_nearest l.r_literal) + +let code_lit ulp value original = + match Context.get model , ulp , original with + | Float , Float32 , _ -> F.e_fun fq32 [F.e_float value] + | Float , Float64 , _ -> F.e_fun fq64 [F.e_float value] + | Real , _ , None -> F.e_float value + | Real , _ , Some r -> F.e_real (parse_literal value r) (* -------------------------------------------------------------------------- *) -(* --- Operators --- *) +(* --- Computations --- *) (* -------------------------------------------------------------------------- *) -let flt_rnd = Ctypes.f_memo (make_fun_float "to") -let flt_add = Ctypes.f_memo (make_fun_float "add") -let flt_mul = Ctypes.f_memo (make_fun_float "mul") -let flt_div = Ctypes.f_memo (make_fun_float "div") +let rec exact e = + match F.repr e with + | Qed.Logic.Kreal r -> r + | Qed.Logic.Kint z -> Q.of_bigint z + | Qed.Logic.Fun( f , [ q ] ) when f == fq32 || f == fq64 -> exact q + | _ -> raise Not_found -let () = - begin - let open LogicBuiltins in - add_builtin "\\model" [F Float32] f_model ; - add_builtin "\\model" [F Float64] f_model ; - add_builtin "\\delta" [F Float32] f_delta ; - add_builtin "\\delta" [F Float64] f_delta ; - add_builtin "\\epsilon" [F Float32] f_epsilon ; - add_builtin "\\epsilon" [F Float64] f_epsilon ; - end +let compute op ulp xs = + match op , xs with + | NEG , [ x ] -> qmake ulp (Q.neg (exact x)) + | ADD , [ x ; y ] -> qmake ulp (Q.add (exact x) (exact y)) + | MUL , [ x ; y ] -> qmake ulp (Q.mul (exact x) (exact y)) + | DIV , [ x ; y ] -> qmake ulp (Q.div (exact x) (exact y)) + | ROUND , [ x ] -> qmake ulp (exact x) + | REAL , [ x ] -> F.e_real (exact x) + | LE , [ x ; y ] -> F.e_bool (Q.leq (exact x) (exact y)) + | LT , [ x ; y ] -> F.e_bool (Q.lt (exact x) (exact y)) + | EQ , [ x ; y ] -> F.e_bool (Q.equal (exact x) (exact y)) + | NE , [ x ; y ] -> F.e_bool (not (Q.equal (exact x) (exact y))) + | _ -> raise Not_found (* -------------------------------------------------------------------------- *) -(* --- Floating Point Predicate --- *) +(* --- Operations --- *) (* -------------------------------------------------------------------------- *) -let fle _ = F.p_leq -let flt _ = F.p_lt -let feq _ = F.p_equal -let fneq _ = F.p_neq +let make_fun_float ?result name op ft = + let result = match result with None -> ftau ft | Some r -> r in + let phi = extern_f ~library ~result "%s_%a" name suffix ft in + Lang.F.set_builtin phi (compute op ft) ; + REGISTRY.define phi (op,ft) ; phi + +let make_pred_float name op ft = + let prop = Pretty_utils.sfprintf "%s_%a" name suffix ft in + let bool = Pretty_utils.sfprintf "%s_%ab" name suffix ft in + let phi = extern_p ~library ~bool ~prop () in + Lang.F.set_builtin phi (compute op ft) ; + REGISTRY.define phi (op,ft) ; phi + +let register = Ctypes.f_memo + +let real_of_flt = register (make_fun_float ~result:Logic.Real "of" REAL) +let flt_of_real = register (make_fun_float "to" ROUND) +let flt_add = register (make_fun_float "add" ADD) +let flt_mul = register (make_fun_float "mul" MUL) +let flt_div = register (make_fun_float "div" DIV) +let flt_neg = register (make_fun_float "neg" NEG) + +let flt_lt = register (make_pred_float "lt" LT) +let flt_eq = register (make_pred_float "eq" EQ) +let flt_le = register (make_pred_float "le" LE) +let flt_neq = register (make_pred_float "ne" NE) (* -------------------------------------------------------------------------- *) -(* --- Precision --- *) +(* --- Models --- *) (* -------------------------------------------------------------------------- *) -module OP = Model.Static - (struct - type key = Lang.lfun - type data = (term list -> term) - let name = "Wp.Cfloat.OP" - let compare = Lang.Fun.compare - let pretty = Lang.Fun.pretty - end) - -let define_fmodel_of fop op = +let () = begin - OP.define (fop Float32) op ; - OP.define (fop Float64) op ; + let open LogicBuiltins in + let register ft = + add_builtin "\\model" [F ft] (f_model ft) ; + add_builtin "\\delta" [F ft] (f_delta ft) ; + add_builtin "\\epsilon" [F ft] (f_epsilon ft) ; + in + register Float32 ; + register Float64 ; end -let builtin_model = function - | [e] -> - let open Qed.Logic in - begin match F.repr e with - | Fun(f,_) when f == f_model -> e - | Fun(f,_) when f == f_delta -> e_zero_real - | Fun(f,_) when f == f_epsilon -> e_zero_real - | Fun(op,xs) -> - let phi = OP.find op in - (* find phi before computing arguments *) - phi (List.map (fun e -> e_fun f_model [e]) xs) - | Kreal _ -> e - | _ -> raise Not_found - end - | _ -> raise Not_found - -let builtin_round ulp = function - | [e] -> - let open Qed.Logic in - begin match F.repr e with - | Div(x,y) -> e_fun (flt_div ulp) [x;y] - | Add ([_;_] as xs) -> e_fun (flt_add ulp) xs - | Mul ([_;_] as xs) -> e_fun (flt_mul ulp) xs - | Kreal r when Q.equal r Q.zero -> e - | Kreal r when Q.equal r Q.one -> e - | Kreal r -> - let flt = Transitioning.Q.to_float r in - let rnd = - match ulp with - | Float32 -> Floating_point.round_to_single_precision_float flt - | Float64 -> flt - in F.e_float rnd - | _ -> raise Not_found - end - | _ -> raise Not_found - -let builtin_error = function - | [e] -> - let open Qed.Logic in - begin match F.repr e with - | Fun(f,_) when f == f_model -> e_zero_real - | _ -> raise Not_found - end - | _ -> raise Not_found - (* -------------------------------------------------------------------------- *) (* --- Conversion Symbols --- *) (* -------------------------------------------------------------------------- *) +let real_of_float f a = + match Context.get model with + | Real -> a + | Float -> e_fun (real_of_flt f) [a] + let float_of_real f a = match Context.get model with | Real -> a - | Float -> e_fun (flt_rnd f) [a] + | Float -> e_fun (flt_of_real f) [a] let float_of_int f a = float_of_real f (Cmath.real_of_int a) -let real_of_float _f a = a - -let range = - let is_float = Ctypes.f_memo (make_pred_float "is") in - fun f a -> p_call (is_float f) [a] (* -------------------------------------------------------------------------- *) (* --- Float Arithmetics --- *) @@ -212,32 +266,35 @@ let fbinop rop fop f x y = | Real -> rop x y | Float -> e_fun (fop f) [x;y] +let fcmp rop fop f x y = + match Context.get model with + | Real -> rop x y + | Float -> p_call (fop f) [x;y] + let fadd = fbinop e_add flt_add let fmul = fbinop e_mul flt_mul let fdiv = fbinop e_div flt_div -let fopp _ = e_opp (* sign change is exact in floats *) -let fsub f x y = fadd f x (e_opp y) +let fopp f x = + match Context.get model with + | Real -> e_opp x + | Float -> e_fun (flt_neg f) [x] + +let fsub f x y = fadd f x (fopp f y) + +let flt = fcmp p_lt flt_lt +let fle = fcmp p_leq flt_le +let feq = fcmp p_equal flt_eq +let fneq = fcmp p_neq flt_neq (* -------------------------------------------------------------------------- *) (* --- Registry --- *) (* -------------------------------------------------------------------------- *) -let () = Context.register - begin fun () -> - - F.set_builtin f_model builtin_model ; - F.set_builtin f_delta builtin_error ; - F.set_builtin f_epsilon builtin_error ; - F.set_builtin (flt_rnd Float32) (builtin_round Float32) ; - F.set_builtin (flt_rnd Float64) (builtin_round Float64) ; - - define_fmodel_of flt_rnd (function [x] -> x | _ -> raise Not_found) ; - define_fmodel_of flt_add e_sum ; (* only 2 params in flt_add *) - define_fmodel_of flt_mul e_prod ; (* only 2 params in flt_mul *) - define_fmodel_of flt_div (function [x;y] -> e_div x y | _ -> raise Not_found) ; - end - -let configure m = Context.set model m +let configure m = + begin + Context.set model m ; + Context.set Lang.floats tau_of_float ; + end (* -------------------------------------------------------------------------- *) diff --git a/src/plugins/wp/Cfloat.mli b/src/plugins/wp/Cfloat.mli index 8f1e71f24bc8e379719b6e6c96bb6b15c4ad66e7..f1f46e5950f89fe509e97f6015f2dbf0c5906338 100644 --- a/src/plugins/wp/Cfloat.mli +++ b/src/plugins/wp/Cfloat.mli @@ -28,16 +28,39 @@ open Ctypes open Lang open Lang.F +val f32 : adt +val f64 : adt + +val t32 : tau +val t64 : tau + type model = Real | Float val configure : model -> unit -val code_lit : float -> term +val ftau : c_float -> tau (** model independant *) +val tau_of_float : c_float -> tau (** with respect to model *) + +type op = + | LT + | EQ + | LE + | NE + | NEG + | ADD + | MUL + | DIV + | REAL + | ROUND + | EXACT (** same as round, but argument is exact representation *) + +val find : lfun -> op * c_float + +val code_lit : c_float -> float -> string option -> term val acsl_lit : Cil_types.logic_real -> term val float_of_int : c_float -> unop val float_of_real : c_float -> unop val real_of_float : c_float -> unop -val range : c_float -> term -> pred val fopp : c_float -> unop val fadd : c_float -> binop @@ -50,11 +73,14 @@ val fle : c_float -> cmp val feq : c_float -> cmp val fneq : c_float -> cmp -val f_model : lfun -val f_delta : lfun -val f_epsilon : lfun +val f_model : c_float -> lfun +val f_delta : c_float -> lfun +val f_epsilon : c_float -> lfun + +val flt_of_real : c_float -> lfun +val real_of_flt : c_float -> lfun -val flt_rnd : c_float -> lfun val flt_add : c_float -> lfun val flt_mul : c_float -> lfun val flt_div : c_float -> lfun +val flt_neg : c_float -> lfun diff --git a/src/plugins/wp/Changelog b/src/plugins/wp/Changelog index 405600b3263fe6ba89283519d2f9b81372e9c413..844b5b50097f8f55d30a604eb2ec14cd13cf1498 100644 --- a/src/plugins/wp/Changelog +++ b/src/plugins/wp/Changelog @@ -20,6 +20,8 @@ # <Prover>: prover ############################################################################### +- Wp [2019/01/28] New floating-point model + ###################### Plugin WP 18.0 (Argon) ###################### diff --git a/src/plugins/wp/Cvalues.ml b/src/plugins/wp/Cvalues.ml index 29210e6627c5ab23d665257f77f7c58056f0e190..f952969897624f89bcd5642823903d87a23adfb4 100644 --- a/src/plugins/wp/Cvalues.ml +++ b/src/plugins/wp/Cvalues.ml @@ -47,7 +47,7 @@ let equation = function let rec constant = function | CInt64(z,_,_) -> e_bigint z | CChr c -> e_int64 (Ctypes.char c) - | CReal(f,_,_) -> Cfloat.code_lit f + | CReal(f,fk,s) -> Cfloat.code_lit (Ctypes.c_float fk) f s | CEnum e -> constant_exp e.eival | CStr _ | CWStr _ -> Warning.error "String constants not yet implemented" @@ -193,7 +193,7 @@ module TYPE = STRUCTURAL let prefix = "Is" let natural = false let is_int = Cint.range - let is_float = Cfloat.range + let is_float _ _ = p_true let is_pointer _ = p_true end) diff --git a/src/plugins/wp/Lang.ml b/src/plugins/wp/Lang.ml index a77db4ea05c7cebfaad0d2540334d515b0c32435..fdcb24f90acfb8076919647c8c0e87985d746fff 100644 --- a/src/plugins/wp/Lang.ml +++ b/src/plugins/wp/Lang.ml @@ -142,6 +142,7 @@ and field = and tau = (field,adt) Logic.datatype let pointer = Context.create "Lang.pointer" +let floats = Context.create "Lang.floats" let new_extern_id = ref (-1) let new_extern ~debug ~library ~link = @@ -182,7 +183,7 @@ let t_datatype adt ts = Logic.Data(adt,ts) let rec tau_of_object = function | C_int _ -> Logic.Int - | C_float _ -> Logic.Real + | C_float f -> Context.get floats f | C_pointer t -> Context.get pointer t | C_comp c -> tau_of_comp c | C_array { arr_element = typ } -> t_array (tau_of_ctype typ) diff --git a/src/plugins/wp/Lang.mli b/src/plugins/wp/Lang.mli index d51bee26404ab071663fd95f9ad250c2c51180bb..4644a22391f0473387a54a6fad9ed2871a6d5e0a 100644 --- a/src/plugins/wp/Lang.mli +++ b/src/plugins/wp/Lang.mli @@ -167,6 +167,7 @@ val t_farray : tau -> tau -> tau val t_datatype : adt -> tau list -> tau val pointer : (typ -> tau) Context.value (** type of pointers *) +val floats : (c_float -> tau) Context.value (** type of floats *) val poly : string list Context.value (** polymorphism *) val parameters : (lfun -> sort list) -> unit (** definitions *) diff --git a/src/plugins/wp/LogicSemantics.ml b/src/plugins/wp/LogicSemantics.ml index 05b03df9c0481ed48c5dd7a3bf9ca1cd58cb9060..60c0efae3922f9f7c5b7ae12876965847cd93b65 100644 --- a/src/plugins/wp/LogicSemantics.ml +++ b/src/plugins/wp/LogicSemantics.ml @@ -510,8 +510,10 @@ struct L.map (Cint.convert i) (C.logic env t) | C_int i , L_pointer _ -> L.map_l2t (M.int_of_loc i) (C.logic env t) - | C_int i , (L_cfloat _ | L_real) -> + | C_int i , L_real -> L.map (Cint.of_real i) (C.logic env t) + | C_int i , L_cfloat f -> + L.map (fun v -> Cint.of_real i (Cfloat.real_of_float f v)) (C.logic env t) | C_int _, L_array _ -> Warning.error "@[Logic cast to sized integer (%a) from (%a) not implemented yet@]" Printer.pp_typ dst_ctype Printer.pp_logic_type t.term_type diff --git a/src/plugins/wp/MemTyped.ml b/src/plugins/wp/MemTyped.ml index 4fbf8ef305ef565611689406e43c078cd379856a..7439f2f8393fba8312c40754507ac3794dfd820e 100644 --- a/src/plugins/wp/MemTyped.ml +++ b/src/plugins/wp/MemTyped.ml @@ -402,7 +402,8 @@ let pointer = Context.create "MemTyped.pointer" type chunk = | M_int | M_char - | M_float + | M_f32 + | M_f64 | M_pointer | T_alloc @@ -413,33 +414,36 @@ struct let rank = function | M_int -> 0 | M_char -> 1 - | M_float -> 2 - | M_pointer -> 3 - | T_alloc -> 4 + | M_f32 -> 2 + | M_f64 -> 3 + | M_pointer -> 4 + | T_alloc -> 5 let hash = rank let name = function | M_int -> "Mint" | M_char -> "Mchar" - | M_float -> "Mflt" + | M_f32 -> "Mf32" + | M_f64 -> "Mf64" | M_pointer -> "Mptr" | T_alloc -> "Malloc" let compare a b = rank a - rank b let equal = (=) let pretty fmt c = Format.pp_print_string fmt (name c) let key_of_chunk = function - | M_int | M_char | M_float | M_pointer -> t_addr + | M_int | M_char | M_f32 | M_f64 | M_pointer -> t_addr | T_alloc -> L.Int let val_of_chunk = function | M_int | M_char -> L.Int - | M_float -> L.Real + | M_f32 -> Cfloat.tau_of_float Ctypes.Float32 + | M_f64 -> Cfloat.tau_of_float Ctypes.Float64 | M_pointer -> t_addr | T_alloc -> L.Int - let tau_of_chunk = - let m = Array.make 5 L.Int in - List.iter - (fun c -> m.(rank c) <- L.Array(key_of_chunk c,val_of_chunk c)) - [M_int;M_char;M_float;M_pointer;T_alloc] ; - fun c -> m.(rank c) + let tau_of_chunk = function + | M_int | M_char -> L.Array(t_addr,L.Int) + | M_pointer -> L.Array(t_addr,t_addr) + | M_f32 -> L.Array(t_addr,Cfloat.tau_of_float Ctypes.Float32) + | M_f64 -> L.Array(t_addr,Cfloat.tau_of_float Ctypes.Float64) + | T_alloc -> L.Array(L.Int,L.Int) let basename_of_chunk = name let is_framed _ = false end @@ -454,10 +458,11 @@ type loc = term (* of type addr *) (* -------------------------------------------------------------------------- *) let m_int i = if Ctypes.is_char i then M_char else M_int +let m_float = function Float32 -> M_f32 | Float64 -> M_f64 let rec footprint = function | C_int i -> Heap.Set.singleton (m_int i) - | C_float _ -> Heap.Set.singleton M_float + | C_float f -> Heap.Set.singleton (m_float f) | C_pointer _ -> Heap.Set.singleton M_pointer | C_array a -> footprint (object_of a.arr_element) | C_comp c -> footprint_comp c @@ -1005,7 +1010,7 @@ module ARRAY = Model.Generator(Matrix.NATURAL) let loadvalue sigma obj l = match obj with | C_int i -> F.e_get (Sigma.value sigma (m_int i)) l - | C_float _ -> F.e_get (Sigma.value sigma M_float) l + | C_float f -> F.e_get (Sigma.value sigma (m_float f)) l | C_pointer _ -> F.e_get (Sigma.value sigma M_pointer) l | C_comp c -> let phi,cs = COMP.get c in @@ -1271,7 +1276,7 @@ let eqmem s obj l = let stored s obj l v = match obj with | C_int i -> updated s (m_int i) l v - | C_float _ -> updated s M_float l v + | C_float f -> updated s (m_float f) l v | C_pointer _ -> updated s M_pointer l v | C_comp _ | C_array _ -> Set(loadvalue s.post obj l, v) :: diff --git a/src/plugins/wp/doc/manual/wp_intro.tex b/src/plugins/wp/doc/manual/wp_intro.tex index da74357a7b980d3af92104006171c1c51d367aa9..1e3c5e076a67cc3e3d8a823eceda35a8c64bcd7d 100644 --- a/src/plugins/wp/doc/manual/wp_intro.tex +++ b/src/plugins/wp/doc/manual/wp_intro.tex @@ -340,12 +340,15 @@ For tackling this complexity, the \textsf{WP} plug-in relies on several or \texttt{-wp-rte} will generate a warning if some annotation might be not generated. -\item[Float Model:] floating-point operations are \emph{defined} to be - the mathematical ones \emph{with} a rounding operation. This is fully - consistent with the \textsf{IEEE} semantics. Most automated provers - are not able to discharge the generated proof obligations. Special - support for the \textsf{Gappa} theorem prover is available through - \textsf{Why3}. +\item[Float Model:] floating-point values are represent in a special + theory with dedicated operations over \texttt{float} and \texttt{double} + values and conversion from and to their \texttt{real} representation \emph{via} + rounding, as defined by the \textsc{C/ACSL} semantics. + + Although correct with respect to the \textsc{IEEE} specifications, this + model still provides very little support for proving properties with automated + provers. You may add additional properties using \emph{drivers} + as explained later. \item[Real Model:] floating-point operations are \emph{transformed} on reals, with \emph{no} rounding. This is completely unsound with diff --git a/src/plugins/wp/share/coqwp/Cfloat.v b/src/plugins/wp/share/coqwp/Cfloat.v index 0b7666721938c60d6a21bf9c9fda4a28ecd4b6c6..fd245b87bfb945f92a72fc968f38f392fd83c6b4 100644 --- a/src/plugins/wp/share/coqwp/Cfloat.v +++ b/src/plugins/wp/share/coqwp/Cfloat.v @@ -26,24 +26,35 @@ Require Import BuiltIn. Require Reals.Rbasic_fun. Require Reals.R_sqrt. Require BuiltIn. +Require bool.Bool. Require real.Real. Require real.RealInfix. Require real.Abs. Require real.Square. (* Why3 goal *) -Definition to_float32: R -> R. +Definition f32 : Type. Admitted. (* Why3 goal *) -Definition to_float64: R -> R. +Definition f64 : Type. Admitted. -(* Why3 assumption *) -Definition is_float32 (x:R): Prop := ((to_float32 x) = x). +(* Why3 goal *) +Definition to_f32: R -> f32. +Admitted. -(* Why3 assumption *) -Definition is_float64 (x:R): Prop := ((to_float64 x) = x). +(* Why3 goal *) +Definition of_f32: f32 -> R. +Admitted. + +(* Why3 goal *) +Definition to_f64: R -> f64. +Admitted. + +(* Why3 goal *) +Definition of_f64: f64 -> R. +Admitted. (* Why3 assumption *) Inductive rounding_mode := @@ -56,28 +67,26 @@ Axiom rounding_mode_WhyType : WhyType rounding_mode. Existing Instance rounding_mode_WhyType. (* Why3 goal *) -Definition round_double: rounding_mode -> R -> R. +Definition round_float: rounding_mode -> R -> f32. Admitted. (* Why3 goal *) -Definition round_float: rounding_mode -> R -> R. +Definition round_double: rounding_mode -> R -> f64. Admitted. (* Why3 goal *) -Lemma float_32 : forall (x:R), - ((to_float32 x) = (round_float NearestTiesToEven x)). +Lemma float_32 : forall (x:R), ((to_f32 x) = (round_float NearestTiesToEven + x)). Admitted. (* Why3 goal *) -Lemma float_64 : forall (x:R), - ((to_float64 x) = (round_double NearestTiesToEven x)). +Lemma float_64 : forall (x:R), ((to_f64 x) = (round_double NearestTiesToEven + x)). Admitted. (* Why3 assumption *) Inductive float_kind := - | Real : float_kind - | Float32 : float_kind - | Float64 : float_kind + | Finite : float_kind | NaN : float_kind | Inf_pos : float_kind | Inf_neg : float_kind. @@ -85,99 +94,310 @@ Axiom float_kind_WhyType : WhyType float_kind. Existing Instance float_kind_WhyType. (* Why3 goal *) -Definition classify_float: R -> float_kind. +Definition classify_f32: f32 -> float_kind. Admitted. +(* Why3 goal *) +Definition classify_f64: f64 -> float_kind. +Admitted. + +(* Why3 assumption *) +Definition is_finite_f32 (f:f32): Prop := ((classify_f32 f) = Finite). + +(* Why3 assumption *) +Definition is_finite_f64 (d:f64): Prop := ((classify_f64 d) = Finite). + +(* Why3 assumption *) +Definition is_NaN_f32 (f:f32): Prop := ((classify_f32 f) = NaN). + +(* Why3 assumption *) +Definition is_NaN_f64 (d:f64): Prop := ((classify_f64 d) = NaN). + (* Why3 assumption *) -Definition is_finite32 (x:R): Prop := ((classify_float x) = Float32). +Definition is_infinite_f32 (f:f32): Prop := ((classify_f32 f) = Inf_pos) \/ + ((classify_f32 f) = Inf_neg). (* Why3 assumption *) -Definition is_finite64 (x:R): Prop := ((classify_float x) = Float32) \/ - ((classify_float x) = Float64). +Definition is_infinite_f64 (d:f64): Prop := ((classify_f64 d) = Inf_pos) \/ + ((classify_f64 d) = Inf_neg). (* Why3 assumption *) -Definition is_NaN (x:R): Prop := ((classify_float x) = NaN). +Definition is_positive_infinite_f32 (f:f32): Prop := + ((classify_f32 f) = Inf_pos). (* Why3 assumption *) -Definition is_infinite (x:R): Prop := ((classify_float x) = Inf_pos) \/ - ((classify_float x) = Inf_neg). +Definition is_positive_infinite_f64 (d:f64): Prop := + ((classify_f64 d) = Inf_pos). (* Why3 assumption *) -Definition is_positive_infinite (x:R): Prop := - ((classify_float x) = Inf_pos). +Definition is_negative_infinite_f32 (f:f32): Prop := + ((classify_f32 f) = Inf_neg). (* Why3 assumption *) -Definition is_negative_infinite (x:R): Prop := - ((classify_float x) = Inf_neg). +Definition is_negative_infinite_f64 (d:f64): Prop := + ((classify_f64 d) = Inf_neg). (* Why3 goal *) -Lemma is_finite_to_float_32 : forall (x:R), (is_finite32 (to_float32 x)). +Lemma is_finite_to_float_32 : forall (x:R), (is_finite_f32 (to_f32 x)). Admitted. (* Why3 goal *) -Lemma is_finite_to_float_64 : forall (x:R), (is_finite64 (to_float64 x)). +Lemma is_finite_to_float_64 : forall (x:R), (is_finite_f64 (to_f64 x)). Admitted. -(* Why3 assumption *) -Definition add_float32 (x:R) (y:R): R := (to_float32 (x + y)%R). +(* Why3 goal *) +Lemma to_float_is_finite_32 : forall (f:f32), (is_finite_f32 f) -> + ((to_f32 (of_f32 f)) = f). +Admitted. + +(* Why3 goal *) +Lemma to_float_is_finite_64 : forall (d:f64), (is_finite_f64 d) -> + ((to_f64 (of_f64 d)) = d). +Admitted. (* Why3 assumption *) -Definition add_float64 (x:R) (y:R): R := (to_float64 (x + y)%R). +Definition finite (x:R): Prop := (is_finite_f32 (to_f32 x)) /\ (is_finite_f64 + (to_f64 x)). + +(* Why3 goal *) +Lemma finite_small_f32 : forall (x:R), + (((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R <= x)%R /\ + (x <= 340282346600000016151267322115014000640%R)%R) -> (is_finite_f32 + (to_f32 x)). +Admitted. + +(* Why3 goal *) +Lemma finite_small_f64 : forall (x:R), + (((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R <= x)%R /\ + (x <= 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R) -> + (is_finite_f64 (to_f64 x)). +Admitted. + +(* Why3 goal *) +Lemma finite_range_f32 : forall (f:f32), (is_finite_f32 f) <-> + (((-340282346600000016151267322115014000640%R)%R <= (of_f32 f))%R /\ + ((of_f32 f) <= 340282346600000016151267322115014000640%R)%R). +Admitted. + +(* Why3 goal *) +Lemma finite_range_f64 : forall (d:f64), (is_finite_f64 d) <-> + (((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R <= (of_f64 d))%R /\ + ((of_f64 d) <= 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R). +Admitted. + +(* Why3 goal *) +Definition eq_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition eq_f64b: f64 -> f64 -> bool. +Admitted. (* Why3 assumption *) -Definition mul_float32 (x:R) (y:R): R := (to_float32 (x * y)%R). +Definition eq_f32 (x:f32) (y:f32): Prop := ((eq_f32b x y) = true). (* Why3 assumption *) -Definition mul_float64 (x:R) (y:R): R := (to_float64 (x * y)%R). +Definition eq_f64 (x:f64) (y:f64): Prop := ((eq_f64b x y) = true). + +(* Why3 goal *) +Lemma eq_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((eq_f32 x y) <-> ((of_f32 x) = (of_f32 y)))). +Admitted. + +(* Why3 goal *) +Lemma eq_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((eq_f64 x y) <-> ((of_f64 x) = (of_f64 y)))). +Admitted. + +(* Why3 goal *) +Definition ne_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition ne_f64b: f64 -> f64 -> bool. +Admitted. (* Why3 assumption *) -Definition div_float32 (x:R) (y:R): R := (to_float32 (x / y)%R). +Definition ne_f32 (x:f32) (y:f32): Prop := ((ne_f32b x y) = true). (* Why3 assumption *) -Definition div_float64 (x:R) (y:R): R := (to_float64 (x / y)%R). +Definition ne_f64 (x:f64) (y:f64): Prop := ((ne_f64b x y) = true). + +(* Why3 goal *) +Lemma ne_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((ne_f32 x y) <-> ~ ((of_f32 x) = (of_f32 y)))). +Admitted. + +(* Why3 goal *) +Lemma ne_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((ne_f64 x y) <-> ~ ((of_f64 x) = (of_f64 y)))). +Admitted. + +(* Why3 goal *) +Definition le_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition le_f64b: f64 -> f64 -> bool. +Admitted. (* Why3 assumption *) -Definition sqrt_float32 (x:R): R := (to_float32 (Reals.R_sqrt.sqrt x)). +Definition le_f32 (x:f32) (y:f32): Prop := ((le_f32b x y) = true). (* Why3 assumption *) -Definition sqrt_float64 (x:R): R := (to_float64 (Reals.R_sqrt.sqrt x)). +Definition le_f64 (x:f64) (y:f64): Prop := ((le_f64b x y) = true). (* Why3 goal *) -Definition model: R -> R. +Lemma le_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((le_f32 x y) <-> ((of_f32 x) <= (of_f32 y))%R)). +Admitted. + +(* Why3 goal *) +Lemma le_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((le_f64 x y) <-> ((of_f64 x) <= (of_f64 y))%R)). +Admitted. + +(* Why3 goal *) +Definition lt_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition lt_f64b: f64 -> f64 -> bool. Admitted. (* Why3 assumption *) -Definition delta (x:R): R := (Reals.Rbasic_fun.Rabs (x - (model x))%R). +Definition lt_f32 (x:f32) (y:f32): Prop := ((lt_f32b x y) = true). (* Why3 assumption *) -Definition error (x:R): R := - ((delta x) / (Reals.Rbasic_fun.Rabs (model x)))%R. +Definition lt_f64 (x:f64) (y:f64): Prop := ((lt_f64b x y) = true). + +(* Why3 goal *) +Lemma lt_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((lt_f32 x y) <-> ((of_f32 x) < (of_f32 y))%R)). +Admitted. + +(* Why3 goal *) +Lemma lt_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((lt_f64 x y) <-> ((of_f64 x) < (of_f64 y))%R)). +Admitted. + +(* Why3 goal *) +Definition neg_f32: f32 -> f32. +Admitted. + +(* Why3 goal *) +Definition neg_f64: f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma neg_finite_f32 : forall (x:f32), (is_finite_f32 x) -> + ((of_f32 (neg_f32 x)) = (-(of_f32 x))%R). +Admitted. + +(* Why3 goal *) +Lemma neg_finite_f64 : forall (x:f64), (is_finite_f64 x) -> + ((of_f64 (neg_f64 x)) = (-(of_f64 x))%R). +Admitted. + +(* Why3 goal *) +Definition add_f32: f32 -> f32 -> f32. +Admitted. + +(* Why3 goal *) +Definition add_f64: f64 -> f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma add_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((add_f32 x + y) = (to_f32 ((of_f32 x) + (of_f32 y))%R))). +Admitted. (* Why3 goal *) -Lemma model_float_32 : forall (x:R), ((model (to_float32 x)) = (model x)). +Lemma add_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((add_f64 x + y) = (to_f64 ((of_f64 x) + (of_f64 y))%R))). Admitted. (* Why3 goal *) -Lemma model_float_64 : forall (x:R), ((model (to_float64 x)) = (model x)). +Definition mul_f32: f32 -> f32 -> f32. Admitted. (* Why3 goal *) -Lemma model_add : forall (x:R) (y:R), - ((model (x + y)%R) = ((model x) + (model y))%R). +Definition mul_f64: f64 -> f64 -> f64. Admitted. (* Why3 goal *) -Lemma model_mul : forall (x:R) (y:R), - ((model (x * y)%R) = ((model x) * (model y))%R). +Lemma mul_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((mul_f32 x + y) = (to_f32 ((of_f32 x) * (of_f32 y))%R))). Admitted. (* Why3 goal *) -Lemma model_div : forall (x:R) (y:R), - ((model (x / y)%R) = ((model x) / (model y))%R). +Lemma mul_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((mul_f64 x + y) = (to_f64 ((of_f64 x) * (of_f64 y))%R))). Admitted. (* Why3 goal *) -Lemma model_sqrt : forall (x:R), - ((model (Reals.R_sqrt.sqrt x)) = (Reals.R_sqrt.sqrt (model x))). +Definition div_f32: f32 -> f32 -> f32. Admitted. +(* Why3 goal *) +Definition div_f64: f64 -> f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma div_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((div_f32 x + y) = (to_f32 ((of_f32 x) / (of_f32 y))%R))). +Admitted. + +(* Why3 goal *) +Lemma div_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((div_f64 x + y) = (to_f64 ((of_f64 x) / (of_f64 y))%R))). +Admitted. + +(* Why3 goal *) +Definition sqrt_f32: f32 -> f32. +Admitted. + +(* Why3 goal *) +Definition sqrt_f64: f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma sqrt_finite_f32 : forall (x:f32), (is_finite_f32 x) -> + ((sqrt_f32 x) = (to_f32 (Reals.R_sqrt.sqrt (of_f32 x)))). +Admitted. + +(* Why3 goal *) +Lemma sqrt_finite_f64 : forall (x:f64), (is_finite_f64 x) -> + ((sqrt_f64 x) = (to_f64 (Reals.R_sqrt.sqrt (of_f64 x)))). +Admitted. + +(* Why3 goal *) +Definition model_f32: f32 -> R. +Admitted. + +(* Why3 assumption *) +Definition delta_f32 (f:f32): R := + (Reals.Rbasic_fun.Rabs ((of_f32 f) - (model_f32 f))%R). + +(* Why3 assumption *) +Definition error_f32 (f:f32): R := + ((delta_f32 f) / (Reals.Rbasic_fun.Rabs (model_f32 f)))%R. + +(* Why3 goal *) +Definition model_f64: f64 -> R. +Admitted. + +(* Why3 assumption *) +Definition delta_f64 (f:f64): R := + (Reals.Rbasic_fun.Rabs ((of_f64 f) - (model_f64 f))%R). + +(* Why3 assumption *) +Definition error_f64 (f:f64): R := + ((delta_f64 f) / (Reals.Rbasic_fun.Rabs (model_f64 f)))%R. + diff --git a/src/plugins/wp/share/ergo/Cfloat.mlw b/src/plugins/wp/share/ergo/Cfloat.mlw index 4114401bdc9df5d349adec5ac5c4abd6be234cf0..53d827ee5091005aa9994a4ac9a18398aa6b9e82 100644 --- a/src/plugins/wp/share/ergo/Cfloat.mlw +++ b/src/plugins/wp/share/ergo/Cfloat.mlw @@ -23,17 +23,22 @@ (* this is the prelude for Alt-Ergo, version >= 0.95.2 *) (** The theory BuiltIn_ must be appended to this file*) (** The theory Bool_ must be appended to this file*) +(** The theory bool_Bool_ must be appended to this file*) (** The theory real_Real_ must be appended to this file*) (** The theory real_RealInfix_ must be appended to this file*) (** The theory real_Abs_ must be appended to this file*) (** The theory real_Square_ must be appended to this file*) -logic to_float32 : real -> real +type f32 -logic to_float64 : real -> real +type f64 -predicate is_float32(x: real) = (to_float32(x) = x) +logic to_f32 : real -> f32 -predicate is_float64(x: real) = (to_float64(x) = x) +logic of_f32 : f32 -> real + +logic to_f64 : real -> f64 + +logic of_f64 : f64 -> real type rounding_mode = Up | Down | ToZero | NearestTiesToAway | NearestTiesToEven @@ -60,102 +65,286 @@ axiom match_rounding_mode_NearestTiesToEven : (forall z:'a. forall z1:'a. forall z2:'a. forall z3:'a. forall z4:'a. (match_rounding_mode(NearestTiesToEven, z, z1, z2, z3, z4) = z4)) -logic round_double : rounding_mode, real -> real +logic round_float : rounding_mode, real -> f32 -logic round_float : rounding_mode, real -> real +logic round_double : rounding_mode, real -> f64 axiom float_32 : (forall x:real [round_float(NearestTiesToEven, x)]. - (to_float32(x) = round_float(NearestTiesToEven, x))) + (to_f32(x) = round_float(NearestTiesToEven, x))) axiom float_64 : (forall x:real [round_double(NearestTiesToEven, x)]. - (to_float64(x) = round_double(NearestTiesToEven, x))) + (to_f64(x) = round_double(NearestTiesToEven, x))) -type float_kind = Real | Float32 | Float64 | NaN | Inf_pos | Inf_neg +type float_kind = Finite | NaN | Inf_pos | Inf_neg -logic match_float_kind : float_kind, 'a, 'a, 'a, 'a, 'a, 'a -> 'a +logic match_float_kind : float_kind, 'a, 'a, 'a, 'a -> 'a -axiom match_float_kind_Real : - (forall z:'a. forall z1:'a. forall z2:'a. forall z3:'a. forall z4:'a. - forall z5:'a. (match_float_kind(Real, z, z1, z2, z3, z4, z5) = z)) - -axiom match_float_kind_Float32 : - (forall z:'a. forall z1:'a. forall z2:'a. forall z3:'a. forall z4:'a. - forall z5:'a. (match_float_kind(Float32, z, z1, z2, z3, z4, z5) = z1)) - -axiom match_float_kind_Float64 : - (forall z:'a. forall z1:'a. forall z2:'a. forall z3:'a. forall z4:'a. - forall z5:'a. (match_float_kind(Float64, z, z1, z2, z3, z4, z5) = z2)) +axiom match_float_kind_Finite : + (forall z:'a. forall z1:'a. forall z2:'a. forall z3:'a. + (match_float_kind(Finite, z, z1, z2, z3) = z)) axiom match_float_kind_NaN : - (forall z:'a. forall z1:'a. forall z2:'a. forall z3:'a. forall z4:'a. - forall z5:'a. (match_float_kind(NaN, z, z1, z2, z3, z4, z5) = z3)) + (forall z:'a. forall z1:'a. forall z2:'a. forall z3:'a. + (match_float_kind(NaN, z, z1, z2, z3) = z1)) axiom match_float_kind_Inf_pos : - (forall z:'a. forall z1:'a. forall z2:'a. forall z3:'a. forall z4:'a. - forall z5:'a. (match_float_kind(Inf_pos, z, z1, z2, z3, z4, z5) = z4)) + (forall z:'a. forall z1:'a. forall z2:'a. forall z3:'a. + (match_float_kind(Inf_pos, z, z1, z2, z3) = z2)) axiom match_float_kind_Inf_neg : - (forall z:'a. forall z1:'a. forall z2:'a. forall z3:'a. forall z4:'a. - forall z5:'a. (match_float_kind(Inf_neg, z, z1, z2, z3, z4, z5) = z5)) + (forall z:'a. forall z1:'a. forall z2:'a. forall z3:'a. + (match_float_kind(Inf_neg, z, z1, z2, z3) = z3)) + +logic classify_f32 : f32 -> float_kind + +logic classify_f64 : f64 -> float_kind + +predicate is_finite_f32(f: f32) = (classify_f32(f) = Finite) -logic classify_float : real -> float_kind +predicate is_finite_f64(d: f64) = (classify_f64(d) = Finite) -predicate is_finite32(x: real) = (classify_float(x) = Float32) +predicate is_NaN_f32(f: f32) = (classify_f32(f) = NaN) -predicate is_finite64(x: real) = ((classify_float(x) = Float32) or - (classify_float(x) = Float64)) +predicate is_NaN_f64(d: f64) = (classify_f64(d) = NaN) -predicate is_NaN(x: real) = (classify_float(x) = NaN) +predicate is_infinite_f32(f: f32) = ((classify_f32(f) = Inf_pos) or + (classify_f32(f) = Inf_neg)) -predicate is_infinite(x: real) = ((classify_float(x) = Inf_pos) or - (classify_float(x) = Inf_neg)) +predicate is_infinite_f64(d: f64) = ((classify_f64(d) = Inf_pos) or + (classify_f64(d) = Inf_neg)) -predicate is_positive_infinite(x: real) = (classify_float(x) = Inf_pos) +predicate is_positive_infinite_f32(f: f32) = (classify_f32(f) = Inf_pos) -predicate is_negative_infinite(x: real) = (classify_float(x) = Inf_neg) +predicate is_positive_infinite_f64(d: f64) = (classify_f64(d) = Inf_pos) + +predicate is_negative_infinite_f32(f: f32) = (classify_f32(f) = Inf_neg) + +predicate is_negative_infinite_f64(d: f64) = (classify_f64(d) = Inf_neg) axiom is_finite_to_float_32 : - (forall x:real [is_finite32(to_float32(x))]. is_finite32(to_float32(x))) + (forall x:real [is_finite_f32(to_f32(x))]. is_finite_f32(to_f32(x))) axiom is_finite_to_float_64 : - (forall x:real [is_finite64(to_float64(x))]. is_finite64(to_float64(x))) + (forall x:real [is_finite_f64(to_f64(x))]. is_finite_f64(to_f64(x))) + +axiom to_float_is_finite_32 : + (forall f:f32 [to_f32(of_f32(f))| is_finite_f32(f)]. (is_finite_f32(f) -> + (to_f32(of_f32(f)) = f))) + +axiom to_float_is_finite_64 : + (forall d:f64 [to_f64(of_f64(d))| is_finite_f64(d)]. (is_finite_f64(d) -> + (to_f64(of_f64(d)) = d))) + +predicate finite(x: real) = (is_finite_f32(to_f32(x)) and + is_finite_f64(to_f64(x))) + +axiom finite_small_f32 : + (forall x:real. + ((((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0) <= x) and + (x <= 340282346600000016151267322115014000640.0)) -> + is_finite_f32(to_f32(x)))) + +axiom finite_small_f64 : + (forall x:real. + ((((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0) <= x) and + (x <= 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0)) -> + is_finite_f64(to_f64(x)))) + +axiom finite_range_f32 : + (forall f:f32. (is_finite_f32(f) -> + ((-340282346600000016151267322115014000640.0) <= of_f32(f)))) + +axiom finite_range_f321 : + (forall f:f32. (is_finite_f32(f) -> + (of_f32(f) <= 340282346600000016151267322115014000640.0))) + +axiom finite_range_f322 : + (forall f:f32. + ((((-340282346600000016151267322115014000640.0) <= of_f32(f)) and + (of_f32(f) <= 340282346600000016151267322115014000640.0)) -> + is_finite_f32(f))) + +axiom finite_range_f64 : + (forall d:f64. (is_finite_f64(d) -> + ((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0) <= of_f64(d)))) + +axiom finite_range_f641 : + (forall d:f64. (is_finite_f64(d) -> + (of_f64(d) <= 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0))) + +axiom finite_range_f642 : + (forall d:f64. + ((((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0) <= of_f64(d)) and + (of_f64(d) <= 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0)) -> + is_finite_f64(d))) + +logic eq_f32b : f32, f32 -> bool + +logic eq_f64b : f64, f64 -> bool + +predicate eq_f32(x: f32, y: f32) = (eq_f32b(x, y) = true) + +predicate eq_f64(x: f64, y: f64) = (eq_f64b(x, y) = true) + +axiom eq_finite_f32 : + (forall x:f32. forall y:f32 [eq_f32(x, y)]. (is_finite_f32(x) -> + (is_finite_f32(y) -> (eq_f32(x, y) -> (of_f32(x) = of_f32(y)))))) + +axiom eq_finite_f321 : + (forall x:f32. forall y:f32 [eq_f32(x, y)]. (is_finite_f32(x) -> + (is_finite_f32(y) -> ((of_f32(x) = of_f32(y)) -> eq_f32(x, y))))) + +axiom eq_finite_f64 : + (forall x:f64. forall y:f64 [eq_f64(x, y)]. (is_finite_f64(x) -> + (is_finite_f64(y) -> (eq_f64(x, y) -> (of_f64(x) = of_f64(y)))))) + +axiom eq_finite_f641 : + (forall x:f64. forall y:f64 [eq_f64(x, y)]. (is_finite_f64(x) -> + (is_finite_f64(y) -> ((of_f64(x) = of_f64(y)) -> eq_f64(x, y))))) + +logic ne_f32b : f32, f32 -> bool + +logic ne_f64b : f64, f64 -> bool + +predicate ne_f32(x: f32, y: f32) = (ne_f32b(x, y) = true) + +predicate ne_f64(x: f64, y: f64) = (ne_f64b(x, y) = true) + +axiom ne_finite_f32 : + (forall x:f32. forall y:f32 [ne_f32(x, y)]. (is_finite_f32(x) -> + (is_finite_f32(y) -> (ne_f32(x, y) -> (not (of_f32(x) = of_f32(y))))))) + +axiom ne_finite_f321 : + (forall x:f32. forall y:f32 [ne_f32(x, y)]. (is_finite_f32(x) -> + (is_finite_f32(y) -> ((not (of_f32(x) = of_f32(y))) -> ne_f32(x, y))))) + +axiom ne_finite_f64 : + (forall x:f64. forall y:f64 [ne_f64(x, y)]. (is_finite_f64(x) -> + (is_finite_f64(y) -> (ne_f64(x, y) -> (not (of_f64(x) = of_f64(y))))))) + +axiom ne_finite_f641 : + (forall x:f64. forall y:f64 [ne_f64(x, y)]. (is_finite_f64(x) -> + (is_finite_f64(y) -> ((not (of_f64(x) = of_f64(y))) -> ne_f64(x, y))))) + +logic le_f32b : f32, f32 -> bool + +logic le_f64b : f64, f64 -> bool + +predicate le_f32(x: f32, y: f32) = (le_f32b(x, y) = true) + +predicate le_f64(x: f64, y: f64) = (le_f64b(x, y) = true) + +axiom le_finite_f32 : + (forall x:f32. forall y:f32 [le_f32(x, y)]. (is_finite_f32(x) -> + (is_finite_f32(y) -> (le_f32(x, y) -> (of_f32(x) <= of_f32(y)))))) + +axiom le_finite_f321 : + (forall x:f32. forall y:f32 [le_f32(x, y)]. (is_finite_f32(x) -> + (is_finite_f32(y) -> ((of_f32(x) <= of_f32(y)) -> le_f32(x, y))))) + +axiom le_finite_f64 : + (forall x:f64. forall y:f64 [le_f64(x, y)]. (is_finite_f64(x) -> + (is_finite_f64(y) -> (le_f64(x, y) -> (of_f64(x) <= of_f64(y)))))) + +axiom le_finite_f641 : + (forall x:f64. forall y:f64 [le_f64(x, y)]. (is_finite_f64(x) -> + (is_finite_f64(y) -> ((of_f64(x) <= of_f64(y)) -> le_f64(x, y))))) + +logic lt_f32b : f32, f32 -> bool + +logic lt_f64b : f64, f64 -> bool + +predicate lt_f32(x: f32, y: f32) = (lt_f32b(x, y) = true) + +predicate lt_f64(x: f64, y: f64) = (lt_f64b(x, y) = true) + +axiom lt_finite_f32 : + (forall x:f32. forall y:f32 [lt_f32(x, y)]. (is_finite_f32(x) -> + (is_finite_f32(y) -> (lt_f32(x, y) -> (of_f32(x) < of_f32(y)))))) + +axiom lt_finite_f321 : + (forall x:f32. forall y:f32 [lt_f32(x, y)]. (is_finite_f32(x) -> + (is_finite_f32(y) -> ((of_f32(x) < of_f32(y)) -> lt_f32(x, y))))) + +axiom lt_finite_f64 : + (forall x:f64. forall y:f64 [lt_f64(x, y)]. (is_finite_f64(x) -> + (is_finite_f64(y) -> (lt_f64(x, y) -> (of_f64(x) < of_f64(y)))))) + +axiom lt_finite_f641 : + (forall x:f64. forall y:f64 [lt_f64(x, y)]. (is_finite_f64(x) -> + (is_finite_f64(y) -> ((of_f64(x) < of_f64(y)) -> lt_f64(x, y))))) + +logic neg_f32 : f32 -> f32 + +logic neg_f64 : f64 -> f64 + +axiom neg_finite_f32 : + (forall x:f32 [neg_f32(x)]. (is_finite_f32(x) -> + (of_f32(neg_f32(x)) = (-of_f32(x))))) + +axiom neg_finite_f64 : + (forall x:f64 [neg_f64(x)]. (is_finite_f64(x) -> + (of_f64(neg_f64(x)) = (-of_f64(x))))) + +logic add_f32 : f32, f32 -> f32 + +logic add_f64 : f64, f64 -> f64 + +axiom add_finite_f32 : + (forall x:f32. forall y:f32 [add_f32(x, y)]. (is_finite_f32(x) -> + (is_finite_f32(y) -> (add_f32(x, y) = to_f32((of_f32(x) + of_f32(y))))))) + +axiom add_finite_f64 : + (forall x:f64. forall y:f64 [add_f64(x, y)]. (is_finite_f64(x) -> + (is_finite_f64(y) -> (add_f64(x, y) = to_f64((of_f64(x) + of_f64(y))))))) + +logic mul_f32 : f32, f32 -> f32 -function add_float32(x: real, y: real) : real = to_float32((x + y)) +logic mul_f64 : f64, f64 -> f64 -function add_float64(x: real, y: real) : real = to_float64((x + y)) +axiom mul_finite_f32 : + (forall x:f32. forall y:f32 [mul_f32(x, y)]. (is_finite_f32(x) -> + (is_finite_f32(y) -> (mul_f32(x, y) = to_f32((of_f32(x) * of_f32(y))))))) -function mul_float32(x: real, y: real) : real = to_float32((x * y)) +axiom mul_finite_f64 : + (forall x:f64. forall y:f64 [mul_f64(x, y)]. (is_finite_f64(x) -> + (is_finite_f64(y) -> (mul_f64(x, y) = to_f64((of_f64(x) * of_f64(y))))))) -function mul_float64(x: real, y: real) : real = to_float64((x * y)) +logic div_f32 : f32, f32 -> f32 -function div_float32(x: real, y: real) : real = to_float32((x / y)) +logic div_f64 : f64, f64 -> f64 -function div_float64(x: real, y: real) : real = to_float64((x / y)) +axiom div_finite_f32 : + (forall x:f32. forall y:f32 [div_f32(x, y)]. (is_finite_f32(x) -> + (is_finite_f32(y) -> (div_f32(x, y) = to_f32((of_f32(x) / of_f32(y))))))) -function sqrt_float32(x: real) : real = to_float32(sqrt(x)) +axiom div_finite_f64 : + (forall x:f64. forall y:f64 [div_f64(x, y)]. (is_finite_f64(x) -> + (is_finite_f64(y) -> (div_f64(x, y) = to_f64((of_f64(x) / of_f64(y))))))) -function sqrt_float64(x: real) : real = to_float64(sqrt(x)) +logic sqrt_f32 : f32 -> f32 -logic model : real -> real +logic sqrt_f64 : f64 -> f64 -function delta(x: real) : real = abs_real((x - model(x))) +axiom sqrt_finite_f32 : + (forall x:f32 [sqrt_f32(x)]. (is_finite_f32(x) -> + (sqrt_f32(x) = to_f32(sqrt(of_f32(x)))))) -function error(x: real) : real = (delta(x) / abs_real(model(x))) +axiom sqrt_finite_f64 : + (forall x:f64 [sqrt_f64(x)]. (is_finite_f64(x) -> + (sqrt_f64(x) = to_f64(sqrt(of_f64(x)))))) -axiom model_float_32 : (forall x:real. (model(to_float32(x)) = model(x))) +logic model_f32 : f32 -> real -axiom model_float_64 : (forall x:real. (model(to_float64(x)) = model(x))) +function delta_f32(f: f32) : real = abs_real((of_f32(f) - model_f32(f))) -axiom model_add : - (forall x:real. forall y:real. (model((x + y)) = (model(x) + model(y)))) +function error_f32(f: f32) : real = (delta_f32(f) / abs_real(model_f32(f))) -axiom model_mul : - (forall x:real. forall y:real. (model((x * y)) = (model(x) * model(y)))) +logic model_f64 : f64 -> real -axiom model_div : - (forall x:real. forall y:real. (model((x / y)) = (model(x) / model(y)))) +function delta_f64(f: f64) : real = abs_real((of_f64(f) - model_f64(f))) -axiom model_sqrt : (forall x:real. (model(sqrt(x)) = sqrt(model(x)))) +function error_f64(f: f64) : real = (delta_f64(f) / abs_real(model_f64(f))) diff --git a/src/plugins/wp/share/src/Cfloat.v b/src/plugins/wp/share/src/Cfloat.v index b995e0c55e8d4d8c573e794c0dcc90cc367674d4..2e91223270243ab2f1aea16be655e01e627251c8 100644 --- a/src/plugins/wp/share/src/Cfloat.v +++ b/src/plugins/wp/share/src/Cfloat.v @@ -4,24 +4,35 @@ Require Import BuiltIn. Require Reals.Rbasic_fun. Require Reals.R_sqrt. Require BuiltIn. +Require bool.Bool. Require real.Real. Require real.RealInfix. Require real.Abs. Require real.Square. (* Why3 goal *) -Definition to_float32: R -> R. +Definition f32 : Type. Admitted. (* Why3 goal *) -Definition to_float64: R -> R. +Definition f64 : Type. Admitted. -(* Why3 assumption *) -Definition is_float32 (x:R): Prop := ((to_float32 x) = x). +(* Why3 goal *) +Definition to_f32: R -> f32. +Admitted. -(* Why3 assumption *) -Definition is_float64 (x:R): Prop := ((to_float64 x) = x). +(* Why3 goal *) +Definition of_f32: f32 -> R. +Admitted. + +(* Why3 goal *) +Definition to_f64: R -> f64. +Admitted. + +(* Why3 goal *) +Definition of_f64: f64 -> R. +Admitted. (* Why3 assumption *) Inductive rounding_mode := @@ -34,28 +45,26 @@ Axiom rounding_mode_WhyType : WhyType rounding_mode. Existing Instance rounding_mode_WhyType. (* Why3 goal *) -Definition round_double: rounding_mode -> R -> R. +Definition round_float: rounding_mode -> R -> f32. Admitted. (* Why3 goal *) -Definition round_float: rounding_mode -> R -> R. +Definition round_double: rounding_mode -> R -> f64. Admitted. (* Why3 goal *) -Lemma float_32 : forall (x:R), - ((to_float32 x) = (round_float NearestTiesToEven x)). +Lemma float_32 : forall (x:R), ((to_f32 x) = (round_float NearestTiesToEven + x)). Admitted. (* Why3 goal *) -Lemma float_64 : forall (x:R), - ((to_float64 x) = (round_double NearestTiesToEven x)). +Lemma float_64 : forall (x:R), ((to_f64 x) = (round_double NearestTiesToEven + x)). Admitted. (* Why3 assumption *) Inductive float_kind := - | Real : float_kind - | Float32 : float_kind - | Float64 : float_kind + | Finite : float_kind | NaN : float_kind | Inf_pos : float_kind | Inf_neg : float_kind. @@ -63,99 +72,310 @@ Axiom float_kind_WhyType : WhyType float_kind. Existing Instance float_kind_WhyType. (* Why3 goal *) -Definition classify_float: R -> float_kind. +Definition classify_f32: f32 -> float_kind. Admitted. +(* Why3 goal *) +Definition classify_f64: f64 -> float_kind. +Admitted. + +(* Why3 assumption *) +Definition is_finite_f32 (f:f32): Prop := ((classify_f32 f) = Finite). + +(* Why3 assumption *) +Definition is_finite_f64 (d:f64): Prop := ((classify_f64 d) = Finite). + +(* Why3 assumption *) +Definition is_NaN_f32 (f:f32): Prop := ((classify_f32 f) = NaN). + +(* Why3 assumption *) +Definition is_NaN_f64 (d:f64): Prop := ((classify_f64 d) = NaN). + (* Why3 assumption *) -Definition is_finite32 (x:R): Prop := ((classify_float x) = Float32). +Definition is_infinite_f32 (f:f32): Prop := ((classify_f32 f) = Inf_pos) \/ + ((classify_f32 f) = Inf_neg). (* Why3 assumption *) -Definition is_finite64 (x:R): Prop := ((classify_float x) = Float32) \/ - ((classify_float x) = Float64). +Definition is_infinite_f64 (d:f64): Prop := ((classify_f64 d) = Inf_pos) \/ + ((classify_f64 d) = Inf_neg). (* Why3 assumption *) -Definition is_NaN (x:R): Prop := ((classify_float x) = NaN). +Definition is_positive_infinite_f32 (f:f32): Prop := + ((classify_f32 f) = Inf_pos). (* Why3 assumption *) -Definition is_infinite (x:R): Prop := ((classify_float x) = Inf_pos) \/ - ((classify_float x) = Inf_neg). +Definition is_positive_infinite_f64 (d:f64): Prop := + ((classify_f64 d) = Inf_pos). (* Why3 assumption *) -Definition is_positive_infinite (x:R): Prop := - ((classify_float x) = Inf_pos). +Definition is_negative_infinite_f32 (f:f32): Prop := + ((classify_f32 f) = Inf_neg). (* Why3 assumption *) -Definition is_negative_infinite (x:R): Prop := - ((classify_float x) = Inf_neg). +Definition is_negative_infinite_f64 (d:f64): Prop := + ((classify_f64 d) = Inf_neg). (* Why3 goal *) -Lemma is_finite_to_float_32 : forall (x:R), (is_finite32 (to_float32 x)). +Lemma is_finite_to_float_32 : forall (x:R), (is_finite_f32 (to_f32 x)). Admitted. (* Why3 goal *) -Lemma is_finite_to_float_64 : forall (x:R), (is_finite64 (to_float64 x)). +Lemma is_finite_to_float_64 : forall (x:R), (is_finite_f64 (to_f64 x)). Admitted. -(* Why3 assumption *) -Definition add_float32 (x:R) (y:R): R := (to_float32 (x + y)%R). +(* Why3 goal *) +Lemma to_float_is_finite_32 : forall (f:f32), (is_finite_f32 f) -> + ((to_f32 (of_f32 f)) = f). +Admitted. + +(* Why3 goal *) +Lemma to_float_is_finite_64 : forall (d:f64), (is_finite_f64 d) -> + ((to_f64 (of_f64 d)) = d). +Admitted. (* Why3 assumption *) -Definition add_float64 (x:R) (y:R): R := (to_float64 (x + y)%R). +Definition finite (x:R): Prop := (is_finite_f32 (to_f32 x)) /\ (is_finite_f64 + (to_f64 x)). + +(* Why3 goal *) +Lemma finite_small_f32 : forall (x:R), + (((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R <= x)%R /\ + (x <= 340282346600000016151267322115014000640%R)%R) -> (is_finite_f32 + (to_f32 x)). +Admitted. + +(* Why3 goal *) +Lemma finite_small_f64 : forall (x:R), + (((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R <= x)%R /\ + (x <= 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R) -> + (is_finite_f64 (to_f64 x)). +Admitted. + +(* Why3 goal *) +Lemma finite_range_f32 : forall (f:f32), (is_finite_f32 f) <-> + (((-340282346600000016151267322115014000640%R)%R <= (of_f32 f))%R /\ + ((of_f32 f) <= 340282346600000016151267322115014000640%R)%R). +Admitted. + +(* Why3 goal *) +Lemma finite_range_f64 : forall (d:f64), (is_finite_f64 d) <-> + (((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R <= (of_f64 d))%R /\ + ((of_f64 d) <= 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R). +Admitted. + +(* Why3 goal *) +Definition eq_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition eq_f64b: f64 -> f64 -> bool. +Admitted. (* Why3 assumption *) -Definition mul_float32 (x:R) (y:R): R := (to_float32 (x * y)%R). +Definition eq_f32 (x:f32) (y:f32): Prop := ((eq_f32b x y) = true). (* Why3 assumption *) -Definition mul_float64 (x:R) (y:R): R := (to_float64 (x * y)%R). +Definition eq_f64 (x:f64) (y:f64): Prop := ((eq_f64b x y) = true). + +(* Why3 goal *) +Lemma eq_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((eq_f32 x y) <-> ((of_f32 x) = (of_f32 y)))). +Admitted. + +(* Why3 goal *) +Lemma eq_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((eq_f64 x y) <-> ((of_f64 x) = (of_f64 y)))). +Admitted. + +(* Why3 goal *) +Definition ne_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition ne_f64b: f64 -> f64 -> bool. +Admitted. (* Why3 assumption *) -Definition div_float32 (x:R) (y:R): R := (to_float32 (x / y)%R). +Definition ne_f32 (x:f32) (y:f32): Prop := ((ne_f32b x y) = true). (* Why3 assumption *) -Definition div_float64 (x:R) (y:R): R := (to_float64 (x / y)%R). +Definition ne_f64 (x:f64) (y:f64): Prop := ((ne_f64b x y) = true). + +(* Why3 goal *) +Lemma ne_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((ne_f32 x y) <-> ~ ((of_f32 x) = (of_f32 y)))). +Admitted. + +(* Why3 goal *) +Lemma ne_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((ne_f64 x y) <-> ~ ((of_f64 x) = (of_f64 y)))). +Admitted. + +(* Why3 goal *) +Definition le_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition le_f64b: f64 -> f64 -> bool. +Admitted. (* Why3 assumption *) -Definition sqrt_float32 (x:R): R := (to_float32 (Reals.R_sqrt.sqrt x)). +Definition le_f32 (x:f32) (y:f32): Prop := ((le_f32b x y) = true). (* Why3 assumption *) -Definition sqrt_float64 (x:R): R := (to_float64 (Reals.R_sqrt.sqrt x)). +Definition le_f64 (x:f64) (y:f64): Prop := ((le_f64b x y) = true). (* Why3 goal *) -Definition model: R -> R. +Lemma le_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((le_f32 x y) <-> ((of_f32 x) <= (of_f32 y))%R)). +Admitted. + +(* Why3 goal *) +Lemma le_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((le_f64 x y) <-> ((of_f64 x) <= (of_f64 y))%R)). +Admitted. + +(* Why3 goal *) +Definition lt_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition lt_f64b: f64 -> f64 -> bool. Admitted. (* Why3 assumption *) -Definition delta (x:R): R := (Reals.Rbasic_fun.Rabs (x - (model x))%R). +Definition lt_f32 (x:f32) (y:f32): Prop := ((lt_f32b x y) = true). (* Why3 assumption *) -Definition error (x:R): R := - ((delta x) / (Reals.Rbasic_fun.Rabs (model x)))%R. +Definition lt_f64 (x:f64) (y:f64): Prop := ((lt_f64b x y) = true). + +(* Why3 goal *) +Lemma lt_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((lt_f32 x y) <-> ((of_f32 x) < (of_f32 y))%R)). +Admitted. + +(* Why3 goal *) +Lemma lt_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((lt_f64 x y) <-> ((of_f64 x) < (of_f64 y))%R)). +Admitted. + +(* Why3 goal *) +Definition neg_f32: f32 -> f32. +Admitted. + +(* Why3 goal *) +Definition neg_f64: f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma neg_finite_f32 : forall (x:f32), (is_finite_f32 x) -> + ((of_f32 (neg_f32 x)) = (-(of_f32 x))%R). +Admitted. + +(* Why3 goal *) +Lemma neg_finite_f64 : forall (x:f64), (is_finite_f64 x) -> + ((of_f64 (neg_f64 x)) = (-(of_f64 x))%R). +Admitted. + +(* Why3 goal *) +Definition add_f32: f32 -> f32 -> f32. +Admitted. + +(* Why3 goal *) +Definition add_f64: f64 -> f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma add_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((add_f32 x + y) = (to_f32 ((of_f32 x) + (of_f32 y))%R))). +Admitted. (* Why3 goal *) -Lemma model_float_32 : forall (x:R), ((model (to_float32 x)) = (model x)). +Lemma add_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((add_f64 x + y) = (to_f64 ((of_f64 x) + (of_f64 y))%R))). Admitted. (* Why3 goal *) -Lemma model_float_64 : forall (x:R), ((model (to_float64 x)) = (model x)). +Definition mul_f32: f32 -> f32 -> f32. Admitted. (* Why3 goal *) -Lemma model_add : forall (x:R) (y:R), - ((model (x + y)%R) = ((model x) + (model y))%R). +Definition mul_f64: f64 -> f64 -> f64. Admitted. (* Why3 goal *) -Lemma model_mul : forall (x:R) (y:R), - ((model (x * y)%R) = ((model x) * (model y))%R). +Lemma mul_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((mul_f32 x + y) = (to_f32 ((of_f32 x) * (of_f32 y))%R))). Admitted. (* Why3 goal *) -Lemma model_div : forall (x:R) (y:R), - ((model (x / y)%R) = ((model x) / (model y))%R). +Lemma mul_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((mul_f64 x + y) = (to_f64 ((of_f64 x) * (of_f64 y))%R))). Admitted. (* Why3 goal *) -Lemma model_sqrt : forall (x:R), - ((model (Reals.R_sqrt.sqrt x)) = (Reals.R_sqrt.sqrt (model x))). +Definition div_f32: f32 -> f32 -> f32. Admitted. +(* Why3 goal *) +Definition div_f64: f64 -> f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma div_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((div_f32 x + y) = (to_f32 ((of_f32 x) / (of_f32 y))%R))). +Admitted. + +(* Why3 goal *) +Lemma div_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((div_f64 x + y) = (to_f64 ((of_f64 x) / (of_f64 y))%R))). +Admitted. + +(* Why3 goal *) +Definition sqrt_f32: f32 -> f32. +Admitted. + +(* Why3 goal *) +Definition sqrt_f64: f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma sqrt_finite_f32 : forall (x:f32), (is_finite_f32 x) -> + ((sqrt_f32 x) = (to_f32 (Reals.R_sqrt.sqrt (of_f32 x)))). +Admitted. + +(* Why3 goal *) +Lemma sqrt_finite_f64 : forall (x:f64), (is_finite_f64 x) -> + ((sqrt_f64 x) = (to_f64 (Reals.R_sqrt.sqrt (of_f64 x)))). +Admitted. + +(* Why3 goal *) +Definition model_f32: f32 -> R. +Admitted. + +(* Why3 assumption *) +Definition delta_f32 (f:f32): R := + (Reals.Rbasic_fun.Rabs ((of_f32 f) - (model_f32 f))%R). + +(* Why3 assumption *) +Definition error_f32 (f:f32): R := + ((delta_f32 f) / (Reals.Rbasic_fun.Rabs (model_f32 f)))%R. + +(* Why3 goal *) +Definition model_f64: f64 -> R. +Admitted. + +(* Why3 assumption *) +Definition delta_f64 (f:f64): R := + (Reals.Rbasic_fun.Rabs ((of_f64 f) - (model_f64 f))%R). + +(* Why3 assumption *) +Definition error_f64 (f:f64): R := + ((delta_f64 f) / (Reals.Rbasic_fun.Rabs (model_f64 f)))%R. + diff --git a/src/plugins/wp/share/src/cfloat.why b/src/plugins/wp/share/src/cfloat.why index 718a16a45d89854e89b0109a043b08107374a072..711a803b32eab70a51cc93d9f5d22534c97c7c4f 100644 --- a/src/plugins/wp/share/src/cfloat.why +++ b/src/plugins/wp/share/src/cfloat.why @@ -26,6 +26,7 @@ theory Cfloat + use import bool.Bool use import real.RealInfix use import real.Abs use import real.Square @@ -34,140 +35,184 @@ theory Cfloat (* --- C-Integer Arithmetics for Alt-Ergo --- *) (* -------------------------------------------------------------------------- *) + type f32 (* single precision IEEE *) + type f64 (* double precision IEEE *) + (* C-Float Conversion *) - function to_float32 real : real - function to_float64 real : real - predicate is_float32 (x : real) = to_float32(x)=x - predicate is_float64 (x : real) = to_float64(x)=x + function to_f32 real : f32 + function of_f32 f32 : real + + function to_f64 real : f64 + function of_f64 f64 : real (* C-Float Rounding Modes *) type rounding_mode = Up | Down | ToZero | NearestTiesToAway | NearestTiesToEven - function round_double rounding_mode real : real - function round_float rounding_mode real : real + + function round_float rounding_mode real : f32 + function round_double rounding_mode real : f64 axiom float_32: forall x:real [ round_float NearestTiesToEven x ]. - to_float32 x = round_float NearestTiesToEven x + to_f32 x = round_float NearestTiesToEven x axiom float_64: forall x:real [ round_double NearestTiesToEven x ]. - to_float64 x = round_double NearestTiesToEven x + to_f64 x = round_double NearestTiesToEven x (* C-Float Classification *) - type float_kind = Real | Float32 | Float64 | NaN | Inf_pos | Inf_neg + type float_kind = Finite | NaN | Inf_pos | Inf_neg + + function classify_f32 f32 : float_kind + function classify_f64 f64 : float_kind + + predicate is_finite_f32 (f:f32) = (classify_f32 f = Finite) + predicate is_finite_f64 (d:f64) = (classify_f64 d = Finite) + + predicate is_NaN_f32 (f:f32) = (classify_f32 f = NaN) + predicate is_NaN_f64 (d:f64) = (classify_f64 d = NaN) - function classify_float real : float_kind - predicate is_finite32(x:real) = classify_float x = Float32 - predicate is_finite64(x:real) = classify_float(x) = Float32 || - classify_float(x) = Float64 - predicate is_NaN(x:real) = classify_float(x) = NaN - predicate is_infinite(x:real) = classify_float(x) = Inf_pos || - classify_float(x) = Inf_neg - predicate is_positive_infinite(x:real) = classify_float(x) = Inf_pos - predicate is_negative_infinite(x:real) = classify_float(x) = Inf_neg + predicate is_infinite_f32 (f:f32) = (classify_f32 f = Inf_pos || classify_f32 f = Inf_neg) + predicate is_infinite_f64 (d:f64) = (classify_f64 d = Inf_pos || classify_f64 d = Inf_neg) + + predicate is_positive_infinite_f32 (f:f32) = (classify_f32 f = Inf_pos) + predicate is_positive_infinite_f64 (d:f64) = (classify_f64 d = Inf_pos) + + predicate is_negative_infinite_f32 (f:f32) = (classify_f32 f = Inf_neg) + predicate is_negative_infinite_f64 (d:f64) = (classify_f64 d = Inf_neg) axiom is_finite_to_float_32 : - forall x:real [is_finite32(to_float32 x)]. is_finite32(to_float32 x) + forall x:real [is_finite_f32(to_f32 x)]. is_finite_f32 (to_f32 x) axiom is_finite_to_float_64 : - forall x:real [is_finite64(to_float64 x)]. is_finite64(to_float64 x) + forall x:real [is_finite_f64(to_f64 x)]. is_finite_f64 (to_f64 x) - (* C-Float Rounded Arithmetics *) + axiom to_float_is_finite_32 : + forall f:f32 [ to_f32( of_f32 f ) | is_finite_f32(f) ]. is_finite_f32(f) -> to_f32( of_f32 f ) = f - function add_float32 (x:real)(y:real) : real = to_float32 (x +. y) - function add_float64 (x:real)(y:real) : real = to_float64 (x +. y) + axiom to_float_is_finite_64 : + forall d:f64 [ to_f64( of_f64 d ) | is_finite_f64(d) ]. is_finite_f64(d) -> to_f64( of_f64 d ) = d - function mul_float32 (x:real)(y:real) : real = to_float32 (x *. y) - function mul_float64 (x:real)(y:real) : real = to_float64 (x *. y) + (* Finite Constants *) - function div_float32 (x:real)(y:real) : real = to_float32 (x /. y) - function div_float64 (x:real)(y:real) : real = to_float64 (x /. y) + predicate finite (x:real) = (is_finite_f32 (to_f32 x)) /\ (is_finite_f64 (to_f64 x)) - function sqrt_float32 (x:real) : real = to_float32(sqrt x) - function sqrt_float64 (x:real) : real = to_float64(sqrt x) + constant max_f32 : real = 340282346600000016151267322115014000640.0 + constant max_f64 : real = 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0 - function model real : real - function delta(x:real) : real = abs( x -. model x ) - function error(x:real) : real = delta(x) /. abs(model x) + axiom finite_small_f32 : forall x:real. -. max_f64 <=. x <=. max_f32 -> is_finite_f32(to_f32 x) + axiom finite_small_f64 : forall x:real. -. max_f64 <=. x <=. max_f64 -> is_finite_f64(to_f64 x) + axiom finite_range_f32 : forall f:f32. is_finite_f32(f) <-> -. max_f32 <=. of_f32 f <=. max_f32 + axiom finite_range_f64 : forall d:f64. is_finite_f64(d) <-> -. max_f64 <=. of_f64 d <=. max_f64 - axiom model_float_32: forall x:real. model(to_float32 x) = model x - axiom model_float_64: forall x:real. model(to_float64 x) = model x - axiom model_add: forall x y:real. model (x +. y) = model x +. model y - axiom model_mul: forall x y:real. model (x *. y) = model x *. model y - axiom model_div: forall x y:real. model (x /. y) = model x /. model y - axiom model_sqrt: forall x:real. model (sqrt x) = sqrt(model(x)) + (* Equal *) + function eq_f32b (x:f32) (y:f32) : bool + function eq_f64b (x:f64) (y:f64) : bool + predicate eq_f32 (x:f32) (y:f32) = (eq_f32b x y = true) + predicate eq_f64 (x:f64) (y:f64) = (eq_f64b x y = true) -end + axiom eq_finite_f32 : forall x,y:f32 [eq_f32 x y]. is_finite_f32 x -> is_finite_f32 y -> + eq_f32 x y <-> of_f32 x = of_f32 y -(** Realization using why3 floats *) + axiom eq_finite_f64 : forall x,y:f64 [eq_f64 x y]. is_finite_f64 x -> is_finite_f64 y -> + eq_f64 x y <-> of_f64 x = of_f64 y -(* - (* C-Float IEEE-754 *) + (* Not Equal *) - use export floating_point.Rounding - use import floating_point.Single - use import floating_point.Double + function ne_f32b (x:f32) (y:f32) : bool + function ne_f64b (x:f64) (y:f64) : bool + predicate ne_f32 (x:f32) (y:f32) = (ne_f32b x y = true) + predicate ne_f64 (x:f64) (y:f64) = (ne_f64b x y = true) - type rounding_mode = Rounding.mode + axiom ne_finite_f32 : forall x,y:f32 [ne_f32 x y]. is_finite_f32 x -> is_finite_f32 y -> + ne_f32 x y <-> of_f32 x <> of_f32 y - function round_float (m:rounding_mode) (x:real) : real = Single.round m x - function round_double (m:rounding_mode) (x:real) : real = Double.round m x + axiom ne_finite_f64 : forall x,y:f64 [ne_f64 x y]. is_finite_f64 x -> is_finite_f64 y -> + ne_f64 x y <-> of_f64 x <> of_f64 y + (* Comparison (<=) *) - (* C-Float Conversion *) + function le_f32b (x:f32) (y:f32) : bool + function le_f64b (x:f64) (y:f64) : bool + predicate le_f32 (x:f32) (y:f32) = (le_f32b x y = true) + predicate le_f64 (x:f64) (y:f64) = (le_f64b x y = true) - function to_float32 (x:real) : real = Single.round NearestTiesToEven x - function to_float64 (x:real) : real = Double.round NearestTiesToEven x + axiom le_finite_f32 : forall x,y:f32 [le_f32 x y]. is_finite_f32 x -> is_finite_f32 y -> + le_f32 x y <-> of_f32 x <=. of_f32 y - predicate is_float32 real - predicate is_float64 real + axiom le_finite_f64 : forall x,y:f64 [le_f64 x y]. is_finite_f64 x -> is_finite_f64 y -> + le_f64 x y <-> of_f64 x <=. of_f64 y + (* Comparison (<) *) - axiom def_float32: forall x:real [ is_float32(x) ]. is_float32 x -> to_float32 x = x - axiom def_float64: forall x:real [ is_float64(x) ]. is_float64 x -> to_float64 x = x + function lt_f32b (x:f32) (y:f32) : bool + function lt_f64b (x:f64) (y:f64) : bool + predicate lt_f32 (x:f32) (y:f32) = (lt_f32b x y = true) + predicate lt_f64 (x:f64) (y:f64) = (lt_f64b x y = true) - predicate is_finite32 (x:real) = abs(x) <=. Single.max_single - predicate is_finite64 (x:real) = abs(x) <=. Double.max_double + axiom lt_finite_f32 : forall x,y:f32 [lt_f32 x y]. is_finite_f32 x -> is_finite_f32 y -> + lt_f32 x y <-> of_f32 x <. of_f32 y - axiom is_finite_to_float_32 : - forall x:real [is_finite32(to_float32 x)]. is_finite32(to_float32 x) + axiom lt_finite_f64 : forall x,y:f64 [lt_f64 x y]. is_finite_f64 x -> is_finite_f64 y -> + lt_f64 x y <-> of_f64 x <. of_f64 y - axiom is_finite_to_float_64 : - forall x:real [is_finite64(to_float64 x)]. is_finite64(to_float64 x) + (* Negation *) + + + function neg_f32 (x:f32) : f32 + function neg_f64 (x:f64) : f64 + + axiom neg_finite_f32 : forall x:f32 [neg_f32 x]. is_finite_f32 x -> of_f32 (neg_f32 x) = -. (of_f32 x) + axiom neg_finite_f64 : forall x:f64 [neg_f64 x]. is_finite_f64 x -> of_f64 (neg_f64 x) = -. (of_f64 x) + + (* Addition *) - (* C-Float Conversions are projections *) + function add_f32 (x:f32) (y:f32) : f32 + function add_f64 (x:f64) (y:f64) : f64 - axiom proj_float32 : forall x:real [ to_float32(to_float32 x) ]. to_float32(to_float32 x)=to_float32 x - axiom proj_float64 : forall x:real [ to_float64(to_float64 x) ]. to_float64(to_float64 x)=to_float64 x + axiom add_finite_f32 : forall x,y:f32 [add_f32 x y]. is_finite_f32 x -> is_finite_f32 y -> + add_f32 x y = to_f32 (of_f32 x +. of_f32 y) - (* C-Float Arithemtics *) + axiom add_finite_f64 : forall x,y:f64 [add_f64 x y]. is_finite_f64 x -> is_finite_f64 y -> + add_f64 x y = to_f64 (of_f64 x +. of_f64 y) + (* Multiplication *) - function add_float32(x:real)(y:real):real = to_float32(x +. y) - function add_float64(x:real)(y:real):real = to_float64(x +. y) + function mul_f32 (x:f32) (y:f32) : f32 + function mul_f64 (x:f64) (y:f64) : f64 - function mul_float32(x:real)(y:real):real = to_float32(x *. y) - function mul_float64(x:real)(y:real):real = to_float64(x *. y) + axiom mul_finite_f32 : forall x,y:f32 [mul_f32 x y]. is_finite_f32 x -> is_finite_f32 y -> + mul_f32 x y = to_f32 (of_f32 x *. of_f32 y) - function div_float32(x:real)(y:real):real = to_float32(x /. y) - function div_float64(x:real)(y:real):real = to_float64(x /. y) + axiom mul_finite_f64 : forall x,y:f64 [mul_f64 x y]. is_finite_f64 x -> is_finite_f64 y -> + mul_f64 x y = to_f64 (of_f64 x *. of_f64 y) + (* Division *) - function sqrt_float32(x:real):real = to_float32(sqrt x) - function sqrt_float64(x:real):real = to_float64(sqrt x) + function div_f32 (x:f32) (y:f32) : f32 + function div_f64 (x:f64) (y:f64) : f64 - (* C-Float Precision *) + axiom div_finite_f32 : forall x,y:f32 [div_f32 x y]. is_finite_f32 x -> is_finite_f32 y -> + div_f32 x y = to_f32 (of_f32 x /. of_f32 y) - function model real : real - function delta (x:real) : real = abs ( x -. (model x) ) - function error (x:real) : real = (delta x) /. (abs (model x)) + axiom div_finite_f64 : forall x,y:f64 [div_f64 x y]. is_finite_f64 x -> is_finite_f64 y -> + div_f64 x y = to_f64 (of_f64 x /. of_f64 y) - axiom model_float_32: forall x:real. model(to_float32 x) = model x - axiom model_float_64: forall x:real. model(to_float64 x) = model x - axiom model_add: forall x y:real. model(x +. y) = model x +. model y - axiom model_mul: forall x y:real. model(x *. y) = model x *. model y - axiom model_div: forall x y:real. model(x /. y) = model x /. model y - axiom model_sqrt: forall x:real. model(sqrt(x)) = sqrt(model x) + (* Square Root *) + function sqrt_f32 f32 : f32 + function sqrt_f64 f64 : f64 -*) + axiom sqrt_finite_f32 : forall x:f32 [sqrt_f32 x]. is_finite_f32 x -> sqrt_f32 x = to_f32 (sqrt (of_f32 x)) + axiom sqrt_finite_f64 : forall x:f64 [sqrt_f64 x]. is_finite_f64 x -> sqrt_f64 x = to_f64 (sqrt (of_f64 x)) + + (* Models *) + + function model_f32 (f:f32) : real + function delta_f32 (f:f32) : real = abs( of_f32 f -. model_f32 f ) + function error_f32 (f:f32) : real = (delta_f32 f) /. (abs (model_f32 f)) + + function model_f64 (f:f64) : real + function delta_f64 (f:f64) : real = abs( of_f64 f -. model_f64 f ) + function error_f64 (f:f64) : real = (delta_f64 f) /. (abs (model_f64 f)) + +end diff --git a/src/plugins/wp/share/why3/Cfloat.v b/src/plugins/wp/share/why3/Cfloat.v index 0b7666721938c60d6a21bf9c9fda4a28ecd4b6c6..fd245b87bfb945f92a72fc968f38f392fd83c6b4 100644 --- a/src/plugins/wp/share/why3/Cfloat.v +++ b/src/plugins/wp/share/why3/Cfloat.v @@ -26,24 +26,35 @@ Require Import BuiltIn. Require Reals.Rbasic_fun. Require Reals.R_sqrt. Require BuiltIn. +Require bool.Bool. Require real.Real. Require real.RealInfix. Require real.Abs. Require real.Square. (* Why3 goal *) -Definition to_float32: R -> R. +Definition f32 : Type. Admitted. (* Why3 goal *) -Definition to_float64: R -> R. +Definition f64 : Type. Admitted. -(* Why3 assumption *) -Definition is_float32 (x:R): Prop := ((to_float32 x) = x). +(* Why3 goal *) +Definition to_f32: R -> f32. +Admitted. -(* Why3 assumption *) -Definition is_float64 (x:R): Prop := ((to_float64 x) = x). +(* Why3 goal *) +Definition of_f32: f32 -> R. +Admitted. + +(* Why3 goal *) +Definition to_f64: R -> f64. +Admitted. + +(* Why3 goal *) +Definition of_f64: f64 -> R. +Admitted. (* Why3 assumption *) Inductive rounding_mode := @@ -56,28 +67,26 @@ Axiom rounding_mode_WhyType : WhyType rounding_mode. Existing Instance rounding_mode_WhyType. (* Why3 goal *) -Definition round_double: rounding_mode -> R -> R. +Definition round_float: rounding_mode -> R -> f32. Admitted. (* Why3 goal *) -Definition round_float: rounding_mode -> R -> R. +Definition round_double: rounding_mode -> R -> f64. Admitted. (* Why3 goal *) -Lemma float_32 : forall (x:R), - ((to_float32 x) = (round_float NearestTiesToEven x)). +Lemma float_32 : forall (x:R), ((to_f32 x) = (round_float NearestTiesToEven + x)). Admitted. (* Why3 goal *) -Lemma float_64 : forall (x:R), - ((to_float64 x) = (round_double NearestTiesToEven x)). +Lemma float_64 : forall (x:R), ((to_f64 x) = (round_double NearestTiesToEven + x)). Admitted. (* Why3 assumption *) Inductive float_kind := - | Real : float_kind - | Float32 : float_kind - | Float64 : float_kind + | Finite : float_kind | NaN : float_kind | Inf_pos : float_kind | Inf_neg : float_kind. @@ -85,99 +94,310 @@ Axiom float_kind_WhyType : WhyType float_kind. Existing Instance float_kind_WhyType. (* Why3 goal *) -Definition classify_float: R -> float_kind. +Definition classify_f32: f32 -> float_kind. Admitted. +(* Why3 goal *) +Definition classify_f64: f64 -> float_kind. +Admitted. + +(* Why3 assumption *) +Definition is_finite_f32 (f:f32): Prop := ((classify_f32 f) = Finite). + +(* Why3 assumption *) +Definition is_finite_f64 (d:f64): Prop := ((classify_f64 d) = Finite). + +(* Why3 assumption *) +Definition is_NaN_f32 (f:f32): Prop := ((classify_f32 f) = NaN). + +(* Why3 assumption *) +Definition is_NaN_f64 (d:f64): Prop := ((classify_f64 d) = NaN). + (* Why3 assumption *) -Definition is_finite32 (x:R): Prop := ((classify_float x) = Float32). +Definition is_infinite_f32 (f:f32): Prop := ((classify_f32 f) = Inf_pos) \/ + ((classify_f32 f) = Inf_neg). (* Why3 assumption *) -Definition is_finite64 (x:R): Prop := ((classify_float x) = Float32) \/ - ((classify_float x) = Float64). +Definition is_infinite_f64 (d:f64): Prop := ((classify_f64 d) = Inf_pos) \/ + ((classify_f64 d) = Inf_neg). (* Why3 assumption *) -Definition is_NaN (x:R): Prop := ((classify_float x) = NaN). +Definition is_positive_infinite_f32 (f:f32): Prop := + ((classify_f32 f) = Inf_pos). (* Why3 assumption *) -Definition is_infinite (x:R): Prop := ((classify_float x) = Inf_pos) \/ - ((classify_float x) = Inf_neg). +Definition is_positive_infinite_f64 (d:f64): Prop := + ((classify_f64 d) = Inf_pos). (* Why3 assumption *) -Definition is_positive_infinite (x:R): Prop := - ((classify_float x) = Inf_pos). +Definition is_negative_infinite_f32 (f:f32): Prop := + ((classify_f32 f) = Inf_neg). (* Why3 assumption *) -Definition is_negative_infinite (x:R): Prop := - ((classify_float x) = Inf_neg). +Definition is_negative_infinite_f64 (d:f64): Prop := + ((classify_f64 d) = Inf_neg). (* Why3 goal *) -Lemma is_finite_to_float_32 : forall (x:R), (is_finite32 (to_float32 x)). +Lemma is_finite_to_float_32 : forall (x:R), (is_finite_f32 (to_f32 x)). Admitted. (* Why3 goal *) -Lemma is_finite_to_float_64 : forall (x:R), (is_finite64 (to_float64 x)). +Lemma is_finite_to_float_64 : forall (x:R), (is_finite_f64 (to_f64 x)). Admitted. -(* Why3 assumption *) -Definition add_float32 (x:R) (y:R): R := (to_float32 (x + y)%R). +(* Why3 goal *) +Lemma to_float_is_finite_32 : forall (f:f32), (is_finite_f32 f) -> + ((to_f32 (of_f32 f)) = f). +Admitted. + +(* Why3 goal *) +Lemma to_float_is_finite_64 : forall (d:f64), (is_finite_f64 d) -> + ((to_f64 (of_f64 d)) = d). +Admitted. (* Why3 assumption *) -Definition add_float64 (x:R) (y:R): R := (to_float64 (x + y)%R). +Definition finite (x:R): Prop := (is_finite_f32 (to_f32 x)) /\ (is_finite_f64 + (to_f64 x)). + +(* Why3 goal *) +Lemma finite_small_f32 : forall (x:R), + (((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R <= x)%R /\ + (x <= 340282346600000016151267322115014000640%R)%R) -> (is_finite_f32 + (to_f32 x)). +Admitted. + +(* Why3 goal *) +Lemma finite_small_f64 : forall (x:R), + (((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R <= x)%R /\ + (x <= 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R) -> + (is_finite_f64 (to_f64 x)). +Admitted. + +(* Why3 goal *) +Lemma finite_range_f32 : forall (f:f32), (is_finite_f32 f) <-> + (((-340282346600000016151267322115014000640%R)%R <= (of_f32 f))%R /\ + ((of_f32 f) <= 340282346600000016151267322115014000640%R)%R). +Admitted. + +(* Why3 goal *) +Lemma finite_range_f64 : forall (d:f64), (is_finite_f64 d) <-> + (((-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R <= (of_f64 d))%R /\ + ((of_f64 d) <= 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368%R)%R). +Admitted. + +(* Why3 goal *) +Definition eq_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition eq_f64b: f64 -> f64 -> bool. +Admitted. (* Why3 assumption *) -Definition mul_float32 (x:R) (y:R): R := (to_float32 (x * y)%R). +Definition eq_f32 (x:f32) (y:f32): Prop := ((eq_f32b x y) = true). (* Why3 assumption *) -Definition mul_float64 (x:R) (y:R): R := (to_float64 (x * y)%R). +Definition eq_f64 (x:f64) (y:f64): Prop := ((eq_f64b x y) = true). + +(* Why3 goal *) +Lemma eq_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((eq_f32 x y) <-> ((of_f32 x) = (of_f32 y)))). +Admitted. + +(* Why3 goal *) +Lemma eq_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((eq_f64 x y) <-> ((of_f64 x) = (of_f64 y)))). +Admitted. + +(* Why3 goal *) +Definition ne_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition ne_f64b: f64 -> f64 -> bool. +Admitted. (* Why3 assumption *) -Definition div_float32 (x:R) (y:R): R := (to_float32 (x / y)%R). +Definition ne_f32 (x:f32) (y:f32): Prop := ((ne_f32b x y) = true). (* Why3 assumption *) -Definition div_float64 (x:R) (y:R): R := (to_float64 (x / y)%R). +Definition ne_f64 (x:f64) (y:f64): Prop := ((ne_f64b x y) = true). + +(* Why3 goal *) +Lemma ne_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((ne_f32 x y) <-> ~ ((of_f32 x) = (of_f32 y)))). +Admitted. + +(* Why3 goal *) +Lemma ne_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((ne_f64 x y) <-> ~ ((of_f64 x) = (of_f64 y)))). +Admitted. + +(* Why3 goal *) +Definition le_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition le_f64b: f64 -> f64 -> bool. +Admitted. (* Why3 assumption *) -Definition sqrt_float32 (x:R): R := (to_float32 (Reals.R_sqrt.sqrt x)). +Definition le_f32 (x:f32) (y:f32): Prop := ((le_f32b x y) = true). (* Why3 assumption *) -Definition sqrt_float64 (x:R): R := (to_float64 (Reals.R_sqrt.sqrt x)). +Definition le_f64 (x:f64) (y:f64): Prop := ((le_f64b x y) = true). (* Why3 goal *) -Definition model: R -> R. +Lemma le_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((le_f32 x y) <-> ((of_f32 x) <= (of_f32 y))%R)). +Admitted. + +(* Why3 goal *) +Lemma le_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((le_f64 x y) <-> ((of_f64 x) <= (of_f64 y))%R)). +Admitted. + +(* Why3 goal *) +Definition lt_f32b: f32 -> f32 -> bool. +Admitted. + +(* Why3 goal *) +Definition lt_f64b: f64 -> f64 -> bool. Admitted. (* Why3 assumption *) -Definition delta (x:R): R := (Reals.Rbasic_fun.Rabs (x - (model x))%R). +Definition lt_f32 (x:f32) (y:f32): Prop := ((lt_f32b x y) = true). (* Why3 assumption *) -Definition error (x:R): R := - ((delta x) / (Reals.Rbasic_fun.Rabs (model x)))%R. +Definition lt_f64 (x:f64) (y:f64): Prop := ((lt_f64b x y) = true). + +(* Why3 goal *) +Lemma lt_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((lt_f32 x y) <-> ((of_f32 x) < (of_f32 y))%R)). +Admitted. + +(* Why3 goal *) +Lemma lt_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((lt_f64 x y) <-> ((of_f64 x) < (of_f64 y))%R)). +Admitted. + +(* Why3 goal *) +Definition neg_f32: f32 -> f32. +Admitted. + +(* Why3 goal *) +Definition neg_f64: f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma neg_finite_f32 : forall (x:f32), (is_finite_f32 x) -> + ((of_f32 (neg_f32 x)) = (-(of_f32 x))%R). +Admitted. + +(* Why3 goal *) +Lemma neg_finite_f64 : forall (x:f64), (is_finite_f64 x) -> + ((of_f64 (neg_f64 x)) = (-(of_f64 x))%R). +Admitted. + +(* Why3 goal *) +Definition add_f32: f32 -> f32 -> f32. +Admitted. + +(* Why3 goal *) +Definition add_f64: f64 -> f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma add_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((add_f32 x + y) = (to_f32 ((of_f32 x) + (of_f32 y))%R))). +Admitted. (* Why3 goal *) -Lemma model_float_32 : forall (x:R), ((model (to_float32 x)) = (model x)). +Lemma add_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((add_f64 x + y) = (to_f64 ((of_f64 x) + (of_f64 y))%R))). Admitted. (* Why3 goal *) -Lemma model_float_64 : forall (x:R), ((model (to_float64 x)) = (model x)). +Definition mul_f32: f32 -> f32 -> f32. Admitted. (* Why3 goal *) -Lemma model_add : forall (x:R) (y:R), - ((model (x + y)%R) = ((model x) + (model y))%R). +Definition mul_f64: f64 -> f64 -> f64. Admitted. (* Why3 goal *) -Lemma model_mul : forall (x:R) (y:R), - ((model (x * y)%R) = ((model x) * (model y))%R). +Lemma mul_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((mul_f32 x + y) = (to_f32 ((of_f32 x) * (of_f32 y))%R))). Admitted. (* Why3 goal *) -Lemma model_div : forall (x:R) (y:R), - ((model (x / y)%R) = ((model x) / (model y))%R). +Lemma mul_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((mul_f64 x + y) = (to_f64 ((of_f64 x) * (of_f64 y))%R))). Admitted. (* Why3 goal *) -Lemma model_sqrt : forall (x:R), - ((model (Reals.R_sqrt.sqrt x)) = (Reals.R_sqrt.sqrt (model x))). +Definition div_f32: f32 -> f32 -> f32. Admitted. +(* Why3 goal *) +Definition div_f64: f64 -> f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma div_finite_f32 : forall (x:f32) (y:f32), (is_finite_f32 x) -> + ((is_finite_f32 y) -> ((div_f32 x + y) = (to_f32 ((of_f32 x) / (of_f32 y))%R))). +Admitted. + +(* Why3 goal *) +Lemma div_finite_f64 : forall (x:f64) (y:f64), (is_finite_f64 x) -> + ((is_finite_f64 y) -> ((div_f64 x + y) = (to_f64 ((of_f64 x) / (of_f64 y))%R))). +Admitted. + +(* Why3 goal *) +Definition sqrt_f32: f32 -> f32. +Admitted. + +(* Why3 goal *) +Definition sqrt_f64: f64 -> f64. +Admitted. + +(* Why3 goal *) +Lemma sqrt_finite_f32 : forall (x:f32), (is_finite_f32 x) -> + ((sqrt_f32 x) = (to_f32 (Reals.R_sqrt.sqrt (of_f32 x)))). +Admitted. + +(* Why3 goal *) +Lemma sqrt_finite_f64 : forall (x:f64), (is_finite_f64 x) -> + ((sqrt_f64 x) = (to_f64 (Reals.R_sqrt.sqrt (of_f64 x)))). +Admitted. + +(* Why3 goal *) +Definition model_f32: f32 -> R. +Admitted. + +(* Why3 assumption *) +Definition delta_f32 (f:f32): R := + (Reals.Rbasic_fun.Rabs ((of_f32 f) - (model_f32 f))%R). + +(* Why3 assumption *) +Definition error_f32 (f:f32): R := + ((delta_f32 f) / (Reals.Rbasic_fun.Rabs (model_f32 f)))%R. + +(* Why3 goal *) +Definition model_f64: f64 -> R. +Admitted. + +(* Why3 assumption *) +Definition delta_f64 (f:f64): R := + (Reals.Rbasic_fun.Rabs ((of_f64 f) - (model_f64 f))%R). + +(* Why3 assumption *) +Definition error_f64 (f:f64): R := + ((delta_f64 f) / (Reals.Rbasic_fun.Rabs (model_f64 f)))%R. + diff --git a/src/plugins/wp/share/why3/Cfloat.why b/src/plugins/wp/share/why3/Cfloat.why index c9f00f51c5f5c6fc749708f962605f061d39d436..91baa7e38d97daab5d8e31a315e87f2486a4fe46 100644 --- a/src/plugins/wp/share/why3/Cfloat.why +++ b/src/plugins/wp/share/why3/Cfloat.why @@ -21,17 +21,22 @@ (**************************************************************************) theory Cfloat +use bool.Bool as Bool use real.Real as Real use real.Abs as Abs use real.Square as Square -function to_float32 real : real +type f32 -function to_float64 real : real +type f64 -predicate is_float32 (x:real) = ((to_float32 x) = (x)) +function to_f32 real : f32 -predicate is_float64 (x:real) = ((to_float64 x) = (x)) +function of_f32 f32 : real + +function to_f64 real : f64 + +function of_f64 f64 : real type rounding_mode = | Up @@ -40,82 +45,210 @@ type rounding_mode = | NearestTiesToAway | NearestTiesToEven -function round_double rounding_mode real : real +function round_float rounding_mode real : f32 -function round_float rounding_mode real : real +function round_double rounding_mode real : f64 -axiom float_32 : forall x:real [round_float NearestTiesToEven x]. - ((to_float32 x) = (round_float NearestTiesToEven x)) +axiom float_32 : forall x:real [round_float NearestTiesToEven x]. ((to_f32 + x) = (round_float NearestTiesToEven x)) -axiom float_64 : forall x:real [round_double NearestTiesToEven x]. - ((to_float64 x) = (round_double NearestTiesToEven x)) +axiom float_64 : forall x:real [round_double NearestTiesToEven x]. ((to_f64 + x) = (round_double NearestTiesToEven x)) type float_kind = - | Real - | Float32 - | Float64 + | Finite | NaN | Inf_pos | Inf_neg -function classify_float real : float_kind +function classify_f32 f32 : float_kind + +function classify_f64 f64 : float_kind + +predicate is_finite_f32 (f:f32) = ((classify_f32 f) = (Finite)) + +predicate is_finite_f64 (d:f64) = ((classify_f64 d) = (Finite)) + +predicate is_NaN_f32 (f:f32) = ((classify_f32 f) = (NaN)) + +predicate is_NaN_f64 (d:f64) = ((classify_f64 d) = (NaN)) + +predicate is_infinite_f32 (f:f32) = ("asym_split" ((classify_f32 + f) = (Inf_pos))) || ((classify_f32 f) = (Inf_neg)) + +predicate is_infinite_f64 (d:f64) = ("asym_split" ((classify_f64 + d) = (Inf_pos))) || ((classify_f64 d) = (Inf_neg)) + +predicate is_positive_infinite_f32 (f:f32) = ((classify_f32 f) = (Inf_pos)) + +predicate is_positive_infinite_f64 (d:f64) = ((classify_f64 d) = (Inf_pos)) + +predicate is_negative_infinite_f32 (f:f32) = ((classify_f32 f) = (Inf_neg)) + +predicate is_negative_infinite_f64 (d:f64) = ((classify_f64 d) = (Inf_neg)) + +axiom is_finite_to_float_32 : forall x:real [is_finite_f32 (to_f32 x)]. + is_finite_f32 (to_f32 x) + +axiom is_finite_to_float_64 : forall x:real [is_finite_f64 (to_f64 x)]. + is_finite_f64 (to_f64 x) + +axiom to_float_is_finite_32 : forall f:f32 [to_f32 (of_f32 f)| is_finite_f32 + f]. is_finite_f32 f -> ((to_f32 (of_f32 f)) = (f)) + +axiom to_float_is_finite_64 : forall d:f64 [to_f64 (of_f64 d)| is_finite_f64 + d]. is_finite_f64 d -> ((to_f64 (of_f64 d)) = (d)) + +predicate finite (x:real) = is_finite_f32 (to_f32 x) /\ is_finite_f64 (to_f64 + x) + +function max_f32 : real = 340282346600000016151267322115014000640.0 + +function max_f64 : real = + 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0 + +axiom finite_small_f32 : forall x:real. + (Real.(<=) ((Real.(-_) (max_f64))) (x)) /\ (Real.(<=) (x) (max_f32)) -> + is_finite_f32 (to_f32 x) + +axiom finite_small_f64 : forall x:real. + (Real.(<=) ((Real.(-_) (max_f64))) (x)) /\ (Real.(<=) (x) (max_f64)) -> + is_finite_f64 (to_f64 x) + +axiom finite_range_f32 : forall f:f32. is_finite_f32 f <-> + (Real.(<=) ((Real.(-_) (max_f32))) (of_f32 f)) /\ (Real.(<=) (of_f32 + f) (max_f32)) + +axiom finite_range_f64 : forall d:f64. is_finite_f64 d <-> + (Real.(<=) ((Real.(-_) (max_f64))) (of_f64 d)) /\ (Real.(<=) (of_f64 + d) (max_f64)) + +function eq_f32b f32 f32 : Bool.bool + +function eq_f64b f64 f64 : Bool.bool + +predicate eq_f32 (x:f32) (y:f32) = ((eq_f32b x y) = (Bool.True)) + +predicate eq_f64 (x:f64) (y:f64) = ((eq_f64b x y) = (Bool.True)) + +axiom eq_finite_f32 : forall x:f32, y:f32 [eq_f32 x y]. is_finite_f32 x -> + is_finite_f32 y -> eq_f32 x y <-> ((of_f32 x) = (of_f32 y)) + +axiom eq_finite_f64 : forall x:f64, y:f64 [eq_f64 x y]. is_finite_f64 x -> + is_finite_f64 y -> eq_f64 x y <-> ((of_f64 x) = (of_f64 y)) + +function ne_f32b f32 f32 : Bool.bool + +function ne_f64b f64 f64 : Bool.bool + +predicate ne_f32 (x:f32) (y:f32) = ((ne_f32b x y) = (Bool.True)) + +predicate ne_f64 (x:f64) (y:f64) = ((ne_f64b x y) = (Bool.True)) + +axiom ne_finite_f32 : forall x:f32, y:f32 [ne_f32 x y]. is_finite_f32 x -> + is_finite_f32 y -> ne_f32 x y <-> not ((of_f32 x) = (of_f32 y)) + +axiom ne_finite_f64 : forall x:f64, y:f64 [ne_f64 x y]. is_finite_f64 x -> + is_finite_f64 y -> ne_f64 x y <-> not ((of_f64 x) = (of_f64 y)) + +function le_f32b f32 f32 : Bool.bool + +function le_f64b f64 f64 : Bool.bool + +predicate le_f32 (x:f32) (y:f32) = ((le_f32b x y) = (Bool.True)) + +predicate le_f64 (x:f64) (y:f64) = ((le_f64b x y) = (Bool.True)) + +axiom le_finite_f32 : forall x:f32, y:f32 [le_f32 x y]. is_finite_f32 x -> + is_finite_f32 y -> le_f32 x y <-> (Real.(<=) (of_f32 x) (of_f32 y)) + +axiom le_finite_f64 : forall x:f64, y:f64 [le_f64 x y]. is_finite_f64 x -> + is_finite_f64 y -> le_f64 x y <-> (Real.(<=) (of_f64 x) (of_f64 y)) + +function lt_f32b f32 f32 : Bool.bool + +function lt_f64b f64 f64 : Bool.bool + +predicate lt_f32 (x:f32) (y:f32) = ((lt_f32b x y) = (Bool.True)) + +predicate lt_f64 (x:f64) (y:f64) = ((lt_f64b x y) = (Bool.True)) + +axiom lt_finite_f32 : forall x:f32, y:f32 [lt_f32 x y]. is_finite_f32 x -> + is_finite_f32 y -> lt_f32 x y <-> (Real.(<) (of_f32 x) (of_f32 y)) + +axiom lt_finite_f64 : forall x:f64, y:f64 [lt_f64 x y]. is_finite_f64 x -> + is_finite_f64 y -> lt_f64 x y <-> (Real.(<) (of_f64 x) (of_f64 y)) + +function neg_f32 f32 : f32 -predicate is_finite32 (x:real) = ((classify_float x) = (Float32)) +function neg_f64 f64 : f64 -predicate is_finite64 (x:real) = ("asym_split" ((classify_float - x) = (Float32))) || ((classify_float x) = (Float64)) +axiom neg_finite_f32 : forall x:f32 [neg_f32 x]. is_finite_f32 x -> ((of_f32 + (neg_f32 x)) = ((Real.(-_) (of_f32 x)))) -predicate is_NaN (x:real) = ((classify_float x) = (NaN)) +axiom neg_finite_f64 : forall x:f64 [neg_f64 x]. is_finite_f64 x -> ((of_f64 + (neg_f64 x)) = ((Real.(-_) (of_f64 x)))) -predicate is_infinite (x:real) = ("asym_split" ((classify_float - x) = (Inf_pos))) || ((classify_float x) = (Inf_neg)) +function add_f32 f32 f32 : f32 -predicate is_positive_infinite (x:real) = ((classify_float x) = (Inf_pos)) +function add_f64 f64 f64 : f64 -predicate is_negative_infinite (x:real) = ((classify_float x) = (Inf_neg)) +axiom add_finite_f32 : forall x:f32, y:f32 [add_f32 x y]. is_finite_f32 x -> + is_finite_f32 y -> ((add_f32 x y) = (to_f32 (Real.(+) (of_f32 x) (of_f32 + y)))) -axiom is_finite_to_float_32 : forall x:real [is_finite32 (to_float32 x)]. - is_finite32 (to_float32 x) +axiom add_finite_f64 : forall x:f64, y:f64 [add_f64 x y]. is_finite_f64 x -> + is_finite_f64 y -> ((add_f64 x y) = (to_f64 (Real.(+) (of_f64 x) (of_f64 + y)))) -axiom is_finite_to_float_64 : forall x:real [is_finite64 (to_float64 x)]. - is_finite64 (to_float64 x) +function mul_f32 f32 f32 : f32 -function add_float32 (x:real) (y:real) : real = to_float32 (Real.(+) (x) (y)) +function mul_f64 f64 f64 : f64 -function add_float64 (x:real) (y:real) : real = to_float64 (Real.(+) (x) (y)) +axiom mul_finite_f32 : forall x:f32, y:f32 [mul_f32 x y]. is_finite_f32 x -> + is_finite_f32 y -> ((mul_f32 x y) = (to_f32 (Real.(*) (of_f32 x) (of_f32 + y)))) -function mul_float32 (x:real) (y:real) : real = to_float32 (Real.(*) (x) (y)) +axiom mul_finite_f64 : forall x:f64, y:f64 [mul_f64 x y]. is_finite_f64 x -> + is_finite_f64 y -> ((mul_f64 x y) = (to_f64 (Real.(*) (of_f64 x) (of_f64 + y)))) -function mul_float64 (x:real) (y:real) : real = to_float64 (Real.(*) (x) (y)) +function div_f32 f32 f32 : f32 -function div_float32 (x:real) (y:real) : real = to_float32 (Real.(/) (x) (y)) +function div_f64 f64 f64 : f64 -function div_float64 (x:real) (y:real) : real = to_float64 (Real.(/) (x) (y)) +axiom div_finite_f32 : forall x:f32, y:f32 [div_f32 x y]. is_finite_f32 x -> + is_finite_f32 y -> ((div_f32 x y) = (to_f32 (Real.(/) (of_f32 x) (of_f32 + y)))) -function sqrt_float32 (x:real) : real = to_float32 (Square.sqrt x) +axiom div_finite_f64 : forall x:f64, y:f64 [div_f64 x y]. is_finite_f64 x -> + is_finite_f64 y -> ((div_f64 x y) = (to_f64 (Real.(/) (of_f64 x) (of_f64 + y)))) -function sqrt_float64 (x:real) : real = to_float64 (Square.sqrt x) +function sqrt_f32 f32 : f32 -function model real : real +function sqrt_f64 f64 : f64 -function delta (x:real) : real = Abs.abs (Real.(-) (x) (model x)) +axiom sqrt_finite_f32 : forall x:f32 [sqrt_f32 x]. is_finite_f32 x -> + ((sqrt_f32 x) = (to_f32 (Square.sqrt (of_f32 x)))) -function error (x:real) : real = (Real.(/) (delta x) (Abs.abs (model x))) +axiom sqrt_finite_f64 : forall x:f64 [sqrt_f64 x]. is_finite_f64 x -> + ((sqrt_f64 x) = (to_f64 (Square.sqrt (of_f64 x)))) -axiom model_float_32 : forall x:real. ((model (to_float32 x)) = (model x)) +function model_f32 f32 : real -axiom model_float_64 : forall x:real. ((model (to_float64 x)) = (model x)) +function delta_f32 (f:f32) : real = Abs.abs (Real.(-) (of_f32 f) (model_f32 + f)) -axiom model_add : forall x:real, y:real. ((model - (Real.(+) (x) (y))) = ((Real.(+) (model x) (model y)))) +function error_f32 (f:f32) : real = (Real.(/) (delta_f32 f) (Abs.abs + (model_f32 f))) -axiom model_mul : forall x:real, y:real. ((model - (Real.(*) (x) (y))) = ((Real.(*) (model x) (model y)))) +function model_f64 f64 : real -axiom model_div : forall x:real, y:real. ((model - (Real.(/) (x) (y))) = ((Real.(/) (model x) (model y)))) +function delta_f64 (f:f64) : real = Abs.abs (Real.(-) (of_f64 f) (model_f64 + f)) -axiom model_sqrt : forall x:real. ((model (Square.sqrt x)) = (Square.sqrt - (model x))) +function error_f64 (f:f64) : real = (Real.(/) (delta_f64 f) (Abs.abs + (model_f64 f))) end diff --git a/src/plugins/wp/share/wp.driver b/src/plugins/wp/share/wp.driver index 8e5056482a5df61dd216775890657cf170601b3f..7dd358acc6900842611fed12bc90a0c096eaa60c 100644 --- a/src/plugins/wp/share/wp.driver +++ b/src/plugins/wp/share/wp.driver @@ -95,16 +95,16 @@ ctor "\\Down"() = "Down"; ctor "\\ToZero"() = "ToZero"; ctor "\\NearestAway"() = "NearestTiesToAway"; ctor "\\NearestEven"() = "NearestTiesToEven"; -predicate "\\is_finite"(float32) = "is_finite32"; -predicate "\\is_finite"(float64) = "is_finite64"; -predicate "\\is_NaN"(float32) = "is_NaN"; -predicate "\\is_NaN"(float64) = "is_NaN"; -predicate "\\is_infinite"(float32) = "is_infinite" ; -predicate "\\is_infinite"(float64) = "is_infinite" ; -predicate "\\is_plus_infinity"(float32) = "is_positive_infinite"; -predicate "\\is_plus_infinity"(float64) = "is_positive_infinite"; -predicate "\\is_minus_infinity"(float32) = "is_negative_infinite"; -predicate "\\is_minus_infinity"(float64) = "is_negative_infinite"; +predicate "\\is_finite"(float32) = "is_finite_f32"; +predicate "\\is_finite"(float64) = "is_finite_f64"; +predicate "\\is_NaN"(float32) = "is_NaN_f32"; +predicate "\\is_NaN"(float64) = "is_NaN_f64"; +predicate "\\is_infinite"(float32) = "is_infinite_f32" ; +predicate "\\is_infinite"(float64) = "is_infinite_f64" ; +predicate "\\is_plus_infinity"(float32) = "is_positive_infinite_f32"; +predicate "\\is_plus_infinity"(float64) = "is_positive_infinite_f64"; +predicate "\\is_minus_infinity"(float32) = "is_negative_infinite_f32"; +predicate "\\is_minus_infinity"(float64) = "is_negative_infinite_f64"; logic bool "\\round_float"(rounding_mode,real) = "round_float"; logic bool "\\round_double"(rounding_mode,real) = "round_double"; diff --git a/src/plugins/wp/tests/wp/stmtcompiler_test.ml b/src/plugins/wp/tests/wp/stmtcompiler_test.ml index d5752c3f078f98802065bc3ec40bd501d4cf1415..416f4e48137c375177750486711f2ae6ee39506e 100644 --- a/src/plugins/wp/tests/wp/stmtcompiler_test.ml +++ b/src/plugins/wp/tests/wp/stmtcompiler_test.ml @@ -111,7 +111,8 @@ let run () = Model.on_scope (Some kf) (fun () -> let paths,start = Compiler.compute_kf kf in let cfg, goals = paths.Compiler.paths_cfg, paths.Compiler.paths_goals in - let cout = open_out (Format.sprintf "/tmp/cfg_pre_%s.dot" (Kernel_function.get_name kf)) in + let fname = Filename.temp_file "cfg_pre_" (Kernel_function.get_name kf) in + let cout = open_out fname in Compiler.Cfg.output_dot cout ~checks:(Bag.map (fun g -> g.Compiler.goal_pred) goals) cfg; close_out cout; Format.printf "new way@."; diff --git a/src/plugins/wp/tests/wp_acsl/classify_float.c.0.report.json b/src/plugins/wp/tests/wp_acsl/classify_float.c.0.report.json index c76558630aed65afb7c6242902488dd7ffbe763b..3414144c5e1e515b56db8688cc0889b23bb25493 100644 --- a/src/plugins/wp/tests/wp_acsl/classify_float.c.0.report.json +++ b/src/plugins/wp/tests/wp_acsl/classify_float.c.0.report.json @@ -1,26 +1,26 @@ -{ "wp:global": { "alt-ergo": { "total": 3, "valid": 3, "rank": 2 }, - "wp:main": { "total": 3, "valid": 3, "rank": 2 } }, +{ "wp:global": { "alt-ergo": { "total": 3, "valid": 3, "rank": 1 }, + "wp:main": { "total": 3, "valid": 3, "rank": 1 } }, "wp:axiomatics": { "": { "lemma_NaN_not_finite": { "alt-ergo": { "total": 1, "valid": 1, - "rank": 2 }, + "rank": 1 }, "wp:main": { "total": 1, "valid": 1, - "rank": 2 } }, + "rank": 1 } }, "lemma_InfP_not_finite": { "alt-ergo": { "total": 1, "valid": 1, - "rank": 2 }, + "rank": 1 }, "wp:main": { "total": 1, "valid": 1, - "rank": 2 } }, + "rank": 1 } }, "lemma_InfN_not_finite": { "alt-ergo": { "total": 1, "valid": 1, - "rank": 2 }, + "rank": 1 }, "wp:main": { "total": 1, "valid": 1, - "rank": 2 } }, + "rank": 1 } }, "wp:section": { "alt-ergo": { "total": 3, "valid": 3, - "rank": 2 }, + "rank": 1 }, "wp:main": { "total": 3, "valid": 3, - "rank": 2 } } } } } + "rank": 1 } } } } } diff --git a/src/plugins/wp/tests/wp_acsl/oracle/classify_float.res.oracle b/src/plugins/wp/tests/wp_acsl/oracle/classify_float.res.oracle index ff906a4045f1c9ecf8984a16e62378e90f510786..c376b86e98ce5ec321a21c7b88f978e7d29d847d 100644 --- a/src/plugins/wp/tests/wp_acsl/oracle/classify_float.res.oracle +++ b/src/plugins/wp/tests/wp_acsl/oracle/classify_float.res.oracle @@ -8,19 +8,17 @@ Lemma InfN_not_finite: Assume: 'InfP_not_finite' 'NaN_not_finite' -Prove: (is_float64 x_0) - -> ((not (\is_finite x_0)) \/ (not (\is_minus_infinity x_0))) +Prove: (not (\is_finite x_0)) \/ (not (\is_minus_infinity x_0)) ------------------------------------------------------------ Lemma InfP_not_finite: Assume: 'NaN_not_finite' -Prove: (is_float64 x_0) - -> ((not (\is_finite x_0)) \/ (not (\is_plus_infinity x_0))) +Prove: (not (\is_finite x_0)) \/ (not (\is_plus_infinity x_0)) ------------------------------------------------------------ Lemma NaN_not_finite: -Prove: (is_float64 x_0) -> ((not (\is_finite x_0)) \/ (not (\is_NaN x_0))) +Prove: (not (\is_finite x_0)) \/ (not (\is_NaN x_0)) ------------------------------------------------------------ diff --git a/src/plugins/wp/tests/wp_acsl/oracle_qualif/classify_float.0.res.oracle b/src/plugins/wp/tests/wp_acsl/oracle_qualif/classify_float.0.res.oracle index fdedb97beae9bdd2234a9fe64805ddf4ba4a71ec..354a7ea0d71689e221ef9fc4f3deda3e53b09e2c 100644 --- a/src/plugins/wp/tests/wp_acsl/oracle_qualif/classify_float.0.res.oracle +++ b/src/plugins/wp/tests/wp_acsl/oracle_qualif/classify_float.0.res.oracle @@ -12,5 +12,5 @@ [wp] Report 'tests/wp_acsl/classify_float.c.0.report.json' ------------------------------------------------------------- Axiomatics WP Alt-Ergo Total Success -Lemma - 3 (4..16) 3 100% +Lemma - 3 (1..12) 3 100% ------------------------------------------------------------- diff --git a/src/plugins/wp/tests/wp_bts/bts_1174.s b/src/plugins/wp/tests/wp_bts/bts_1174.s index cf366f0bf18e1d2d827a4187f0e84f1536afbbad..c1d443b3b02a23d7bd40478f0e9968e91bae2842 100644 --- a/src/plugins/wp/tests/wp_bts/bts_1174.s +++ b/src/plugins/wp/tests/wp_bts/bts_1174.s @@ -41,7 +41,6 @@ Hint job,property,qed_ok. Proof. intros. Require Import Fourier. - unfold r_1. fourier. Qed. diff --git a/src/plugins/wp/tests/wp_bts/bts_1601.c.0.report.json b/src/plugins/wp/tests/wp_bts/bts_1601.c.0.report.json index b73559c2044c3943fb56c247cb3b34b239ff6cd7..43baa1f072a617efb65c27d8f4b662a8327e8b92 100644 --- a/src/plugins/wp/tests/wp_bts/bts_1601.c.0.report.json +++ b/src/plugins/wp/tests/wp_bts/bts_1601.c.0.report.json @@ -1,5 +1,6 @@ -{ "wp:global": { "qed": { "total": 8, "valid": 8 }, - "wp:main": { "total": 8, "valid": 8 } }, +{ "wp:global": { "alt-ergo": { "total": 1, "valid": 1, "rank": 4 }, + "qed": { "total": 7, "valid": 7 }, + "wp:main": { "total": 8, "valid": 8, "rank": 4 } }, "wp:functions": { "foo": { "foo_assert_7": { "qed": { "total": 1, "valid": 1 }, "wp:main": { "total": 1, @@ -24,15 +25,21 @@ "valid": 1 }, "wp:main": { "total": 1, "valid": 1 } }, - "foo_assert": { "qed": { "total": 1, - "valid": 1 }, + "foo_assert": { "alt-ergo": { "total": 1, + "valid": 1, + "rank": 4 }, "wp:main": { "total": 1, - "valid": 1 } }, + "valid": 1, + "rank": 4 } }, "foo_basic_post": { "qed": { "total": 1, "valid": 1 }, "wp:main": { "total": 1, "valid": 1 } }, - "wp:section": { "qed": { "total": 8, - "valid": 8 }, + "wp:section": { "alt-ergo": { "total": 1, + "valid": 1, + "rank": 4 }, + "qed": { "total": 7, + "valid": 7 }, "wp:main": { "total": 8, - "valid": 8 } } } } } + "valid": 8, + "rank": 4 } } } } } diff --git a/src/plugins/wp/tests/wp_bts/oracle/bts_1174.res.oracle b/src/plugins/wp/tests/wp_bts/oracle/bts_1174.res.oracle index d98a6cfde684e9c5a8b8e86fce83dde1af255301..0f15882a71638c4b6817b680fb0d30129b4f6887 100644 --- a/src/plugins/wp/tests/wp_bts/oracle/bts_1174.res.oracle +++ b/src/plugins/wp/tests/wp_bts/oracle/bts_1174.res.oracle @@ -8,16 +8,16 @@ ------------------------------------------------------------ Goal Assertion 'qed_ok' (file tests/wp_bts/bts_1174.i, line 11): -Let r = mul_float64(x, 2.0). +Let r = of_f64(x). Assume { - Type: is_sint32(a) /\ is_float64(x) /\ is_float64(r). + Type: is_sint32(a). (* Goal *) - When: .0 <= x. + When: .0 <= r. (* Pre-condition *) - Have: (x <= 10.0) /\ (-10.0 <= x). + Have: (r <= 10.0) /\ (-10.0 <= r). (* Then *) Have: a != 0. } -Prove: .0 <= r. +Prove: .0 <= of_f64(mul_f64(x, to_f64(2.0))). ------------------------------------------------------------ diff --git a/src/plugins/wp/tests/wp_bts/oracle/bts_1601.res.oracle b/src/plugins/wp/tests/wp_bts/oracle/bts_1601.res.oracle index 1dcb038b3f130200fa0166f389d513578b8eddb8..897003473316c3a94c56e22d00d8626c152a9aa4 100644 --- a/src/plugins/wp/tests/wp_bts/oracle/bts_1601.res.oracle +++ b/src/plugins/wp/tests/wp_bts/oracle/bts_1601.res.oracle @@ -8,7 +8,14 @@ ------------------------------------------------------------ Goal Assertion (file tests/wp_bts/bts_1601.c, line 72): -Prove: true. +Assume { + Type: is_uint32(tenumRMode_0). + (* Residual *) + When: ne_f32(fRrValue_0, to_f32(.0)). + (* Goal *) + When: of_f32(fRrValue_0) = .0. +} +Prove: tenumRMode_0 = 1. ------------------------------------------------------------ diff --git a/src/plugins/wp/tests/wp_bts/oracle_qualif/bts_1601.res.oracle b/src/plugins/wp/tests/wp_bts/oracle_qualif/bts_1601.res.oracle index c6a35a894ed9d82d51c935f8d2b90d803b6f62cb..cbeaaa512abdc92f2b4dd7e7eeaf7142b02da934 100644 --- a/src/plugins/wp/tests/wp_bts/oracle_qualif/bts_1601.res.oracle +++ b/src/plugins/wp/tests/wp_bts/oracle_qualif/bts_1601.res.oracle @@ -4,7 +4,7 @@ [wp] Loading driver 'share/wp.driver' [wp] Warning: Missing RTE guards [wp] 8 goals scheduled -[wp] [Qed] Goal typed_foo_assert : Valid +[wp] [Alt-Ergo] Goal typed_foo_assert : Valid [wp] [Qed] Goal typed_foo_assert_2 : Valid [wp] [Qed] Goal typed_foo_assert_3 : Valid [wp] [Qed] Goal typed_foo_assert_4 : Valid @@ -13,9 +13,10 @@ [wp] [Qed] Goal typed_foo_assert_7 : Valid [wp] [Qed] Goal typed_foo_basic_post : Valid [wp] Proved goals: 8 / 8 - Qed: 8 + Qed: 7 + Alt-Ergo: 1 [wp] Report 'tests/wp_bts/bts_1601.c.0.report.json' ------------------------------------------------------------- Functions WP Alt-Ergo Total Success -foo 8 - 8 100% +foo 7 1 (12..24) 8 100% ------------------------------------------------------------- diff --git a/src/plugins/wp/tests/wp_plugin/combined.c b/src/plugins/wp/tests/wp_plugin/combined.c index e698ae498d812c5788580c80ab143b62567331da..33a5d1e193a283f4649865cca1511645456121ac 100644 --- a/src/plugins/wp/tests/wp_plugin/combined.c +++ b/src/plugins/wp/tests/wp_plugin/combined.c @@ -3,7 +3,8 @@ */ /* run.config_qualif - OPT: -wp-par 1 -load-script tests/wp_plugin/combined.ml + EXECNOW: @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -wp-par 1 -load-module @PTEST_DIR@/@PTEST_NAME@ */ /* ZD : this should not be here such as it cannot be tested by all frama-c diff --git a/src/plugins/wp/tests/wp_plugin/combined.ml b/src/plugins/wp/tests/wp_plugin/combined.ml deleted file mode 100644 index 6b9da9a310774ff2577df057db2234f367d9d1b2..0000000000000000000000000000000000000000 --- a/src/plugins/wp/tests/wp_plugin/combined.ml +++ /dev/null @@ -1,22 +0,0 @@ -let main () = - Ast.compute (); - let module OLS = Datatype.List(Datatype.String) in - let module OKF = Datatype.Option(Kernel_function) in - let module OP = Datatype.Option(Property) in - Dynamic.get - ~plugin:"Wp" "wp_compute" - (Datatype.func3 OKF.ty OLS.ty OP.ty Datatype.unit) - (Some - (try Globals.Functions.find_by_name "job" - with Not_found -> assert false)) - [] - None; - let report = - Dynamic.get - ~plugin:"Report" "print" (Datatype.func Datatype.unit Datatype.unit) - in - report (); - !Db.Value.compute (); - report () - -let () = Db.Main.extend main diff --git a/src/plugins/wp/tests/wp_plugin/oracle/combined.res.oracle b/src/plugins/wp/tests/wp_plugin/oracle/combined.res.oracle index 299e5c4b1a5a9d3ef52579e0104f2e788c80b53b..c8a980291364c79ed27ab5f1a70676174e4b91f0 100644 --- a/src/plugins/wp/tests/wp_plugin/oracle/combined.res.oracle +++ b/src/plugins/wp/tests/wp_plugin/oracle/combined.res.oracle @@ -7,7 +7,7 @@ Function job ------------------------------------------------------------ -Goal Assertion (file tests/wp_plugin/combined.c, line 26): +Goal Assertion (file tests/wp_plugin/combined.c, line 27): Assume { Type: is_sint32(A). (* Heap *) @@ -17,7 +17,7 @@ Prove: (50 <= A) /\ (A <= 100). ------------------------------------------------------------ -Goal Preservation of Invariant (file tests/wp_plugin/combined.c, line 28): +Goal Preservation of Invariant (file tests/wp_plugin/combined.c, line 29): Assume { Type: is_sint32(A) /\ is_sint32(i) /\ is_sint32(v) /\ is_sint32(1 + i). (* Heap *) @@ -39,12 +39,12 @@ Prove: (-1) <= i. ------------------------------------------------------------ -Goal Establishment of Invariant (file tests/wp_plugin/combined.c, line 28): +Goal Establishment of Invariant (file tests/wp_plugin/combined.c, line 29): Prove: true. ------------------------------------------------------------ -Goal Preservation of Invariant (file tests/wp_plugin/combined.c, line 29): +Goal Preservation of Invariant (file tests/wp_plugin/combined.c, line 30): Let a = havoc(Mint_undef_0, Mint_0, shift_sint32(t, 0), 50). Assume { Type: is_sint32(A) /\ is_sint32(i) /\ is_sint32(v) /\ is_sint32(1 + i). @@ -68,12 +68,12 @@ Prove: P_P(a[shift_sint32(t, i) <- v][shift_sint32(t, i_1)]). ------------------------------------------------------------ -Goal Establishment of Invariant (file tests/wp_plugin/combined.c, line 29): +Goal Establishment of Invariant (file tests/wp_plugin/combined.c, line 30): Prove: true. ------------------------------------------------------------ -Goal Preservation of Invariant (file tests/wp_plugin/combined.c, line 34): +Goal Preservation of Invariant (file tests/wp_plugin/combined.c, line 35): Let x = 1 + j. Assume { Type: is_sint32(A) /\ is_sint32(i) /\ is_sint32(j) /\ is_sint32(x). @@ -98,12 +98,12 @@ Prove: A <= x. ------------------------------------------------------------ -Goal Establishment of Invariant (file tests/wp_plugin/combined.c, line 34): +Goal Establishment of Invariant (file tests/wp_plugin/combined.c, line 35): Prove: true. ------------------------------------------------------------ -Goal Assertion (file tests/wp_plugin/combined.c, line 39): +Goal Assertion (file tests/wp_plugin/combined.c, line 40): Let a = havoc(Mint_undef_1, Mint_0, shift_sint32(t, 0), 50). Assume { Type: is_sint32(A) /\ is_sint32(i_1) /\ is_sint32(j). @@ -130,36 +130,36 @@ Prove: P_P(havoc(Mint_undef_0, a, shift_sint32(t, A), 100 - A) ------------------------------------------------------------ -Goal Loop assigns (file tests/wp_plugin/combined.c, line 30) (1/3): +Goal Loop assigns (file tests/wp_plugin/combined.c, line 31) (1/3): Prove: true. ------------------------------------------------------------ -Goal Loop assigns (file tests/wp_plugin/combined.c, line 30) (2/3): -Effect at line 32 +Goal Loop assigns (file tests/wp_plugin/combined.c, line 31) (2/3): +Effect at line 33 Prove: true. ------------------------------------------------------------ -Goal Loop assigns (file tests/wp_plugin/combined.c, line 30) (3/3): -Call Result at line 32 +Goal Loop assigns (file tests/wp_plugin/combined.c, line 31) (3/3): +Call Result at line 33 Prove: true. ------------------------------------------------------------ -Goal Loop assigns (file tests/wp_plugin/combined.c, line 35) (1/3): +Goal Loop assigns (file tests/wp_plugin/combined.c, line 36) (1/3): Prove: true. ------------------------------------------------------------ -Goal Loop assigns (file tests/wp_plugin/combined.c, line 35) (2/3): -Effect at line 37 +Goal Loop assigns (file tests/wp_plugin/combined.c, line 36) (2/3): +Effect at line 38 Prove: true. ------------------------------------------------------------ -Goal Loop assigns (file tests/wp_plugin/combined.c, line 35) (3/3): -Call Result at line 37 +Goal Loop assigns (file tests/wp_plugin/combined.c, line 36) (3/3): +Call Result at line 38 Let a = shift_sint32(t, j). Assume { Type: is_sint32(A) /\ is_sint32(i) /\ is_sint32(j). diff --git a/src/plugins/wp/tests/wp_plugin/oracle/float_format.res.oracle b/src/plugins/wp/tests/wp_plugin/oracle/float_format.res.oracle index a1eef7741a054dfba2b25b6e86bd265a8f2ec84c..85e995df2796c0b54545c3d7c1c66198eb899050 100644 --- a/src/plugins/wp/tests/wp_plugin/oracle/float_format.res.oracle +++ b/src/plugins/wp/tests/wp_plugin/oracle/float_format.res.oracle @@ -11,9 +11,9 @@ ------------------------------------------------------------ Goal Post-condition 'KO' in 'output': -Let r = to_float32(add_float64((3602879701896397.0/18014398509481984), - to_float64(x))). -Assume { Type: is_float32(x) /\ is_float32(r). } -Prove: ((1.0/5) + x) = r. +Let r = of_f32(x). +Prove: ((1.0/5) + r) + = of_f32(to_f32(of_f64(add_f64(to_f64((3602879701896397.0/18014398509481984)), + to_f64(r))))). ------------------------------------------------------------ diff --git a/src/plugins/wp/tests/wp_plugin/oracle_qualif/float_format.1.res.oracle b/src/plugins/wp/tests/wp_plugin/oracle_qualif/float_format.1.res.oracle index 0913a0843c70dc2989da1b7f138c2df30c3645b0..51150b389c4802c954416c1f7b1e6e8a25c3a578 100644 --- a/src/plugins/wp/tests/wp_plugin/oracle_qualif/float_format.1.res.oracle +++ b/src/plugins/wp/tests/wp_plugin/oracle_qualif/float_format.1.res.oracle @@ -7,9 +7,9 @@ [wp] Loading driver 'share/wp.driver' [wp] Warning: Missing RTE guards [wp] 1 goal scheduled -[wp] [Alt-Ergo] Goal typed_output_post_KO : Unknown +[wp] [Alt-Ergo] Goal typed_output_post_KO : Step limit [wp] Proved goals: 0 / 1 - Alt-Ergo: 0 (unknown: 1) + Alt-Ergo: 0 (interrupted: 1) [wp] Report 'tests/wp_plugin/float_format.i.1.report.json' ------------------------------------------------------------- Functions WP Alt-Ergo Total Success diff --git a/src/plugins/wp/tests/wp_plugin/string_c.c.0.report.json b/src/plugins/wp/tests/wp_plugin/string_c.c.0.report.json index 89a03ae6f3db1f3d7f13fdd15da4799ae615ee0d..a4d745460b88f693b10e7b28968614fc8fe5225a 100644 --- a/src/plugins/wp/tests/wp_plugin/string_c.c.0.report.json +++ b/src/plugins/wp/tests/wp_plugin/string_c.c.0.report.json @@ -34,12 +34,12 @@ "valid": 1 } }, "memcpy_loop_assign": { "alt-ergo": { "total": 1, "valid": 1, - "rank": 43 }, + "rank": 40 }, "qed": { "total": 2, "valid": 2 }, "wp:main": { "total": 3, "valid": 3, - "rank": 43 } }, + "rank": 40 } }, "memcpy_post_result_ptr": { "qed": { "total": 1, "valid": 1 }, "wp:main": diff --git a/tests/builtins/Longinit_sequencer.i b/tests/builtins/Longinit_sequencer.i index 2998da18c7d5bfa4f9e0d48f067fde4c44a6b860..4d9b50cd565baedf36d4ebb071a2915ff4527216 100644 --- a/tests/builtins/Longinit_sequencer.i +++ b/tests/builtins/Longinit_sequencer.i @@ -1,4 +1,4 @@ /* run.config* -EXECNOW: make tests/builtins/Longinit_sequencer.cmxs -OPT: -load-module tests/builtins/Longinit_sequencer.cmxs -eva-show-progress -res-file @PTEST_RESULT@ +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -eva-show-progress -res-file @PTEST_RESULT@ */ diff --git a/tests/builtins/big_local_array.i b/tests/builtins/big_local_array.i index ccf98764fd086b47e1a139aa5743a4fee0a9b313..d6e1f53181467a2ec7876261086d4a39869f7d19 100644 --- a/tests/builtins/big_local_array.i +++ b/tests/builtins/big_local_array.i @@ -1,6 +1,7 @@ /* run.config* +EXECNOW: make -s @PTEST_DIR@/big_local_array_script.cmxs OPT: -eva-show-progress -print -journal-disable -eva -report -OPT: -load-script tests/builtins/big_local_array_script.ml -then-on prj -print -report +OPT: -load-module @PTEST_DIR@/big_local_array_script -then-on prj -print -report OPT: -eva-show-progress -print -journal-disable -no-initialized-padding-locals -eva */ diff --git a/tests/callgraph/function_pointer.i b/tests/callgraph/function_pointer.i index be249adbd33ce25d7fd82f7a52247bcc42cf0f7f..b28287119069e61b95d7115a89eeb8592e7e8412 100644 --- a/tests/callgraph/function_pointer.i +++ b/tests/callgraph/function_pointer.i @@ -1,10 +1,10 @@ /* run.config COMMENT: Test option -cg-function-pointers EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs - OPT: -cg-function-pointers -load-module @PTEST_DIR@/@PTEST_NAME@ - OPT: -cg-no-services -cg-function-pointers -load-module @PTEST_DIR@/@PTEST_NAME@ - OPT: -cg-no-function-pointers -load-module @PTEST_DIR@/@PTEST_NAME@ - OPT: -cg-no-services -cg-no-function-pointers -load-module @PTEST_DIR@/@PTEST_NAME@ + OPT: -cg-function-pointers -no-autoload-plugins -load-module eva,@PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -cg-no-services -cg-function-pointers -no-autoload-plugins -load-module eva,@PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -cg-no-function-pointers -no-autoload-plugins -load-module eva,@PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -cg-no-services -cg-no-function-pointers -no-autoload-plugins -load-module eva,@PTEST_DIR@/@PTEST_NAME@.cmxs */ int (*fptr)(int); diff --git a/tests/cil/mkBinOp.i b/tests/cil/mkBinOp.i index caa9dd0c396370d25700c25ca86ae605882e0348..1bab30cf83cef46281180438db232f21b9d1224b 100644 --- a/tests/cil/mkBinOp.i +++ b/tests/cil/mkBinOp.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@ -print -constfold +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print -constfold */ int main(void) { diff --git a/tests/constant_propagation/introduction_of_non_explicit_cast.c b/tests/constant_propagation/introduction_of_non_explicit_cast.c index 2d99b7676d0c061844695bf90822e6ed0fe5a68c..9e95b6e88db2c472e56cd47ad852b696c28e2a8b 100644 --- a/tests/constant_propagation/introduction_of_non_explicit_cast.c +++ b/tests/constant_propagation/introduction_of_non_explicit_cast.c @@ -1,8 +1,8 @@ /* run.config - OPT: -load-script tests/constant_propagation/introduction_of_non_explicit_cast.ml -eva -eva-show-progress -deps -journal-disable + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -eva -eva-show-progress -deps -journal-disable */ - int x,y,z; int TAB[10]; struct st { int a, b ; } s1, s2; diff --git a/tests/crowbar/integer_bb_pretty.ml b/tests/crowbar/integer_bb_pretty.ml new file mode 100644 index 0000000000000000000000000000000000000000..2c6ec812e2968f282f1efb3e3cb19a7c45c9ef0a --- /dev/null +++ b/tests/crowbar/integer_bb_pretty.ml @@ -0,0 +1,59 @@ +open Crowbar + +let reparse v s = + let failure info = + Crowbar.fail + ("Pretty-printing '" ^ (Z.to_string v) ^ "' returns '" ^ s ^ "'" ^ info) + in + if String.length s <= 2 then failure ""; + let is_neg = s.[0] = '1' in + let is_hex = s.[1] = 'x' in + let s = String.(concat "" (split_on_char '_' s)) in + let v' = + if is_neg then begin + let chr = if is_hex then 'F' else '1' in + let module M = struct exception Found of int end in + let check i c = if i > 1 && c <> chr then raise (M.Found i) in + try String.iteri check s; Z.minus_one + with M.Found idx -> + let len, v' = + if is_hex then begin + let remains = String.sub s idx (String.length s - idx) in + let v' = Z.of_string ("0x" ^ remains) in + 4 * (String.length remains), v' + end else begin + let remains = String.sub s idx (String.length s - idx) in + let v' = Z.of_string ("0b" ^ remains) in + String.length remains, v' + end + in + let m = Z.(one lsl len) in + let m = Z.pred m in + let v' = Z.logxor m v' in + Z.pred (Z.lognot (Z.pred v')) + end else + Z.of_string s + in + if not (Z.equal v v') then + failure (" reparsed as '" ^ Z.format "%b" v' ^ "' (" ^ Z.to_string v' ^ ")") + +let test z is_hex nbits has_sep = + guard (nbits >= 0 && nbits <= 1024); + let sep = if has_sep then Some "_" else None in + let pp z = if is_hex then + Integer.pp_hex ~nbits ?sep z + else + Integer.pp_bin ~nbits ?sep z + in + let s = Format.asprintf "%a" pp z in + reparse z s + +let zarith = + let open Crowbar in + fix (fun zarith -> + choose + [ map [int64] Z.of_int64; + map [zarith; int64] (fun z i -> Z.((z lsl 64) + of_int64 i)) ]) + +let () = Crowbar.add_test ~name:"pp_bin_hex" + [ zarith; Crowbar.bool; Crowbar.int; Crowbar.bool ] test diff --git a/tests/float/fval_test.i b/tests/float/fval_test.i index eda0e94bd4445ca7c827ff7600569fe3d5518e1d..cabb28768924493f9964d6329934d0356b2e5143 100644 --- a/tests/float/fval_test.i +++ b/tests/float/fval_test.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/float/fval_test.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@ */ /* run.config* DONTRUN: diff --git a/tests/jcdb/jcdb.c b/tests/jcdb/jcdb.c index e065ddbec3380d2ffa6ebb902d1b3838a631422c..ddf00afcd0acb406597062b30cab1a821f769faf 100644 --- a/tests/jcdb/jcdb.c +++ b/tests/jcdb/jcdb.c @@ -2,7 +2,7 @@ EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -json-compilation-database @PTEST_DIR@ -print OPT: -json-compilation-database @PTEST_DIR@/with_arguments.json -print -OPT: -json-compilation-database @PTEST_DIR@/with_arguments.json -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -json-compilation-database @PTEST_DIR@/with_arguments.json -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs EXECNOW: LOG list_files.res LOG list_files.err share/analysis-scripts/list_files.py @PTEST_DIR@/compile_commands_working.json > @PTEST_DIR@/result/list_files.res 2> @PTEST_DIR@/result/list_files.err */ #include <stdio.h> diff --git a/tests/journal/control.i b/tests/journal/control.i index 03c9193098e1b927237577588f973faaeb7a6e45..8a7acc8e682ff542811632ac5f9436e3a9a0f4f9 100644 --- a/tests/journal/control.i +++ b/tests/journal/control.i @@ -5,10 +5,10 @@ OPT: -load-script tests/journal/result/control_journal -journal-disable CMD: FRAMAC_LIB=lib/fc ./bin/toplevel.byte OPT: -load-script tests/journal/result/control_journal_bis -calldeps -journal-disable - EXECNOW: BIN abstract_cpt_journal.ml FRAMAC_LIB=lib/fc ./bin/toplevel.byte -journal-enable -load-script tests/journal/abstract_cpt.ml -load-script tests/journal/use_cpt.ml -journal-name tests/journal/result/abstract_cpt_journal.ml > /dev/null 2> /dev/null + EXECNOW: make -s @PTEST_DIR@/abstract_cpt.cmxs + EXECNOW: BIN abstract_cpt_journal.ml FRAMAC_LIB=lib/fc ./bin/toplevel.byte -journal-enable -load-module @PTEST_DIR@/abstract_cpt -load-script tests/journal/use_cpt.ml -journal-name tests/journal/result/abstract_cpt_journal.ml > /dev/null 2> /dev/null CMD: FRAMAC_LIB=lib/fc ./bin/toplevel.byte - OPT: -load-script tests/journal/result/abstract_cpt_journal.ml -load-script tests/journal/abstract_cpt.ml -load-script tests/journal/use_cpt.ml - + OPT: -load-script tests/journal/result/abstract_cpt_journal.ml -load-module @PTEST_DIR@/abstract_cpt -load-script tests/journal/use_cpt.ml */ int x,y,c,d; diff --git a/tests/journal/intra.i b/tests/journal/intra.i index e5d5ab003425ddf34ceee667dbe4ede23b9338cd..dea5fdbface5e49569a2d52996e69ac8b4d52f06 100644 --- a/tests/journal/intra.i +++ b/tests/journal/intra.i @@ -1,7 +1,7 @@ /* run.config - EXECNOW: make -s tests/journal/intra.cmxs - EXECNOW: BIN intra_journal.ml @frama-c@ -eva-show-progress -load-module ./tests/journal/intra -journal-enable -journal-name tests/journal/result/intra_journal.ml tests/journal/intra.i > /dev/null 2> /dev/null - CMD: @frama-c@ -load-module ./tests/journal/intra + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + EXECNOW: BIN intra_journal.ml @frama-c@ -eva-show-progress -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -journal-enable -journal-name tests/journal/result/intra_journal.ml @PTEST_DIR@/@PTEST_NAME@.i > /dev/null 2> /dev/null + CMD: @frama-c@ -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -load-script tests/journal/result/intra_journal -journal-disable */ diff --git a/tests/libc/fc_libc.c b/tests/libc/fc_libc.c index 5b85156aea37ea5d264a52c07910e37b9eb1d4cd..298bc1b03740873f4764513b51d10747b6869bd3 100644 --- a/tests/libc/fc_libc.c +++ b/tests/libc/fc_libc.c @@ -1,7 +1,10 @@ /* run.config* - OPT: -load-script tests/libc/check_libc_naming_conventions.ml -print -cpp-extra-args='-nostdinc -Ishare/libc' -metrics -metrics-libc -load-script tests/libc/check_const.ml -load-module metrics -eva @VALUECONFIG@ -then -lib-entry -no-print -metrics-no-libc + EXECNOW: make -s @PTEST_DIR@/check_libc_naming_conventions.cmxs + EXECNOW: make -s @PTEST_DIR@/check_const.cmxs + EXECNOW: make -s @PTEST_DIR@/check_parsing_individual_headers.cmxs + OPT: -load-module @PTEST_DIR@/check_libc_naming_conventions -print -cpp-extra-args='-nostdinc -Ishare/libc' -metrics -metrics-libc -load-module @PTEST_DIR@/check_const -load-module metrics -eva @VALUECONFIG@ -then -lib-entry -no-print -metrics-no-libc OPT: -print -print-libc - OPT: -load-script tests/libc/check_parsing_individual_headers.ml + OPT: -load-module @PTEST_DIR@/check_parsing_individual_headers CMD: ./tests/libc/check_full_libc.sh OPT: **/ diff --git a/tests/libc/oracle/fc_libc.0.res.oracle b/tests/libc/oracle/fc_libc.0.res.oracle index ffa163ed517ced7ae131d1bd9f87f61300909256..c1ea9b1264b8f540555594d7684ce6cc084d13d7 100644 --- a/tests/libc/oracle/fc_libc.0.res.oracle +++ b/tests/libc/oracle/fc_libc.0.res.oracle @@ -4,10 +4,10 @@ [eva] Initial state computed [eva:initial-state] Values of globals at initialization -[eva] tests/libc/fc_libc.c:157: assertion got status valid. -[eva] tests/libc/fc_libc.c:158: assertion got status valid. -[eva] tests/libc/fc_libc.c:159: assertion got status valid. [eva] tests/libc/fc_libc.c:160: assertion got status valid. +[eva] tests/libc/fc_libc.c:161: assertion got status valid. +[eva] tests/libc/fc_libc.c:162: assertion got status valid. +[eva] tests/libc/fc_libc.c:163: assertion got status valid. [eva] Recording results for main [eva] done for function main [eva] ====== VALUES COMPUTED ====== diff --git a/tests/misc/add_assigns.i b/tests/misc/add_assigns.i index 5b2b95af84a9f8b267b95b237093296b438f8229..a6a820ecce977ef9f528f95bcb149fe3df18001a 100644 --- a/tests/misc/add_assigns.i +++ b/tests/misc/add_assigns.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -then -report -then -print +OPT: -no-autoload-plugins -load-module report,@PTEST_DIR@/@PTEST_NAME@.cmxs -then -report -then -print */ /*@ assigns *x; */ diff --git a/tests/misc/behavior_names.i b/tests/misc/behavior_names.i index 969831729e947a8c410642c19d50fbd01730a3f1..d4e48cb5bf64a0462aa4b9196b3d1dd23f533b9a 100644 --- a/tests/misc/behavior_names.i +++ b/tests/misc/behavior_names.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/misc/behavior_names.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ /*@ behavior foo: ensures \true; */ diff --git a/tests/misc/bts0452.i b/tests/misc/bts0452.i index 98005844997d596e37329504f7abdabeaf175f76..1f3fc795582b79b21aad809bf852bfb655ce3cd7 100644 --- a/tests/misc/bts0452.i +++ b/tests/misc/bts0452.i @@ -1,7 +1,7 @@ /* run.config - OPT: -typecheck -load-script tests/misc/bts0452.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -typecheck -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ - /* must emit falls-through warning. */ int f (int foo, char** args) { switch(foo) { diff --git a/tests/misc/bts0489.i b/tests/misc/bts0489.i index db94a185c42a8f4948e11331ceed034f854b9a1f..c33db7d4c1a3f7b4d29d0fc48a0aeaf37101775b 100644 --- a/tests/misc/bts0489.i +++ b/tests/misc/bts0489.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/misc/bts0489.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ typedef unsigned char uint8_t; diff --git a/tests/misc/bts1201.i b/tests/misc/bts1201.i index 7e59976a1ab11f91a4cde0c78ed7630c66fa5c14..cbaf4a4e3d114ba17709f3f7fc7bfe0c6f8f5d27 100644 --- a/tests/misc/bts1201.i +++ b/tests/misc/bts1201.i @@ -1,8 +1,8 @@ /* run.config - OPT: -eva-verbose 2 -load-script tests/misc/bts1201.ml -print + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -eva-verbose 2 -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print */ -void main() { - //@ assert \true; +void main() { //@ assert \true; } void main2() { diff --git a/tests/misc/bts1347.i b/tests/misc/bts1347.i index 4351b7a05c365f721926ec2916c2d8b9ba6c7e54..54f633c7beacbf0a298590ec7bd5efb20003b577 100644 --- a/tests/misc/bts1347.i +++ b/tests/misc/bts1347.i @@ -1,6 +1,6 @@ /* run.config - OPT: -load-script tests/misc/bts1347.ml -eva-show-progress -then -report + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -eva-show-progress -then -report */ - int f(int *x) { return *x; } int g(int *x) { return *(x++); } diff --git a/tests/misc/bug_0209.c b/tests/misc/bug_0209.c index e1c584267f93d9cbebcfba033d9ae35f99eec16f..a345a39f3b0ce1c51d4d918965de6620914abbde 100644 --- a/tests/misc/bug_0209.c +++ b/tests/misc/bug_0209.c @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/misc/bug_0209.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ // Everything is done by the script diff --git a/tests/misc/callsite.i b/tests/misc/callsite.i index cb222eb5e95aa3ea93f1f110a8eb5e8b88bca06e..7dcfc493a8c89c38f1bb6189b0c562cccb8841e9 100644 --- a/tests/misc/callsite.i +++ b/tests/misc/callsite.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/misc/callsite.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ // Don't use -debug 1 option in the test command. diff --git a/tests/misc/change_main.i b/tests/misc/change_main.i index 9239d7f51bb663bc2a4d62f841a4887970a04919..c6f70943352c91f4348680131c67bb9e27329040 100644 --- a/tests/misc/change_main.i +++ b/tests/misc/change_main.i @@ -1,5 +1,6 @@ /* run.config* -OPT: -eva -main f -load-script tests/misc/change_main.ml -then-on change_main -main g -eva +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -eva -main f -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -then-on change_main -main g -eva */ int f(int x) { return x; } diff --git a/tests/misc/cli_string_multiple_map.i b/tests/misc/cli_string_multiple_map.i index 35a34f02c7751c7f8f58cc91af0f557d408f1c04..b4a7c3bc23730ae8b09c9d851046c6b3e300b520 100644 --- a/tests/misc/cli_string_multiple_map.i +++ b/tests/misc/cli_string_multiple_map.i @@ -1,3 +1,4 @@ /* run.config - OPT: -load-script tests/misc/cli_string_multiple_map.ml -multiple-map a:1,b:2,a:3 + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -multiple-map a:1,b:2,a:3 */ diff --git a/tests/misc/copy_kf.i b/tests/misc/copy_kf.i index 029cbd00d67d6d1580476a8703c235814ecc057c..15fe7d6bc47b3ae91e25275f2bc159cebaeca86d 100644 --- a/tests/misc/copy_kf.i +++ b/tests/misc/copy_kf.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@ +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ /*@ requires \valid(p); assigns *p; ensures *p == x; */ diff --git a/tests/misc/copy_machdep.i b/tests/misc/copy_machdep.i index 3c150a094ff67a252ea8c3875e854a75b839b327..0b6f32f439f5a76fcda2d18135977d049f386d84 100644 --- a/tests/misc/copy_machdep.i +++ b/tests/misc/copy_machdep.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@ -machdep x86_64 -enums int -no-unicode +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -machdep x86_64 -enums int -no-unicode */ int main () { return 0; } diff --git a/tests/misc/custom_machdep.c b/tests/misc/custom_machdep.c index e92b67f2a8e902f76929347cdee85a7b35688149..f7a377dc16250f21911dbc5f014d7a50b33bac3f 100644 --- a/tests/misc/custom_machdep.c +++ b/tests/misc/custom_machdep.c @@ -1,5 +1,6 @@ /* run.config* -OPT: -cpp-extra-args="-I@PTEST_DIR@/@PTEST_NAME@ -D__FC_MACHDEP_CUSTOM" -load-script @PTEST_DIR@/@PTEST_NAME@/@PTEST_NAME@.ml -machdep custom -print -then -print +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@/@PTEST_NAME@.cmxs +OPT: -cpp-extra-args="-I@PTEST_DIR@/@PTEST_NAME@ -D__FC_MACHDEP_CUSTOM" -load-module @PTEST_DIR@/@PTEST_NAME@/@PTEST_NAME@ -machdep custom -print -then -print COMMENT: we need a -then to test double registering of a machdep */ diff --git a/tests/misc/ensures.i b/tests/misc/ensures.i index 140bf8122f031aa574e460218275fceb1fb3112b..ae04e6fb897e157311e2131e8c00117972aaa048 100644 --- a/tests/misc/ensures.i +++ b/tests/misc/ensures.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/misc/ensures.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ //@ ensures *p==1; void main(int * p){ *p = 0; } diff --git a/tests/misc/exception.i b/tests/misc/exception.i index 4b73ec776649d824fae164bf23655cd6ab7c26c1..a6e5006eb7dbab9286b39fbeaf6ea28e5c22be19 100644 --- a/tests/misc/exception.i +++ b/tests/misc/exception.i @@ -1,7 +1,7 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs - OPT: -load-module @PTEST_DIR@/@PTEST_NAME@ -print - OPT: -load-module @PTEST_DIR@/@PTEST_NAME@ -remove-exn -print + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -remove-exn -print */ struct my_exn { int e; }; diff --git a/tests/misc/filepath.i b/tests/misc/filepath.i index eb178f8224607c8dce90532cc9b037ff562b16f4..f5c0183704fb0f14aba28d804eb133137365c870 100644 --- a/tests/misc/filepath.i +++ b/tests/misc/filepath.i @@ -1,3 +1,4 @@ /* run.config - OPT: -no-autoload-plugins -load-module @PTEST_DIR@/filepath_test.ml + EXECNOW: make -s @PTEST_DIR@/filepath_test.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/filepath_test */ diff --git a/tests/misc/find_enclosing_loop.c b/tests/misc/find_enclosing_loop.c index 0a46b537168e8095a426f03541433800664ae563..76cc35a53187fc9e58ea906527669b5a9482e117 100644 --- a/tests/misc/find_enclosing_loop.c +++ b/tests/misc/find_enclosing_loop.c @@ -1,5 +1,6 @@ /* run.config -OPT: -load-script tests/misc/find_enclosing_loop.ml +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ void f () { diff --git a/tests/misc/global_decl_loc.i b/tests/misc/global_decl_loc.i index 3da30326dde49e4dacd4027a5ac9515fe448b0b5..d13cbce847364dbce968f270f47d9cae11260cd8 100644 --- a/tests/misc/global_decl_loc.i +++ b/tests/misc/global_decl_loc.i @@ -1,4 +1,4 @@ /* run.config - OPT: @PTEST_DIR@/global_decl_loc2.i -load-module @PTEST_DIR@/global_decl_loc.cmxs + OPT: @PTEST_DIR@/global_decl_loc2.i -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ int g; diff --git a/tests/misc/init_from_cil.i b/tests/misc/init_from_cil.i index 276161982d21dae400626a206eca75b7064b3b44..7d767032b7e6c7ef1acc8f6a4a7e1ff655cab5f7 100644 --- a/tests/misc/init_from_cil.i +++ b/tests/misc/init_from_cil.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/misc/init_from_cil.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ int f(int x); diff --git a/tests/misc/issue109.i b/tests/misc/issue109.i index 5d51ec4b48a0d12becb70887d913d3b9527781cd..51c709c227b1c61c905901b787e50e87c0825216 100644 --- a/tests/misc/issue109.i +++ b/tests/misc/issue109.i @@ -1,7 +1,7 @@ /* run.config - OPT: -eva -eva-show-progress -slevel-function main:10 -load-script tests/misc/issue109.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -eva -eva-show-progress -slevel-function main:10 -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ - void main() { int i, j = 0; for (i=0; i<10; i++) { diff --git a/tests/misc/issue_191.c b/tests/misc/issue_191.c index bbba9a680d785fa60685908e9b32322d466639ec..a345a39f3b0ce1c51d4d918965de6620914abbde 100644 --- a/tests/misc/issue_191.c +++ b/tests/misc/issue_191.c @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/misc/issue_191.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ // Everything is done by the script diff --git a/tests/misc/justcopy.i b/tests/misc/justcopy.i index 1045df89354df37d9bb6936a454ceedadd769c85..8cfd1982b8925ce6626f5d9b9d91594011759c5a 100644 --- a/tests/misc/justcopy.i +++ b/tests/misc/justcopy.i @@ -1,3 +1,4 @@ /* run.config - OPT: -load-script tests/misc/justcopy.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ diff --git a/tests/misc/keep_entry_point.i b/tests/misc/keep_entry_point.i index 48746aabe0562d04934b6bf12ea7d704afc45169..6ade640dbb8933cb359dac79d608f7acf33fc4d3 100644 --- a/tests/misc/keep_entry_point.i +++ b/tests/misc/keep_entry_point.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -main f -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print +OPT: -main f -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print */ static int f(void); diff --git a/tests/misc/log-file.i b/tests/misc/log-file.i index 661521ddb7c8d6f929fc18396167c8510f561b67..833ee51da34f8228cc4ab373fe8573b430b7ca3f 100644 --- a/tests/misc/log-file.i +++ b/tests/misc/log-file.i @@ -1,4 +1,5 @@ /* run.config + EXECNOW: make -s @PTEST_DIR@/plugin_log.cmxs LOG: log-file-kernel-warnings.txt LOG: log-file-kernel-results.txt LOG: log-file-feedback.txt @@ -7,7 +8,7 @@ LOG: plugin-log-all.txt FILTER: sed 's|Your Frama-C version is.*|Your Frama-C version is VERSION|' STDOPT: #"-kernel-log w:@PTEST_RESULT@/log-file-kernel-warnings.txt,r:@PTEST_RESULT@/log-file-kernel-results.txt -eva-log f:@PTEST_RESULT@/log-file-feedback.txt,afewr:@PTEST_RESULT@/log-file-value-all.txt -eva-log :@PTEST_RESULT@/log-file-value-default.txt -then -kernel-log f:@PTEST_RESULT@/log-file-feedback.txt" - OPT: -load-module tests/misc/plugin_log.ml -kernel-msg-key foo-category -kernel-log=a:@PTEST_RESULT@/plugin-log-all.txt + OPT: -load-module tests/misc/plugin_log -kernel-msg-key foo-category -kernel-log=a:@PTEST_RESULT@/plugin-log-all.txt DONTRUN: test disabled due to non-deterministic errors in CI */ int f(void); // generates kernel warning (missing spec) diff --git a/tests/misc/log_twice.i b/tests/misc/log_twice.i index 4d912840dfc75a6f69c357e731f420a3b333ed44..e5c6f3a5f23f1f5e9fbe1a0f713c81101ead221d 100644 --- a/tests/misc/log_twice.i +++ b/tests/misc/log_twice.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/misc/log_twice -eva-show-progress + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@ -eva-show-progress */ int* f() { diff --git a/tests/misc/my_visitor.c b/tests/misc/my_visitor.c index 921a82c24c416653c44b705dedb7d86cb431dd12..29355fd152e80c899adebc677eb1abba062d46d5 100644 --- a/tests/misc/my_visitor.c +++ b/tests/misc/my_visitor.c @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -EXECNOW: LOG my_visitor_sav.res LOG my_visitor_sav.err BIN my_visitor.sav FRAMAC_PLUGIN=./lib/plugins @frama-c@ @PTEST_FILE@ -load-module @PTEST_DIR@/@PTEST_NAME@ -main f -save @PTEST_DIR@/@PTEST_NAME@.sav > @PTEST_DIR@/result/@PTEST_NAME@_sav.res 2> @PTEST_DIR@/result/@PTEST_NAME@_sav.err +EXECNOW: LOG my_visitor_sav.res LOG my_visitor_sav.err BIN my_visitor.sav FRAMAC_PLUGIN=./lib/plugins @frama-c@ @PTEST_FILE@ -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -main f -save @PTEST_DIR@/@PTEST_NAME@.sav > @PTEST_DIR@/result/@PTEST_NAME@_sav.res 2> @PTEST_DIR@/result/@PTEST_NAME@_sav.err OPT: -load @PTEST_DIR@/@PTEST_NAME@.sav -print */ int f() { diff --git a/tests/misc/oracle/ensures.res.oracle b/tests/misc/oracle/ensures.res.oracle index 7648b92dd837a79640186839b0e38b1770b249e8..7acf87d61616ae7b517495ee6013e35bbdeaf2a7 100644 --- a/tests/misc/oracle/ensures.res.oracle +++ b/tests/misc/oracle/ensures.res.oracle @@ -4,7 +4,7 @@ [eva] Initial state computed [eva:initial-state] Values of globals at initialization -[eva:alarm] tests/misc/ensures.i:4: Warning: +[eva:alarm] tests/misc/ensures.i:5: Warning: function main: postcondition got status invalid. [eva] done for function main [kernel] main: behavior default! diff --git a/tests/misc/oracle/log-file-feedback.txt b/tests/misc/oracle/log-file-feedback.txt index 36ffb1f22e57f630e6be7ebd23b2467ab31370ea..941d344dc0af8f47c2ec0f194933b87cdb04c53a 100644 --- a/tests/misc/oracle/log-file-feedback.txt +++ b/tests/misc/oracle/log-file-feedback.txt @@ -3,13 +3,13 @@ [eva] Computing initial state [eva] Initial state computed [eva] computing for function f <- main. -Called from tests/misc/log-file.i:18. +Called from tests/misc/log-file.i:20. [eva] using specification for function f [eva] Done for function f [eva] computing for function g <- main. -Called from tests/misc/log-file.i:19. +Called from tests/misc/log-file.i:21. [eva] using specification for function g [eva] Done for function g -tests/misc/log-file.i:20:[eva] starting to merge loop iterations +tests/misc/log-file.i:22:[eva] starting to merge loop iterations [eva] Recording results for main [eva] done for function main diff --git a/tests/misc/oracle/log-file-kernel-warnings.txt b/tests/misc/oracle/log-file-kernel-warnings.txt index 3ab2fc7cdc3e703ae681512fcc3dfe307c4e2042..4e35b1c74cec91a3ba4e36c94232ff1ccbbf3e6e 100644 --- a/tests/misc/oracle/log-file-kernel-warnings.txt +++ b/tests/misc/oracle/log-file-kernel-warnings.txt @@ -1 +1 @@ -tests/misc/log-file.i:18:[kernel:annot:missing-spec] warning: Neither code nor specification for function f, generating default assigns from the prototype +tests/misc/log-file.i:20:[kernel:annot:missing-spec] warning: Neither code nor specification for function f, generating default assigns from the prototype diff --git a/tests/misc/oracle/log-file-value-all.txt b/tests/misc/oracle/log-file-value-all.txt index 258754c1f7f836687e390ddb4e262f18960c866d..c19d8ff15faac9301d00a3f1878c008f2c7ef9fe 100644 --- a/tests/misc/oracle/log-file-value-all.txt +++ b/tests/misc/oracle/log-file-value-all.txt @@ -2,15 +2,15 @@ [eva] Computing initial state [eva] Initial state computed [eva] computing for function f <- main. -Called from tests/misc/log-file.i:18. +Called from tests/misc/log-file.i:20. [eva] using specification for function f [eva] Done for function f [eva] computing for function g <- main. -Called from tests/misc/log-file.i:19. +Called from tests/misc/log-file.i:21. [eva] using specification for function g -tests/misc/log-file.i:15:[eva] warning: no 'assigns \result \from ...' clause specified for function g +tests/misc/log-file.i:17:[eva] warning: no 'assigns \result \from ...' clause specified for function g [eva] Done for function g -tests/misc/log-file.i:20:[eva] starting to merge loop iterations +tests/misc/log-file.i:22:[eva] starting to merge loop iterations [eva] Recording results for main [eva] done for function main [eva] ====== VALUES COMPUTED ====== diff --git a/tests/misc/oracle/log-file-value-default.txt b/tests/misc/oracle/log-file-value-default.txt index 9d4908aa0b45d572c09498784aaebc250f71a300..93553049c30efa17102275ef8c4b8187d04efeea 100644 --- a/tests/misc/oracle/log-file-value-default.txt +++ b/tests/misc/oracle/log-file-value-default.txt @@ -1,2 +1,2 @@ -tests/misc/log-file.i:15:[eva] warning: no 'assigns \result \from ...' clause specified for function g +tests/misc/log-file.i:17:[eva] warning: no 'assigns \result \from ...' clause specified for function g [eva] ====== VALUES COMPUTED ====== diff --git a/tests/misc/oracle/log-file.0.res.oracle b/tests/misc/oracle/log-file.0.res.oracle index 75c688457ba46f7f783c6fa33d20957f376a068f..83288a2ea513c05a7125a26eea8b5a4cee999871 100644 --- a/tests/misc/oracle/log-file.0.res.oracle +++ b/tests/misc/oracle/log-file.0.res.oracle @@ -5,18 +5,18 @@ [eva:initial-state] Values of globals at initialization [eva] computing for function f <- main. - Called from tests/misc/log-file.i:18. -[kernel:annot:missing-spec] tests/misc/log-file.i:18: Warning: + Called from tests/misc/log-file.i:20. +[kernel:annot:missing-spec] tests/misc/log-file.i:20: Warning: Neither code nor specification for function f, generating default assigns from the prototype [eva] using specification for function f [eva] Done for function f [eva] computing for function g <- main. - Called from tests/misc/log-file.i:19. + Called from tests/misc/log-file.i:21. [eva] using specification for function g -[eva] tests/misc/log-file.i:15: Warning: +[eva] tests/misc/log-file.i:17: Warning: no 'assigns \result \from ...' clause specified for function g [eva] Done for function g -[eva] tests/misc/log-file.i:20: starting to merge loop iterations +[eva] tests/misc/log-file.i:22: starting to merge loop iterations [eva] Recording results for main [eva] done for function main [eva] ====== VALUES COMPUTED ====== diff --git a/tests/misc/oracle/log_twice.res.oracle b/tests/misc/oracle/log_twice.res.oracle index 871920c55ba2fee41bfc176a78c22e59d809ea86..30fcb6869ca0f742ade2702953dcb5493a9573e9 100644 --- a/tests/misc/oracle/log_twice.res.oracle +++ b/tests/misc/oracle/log_twice.res.oracle @@ -5,19 +5,19 @@ [eva:initial-state] Values of globals at initialization [eva] computing for function f <- main. - Called from tests/misc/log_twice.i:11. + Called from tests/misc/log_twice.i:12. [eva] Recording results for f [eva] Done for function f -[eva:locals-escaping] tests/misc/log_twice.i:11: Warning: +[eva:locals-escaping] tests/misc/log_twice.i:12: Warning: locals {x} escaping the scope of f through \result<f> -[eva:alarm] tests/misc/log_twice.i:12: Warning: +[eva:alarm] tests/misc/log_twice.i:13: Warning: accessing left-value that contains escaping addresses. assert ¬\dangling(&p); -[kernel] tests/misc/log_twice.i:12: Warning: +[kernel] tests/misc/log_twice.i:13: Warning: all target addresses were invalid. This path is assumed to be dead. [eva] Recording results for main [eva] done for function main -[eva] tests/misc/log_twice.i:12: +[eva] tests/misc/log_twice.i:13: assertion 'Eva,dangling_pointer' got final status invalid. [eva] Analyzing a complete application starting at main [eva] Computing initial state @@ -25,17 +25,17 @@ [eva:initial-state] Values of globals at initialization [eva] computing for function f <- main. - Called from tests/misc/log_twice.i:11. + Called from tests/misc/log_twice.i:12. [eva] Recording results for f [eva] Done for function f -[eva:locals-escaping] tests/misc/log_twice.i:11: Warning: +[eva:locals-escaping] tests/misc/log_twice.i:12: Warning: locals {x} escaping the scope of f through \result<f> -[eva:alarm] tests/misc/log_twice.i:12: Warning: +[eva:alarm] tests/misc/log_twice.i:13: Warning: accessing left-value that contains escaping addresses. assert ¬\dangling(&p); -[kernel] tests/misc/log_twice.i:12: Warning: +[kernel] tests/misc/log_twice.i:13: Warning: all target addresses were invalid. This path is assumed to be dead. [eva] Recording results for main [eva] done for function main -[eva] tests/misc/log_twice.i:12: +[eva] tests/misc/log_twice.i:13: assertion 'Eva,dangling_pointer' got final status invalid. diff --git a/tests/misc/oracle/pp_bin_hex.res.oracle b/tests/misc/oracle/pp_bin_hex.res.oracle new file mode 100644 index 0000000000000000000000000000000000000000..4791a522a343769216bd7ce7e105707e34f739e4 --- /dev/null +++ b/tests/misc/oracle/pp_bin_hex.res.oracle @@ -0,0 +1,86 @@ +-------------------------------------------------- +Dec. 0 +Hex. 0x0000 +Bin. 0b0000_0000 +-------------------------------------------------- +Dec. 1 +Hex. 0x0001 +Bin. 0b0000_0001 +-------------------------------------------------- +Dec. -1 +Hex. 1xFFFF +Bin. 1b1111_1111 +-------------------------------------------------- +Dec. 2 +Hex. 0x0002 +Bin. 0b0000_0010 +-------------------------------------------------- +Dec. -2 +Hex. 1xFFFE +Bin. 1b1111_1110 +-------------------------------------------------- +Dec. 5 +Hex. 0x0005 +Bin. 0b0000_0101 +-------------------------------------------------- +Dec. -5 +Hex. 1xFFFB +Bin. 1b1111_1011 +-------------------------------------------------- +Dec. 9 +Hex. 0x0009 +Bin. 0b0000_1001 +-------------------------------------------------- +Dec. -9 +Hex. 1xFFF7 +Bin. 1b1111_0111 +-------------------------------------------------- +Dec. 16 +Hex. 0x0010 +Bin. 0b0001_0000 +-------------------------------------------------- +Dec. -16 +Hex. 1xFFF0 +Bin. 1b1111_0000 +-------------------------------------------------- +Dec. 127 +Hex. 0x007F +Bin. 0b0111_1111 +-------------------------------------------------- +Dec. -127 +Hex. 1xFF81 +Bin. 1b1000_0001 +-------------------------------------------------- +Dec. 128 +Hex. 0x0080 +Bin. 0b1000_0000 +-------------------------------------------------- +Dec. -128 +Hex. 1xFF80 +Bin. 1b1000_0000 +-------------------------------------------------- +Dec. 255 +Hex. 0x00FF +Bin. 0b1111_1111 +-------------------------------------------------- +Dec. -255 +Hex. 1xFF01 +Bin. 1b0000_0001 +-------------------------------------------------- +Dec. 4279173135 +Hex. 0xFF0F_000F +Bin. 0b1111_1111_0000_1111_0000_0000_0000_1111 +-------------------------------------------------- +Dec. -4279173135 +Hex. 1x00F0_FFF1 +Bin. 1b0000_0000_1111_0000_1111_1111_1111_0001 +-------------------------------------------------- +Dec. 386334727 +Hex. 0x1707_0007 +Bin. 0b0001_0111_0000_0111_0000_0000_0000_0111 +-------------------------------------------------- +Dec. -386334727 +Hex. 1xE8F8_FFF9 +Bin. 1b1110_1000_1111_1000_1111_1111_1111_1001 +-------------------------------------------------- +[kernel] Parsing tests/misc/pp_bin_hex.i (no preprocessing) diff --git a/tests/misc/oracle/save_comments.res.oracle b/tests/misc/oracle/save_comments.res.oracle index fa8ecc7b92399bcdf1721529af1bad62ab343057..939609307f205e0f994526ba6ebc2ea685f0989c 100644 --- a/tests/misc/oracle/save_comments.res.oracle +++ b/tests/misc/oracle/save_comments.res.oracle @@ -2,7 +2,8 @@ Printing default project first time: /* Generated by Frama-C */ /* run.config - OPT: -load-script tests/misc/save_comments.ml -keep-comments + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -keep-comments */ int f(void) { @@ -15,7 +16,8 @@ int f(void) Printing default project second time: /* Generated by Frama-C */ /* run.config - OPT: -load-script tests/misc/save_comments.ml -keep-comments + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -keep-comments */ int f(void) { @@ -34,7 +36,8 @@ End of comments Printing saved project: /* Generated by Frama-C */ /* run.config - OPT: -load-script tests/misc/save_comments.ml -keep-comments + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -keep-comments */ int f(void) { diff --git a/tests/misc/pp_bin_hex.i b/tests/misc/pp_bin_hex.i new file mode 100644 index 0000000000000000000000000000000000000000..a53499be69922b6d91cd0d4926968829ccf22a93 --- /dev/null +++ b/tests/misc/pp_bin_hex.i @@ -0,0 +1,3 @@ +/* run.config + OPT: -no-autoload-plugins -load-script tests/misc/pp_bin_hex.ml +*/ diff --git a/tests/misc/pp_bin_hex.ml b/tests/misc/pp_bin_hex.ml new file mode 100644 index 0000000000000000000000000000000000000000..41ab2e6ab92ee1beef120983f3e307461ada4811 --- /dev/null +++ b/tests/misc/pp_bin_hex.ml @@ -0,0 +1,37 @@ +let pp_dec fmt z = Integer.pretty ~hexa:false fmt z +let pp_hex fmt z = Integer.pp_hex ~nbits:16 ~sep:"_" fmt z +let pp_bin fmt z = Integer.pp_bin ~nbits:8 ~sep:"_" fmt z + +let hrule () = + Format.printf "--------------------------------------------------@." + +let testcase z = + begin + hrule () ; + Format.printf "Dec. %a@." pp_dec z ; + Format.printf "Hex. %a@." pp_hex z ; + Format.printf "Bin. %a@." pp_bin z ; + end + +let () = + begin + List.iter + (fun z -> + testcase z ; + if not (Integer.equal z Integer.zero) then + testcase (Integer.neg z) + ) [ + Integer.of_string "0" ; + Integer.of_string "1" ; + Integer.of_string "2" ; + Integer.of_string "5" ; + Integer.of_string "9" ; + Integer.of_string "16" ; + Integer.of_string "127" ; + Integer.of_string "128" ; + Integer.of_string "0xFF" ; + Integer.of_string "0xFF0F000F" ; + Integer.of_string "0x17070007" ; + ] ; + hrule () ; + end diff --git a/tests/misc/print_machdep.i b/tests/misc/print_machdep.i index 80afbbd20f335c72d597dbc6c45cf6e37d304c37..0762669acd646cdbd6257081b52f420d15c7e2b2 100644 --- a/tests/misc/print_machdep.i +++ b/tests/misc/print_machdep.i @@ -1,4 +1,3 @@ /* run.config - CMD: @frama-c@ -no-autoload-plugins - OPT: -print-machdep + OPT: -no-autoload-plugins -print-machdep */ diff --git a/tests/misc/remove_status_hyps.i b/tests/misc/remove_status_hyps.i index 65348944a6d4a5ede92bee270d3aa2c8352a3070..a436356626c8169ba8c349bf26bb5d2d31c72a52 100644 --- a/tests/misc/remove_status_hyps.i +++ b/tests/misc/remove_status_hyps.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/misc/remove_status_hyps.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ int main(void) { diff --git a/tests/misc/save_comments.i b/tests/misc/save_comments.i index 6ee3a950e34b306f68b62dc474d4a364156afafb..aaf7cccdef62fdaaaea56d6e6b5160163941eea4 100644 --- a/tests/misc/save_comments.i +++ b/tests/misc/save_comments.i @@ -1,8 +1,8 @@ /* run.config - OPT: -load-script tests/misc/save_comments.ml -keep-comments + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -keep-comments */ - int f() { int x = 0; /* Hello, I'm the f function */ diff --git a/tests/misc/static.i b/tests/misc/static.i index 4c5ea035b725324d3a71332ef52c1d4e2a78a5ad..b0863c3a2b3908f34f1bfe07919867975270aa3c 100644 --- a/tests/misc/static.i +++ b/tests/misc/static.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ int x; diff --git a/tests/misc/test_datatype.i b/tests/misc/test_datatype.i index ffe2a11b457e9c4671e36a98bb2106a129035cd6..19405eb11ec4c3d5e608f535e9aeab5f595fb19a 100644 --- a/tests/misc/test_datatype.i +++ b/tests/misc/test_datatype.i @@ -1,4 +1,4 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ diff --git a/tests/misc/version.i b/tests/misc/version.i index cd0bcd0bf8696a3febda5e79680981cf9a2aed9d..3a762af550b5fb818f962ec7d88d225747f95e50 100644 --- a/tests/misc/version.i +++ b/tests/misc/version.i @@ -1,3 +1,4 @@ /* run.config - OPT: -load-script tests/misc/version.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ diff --git a/tests/misc/vis_queueInstr.i b/tests/misc/vis_queueInstr.i index f9f32820ed0dc77562cb2d9e938ec18c823d4a97..61fd2bb820de4616e9e18edfc2cd55a5eedd711b 100644 --- a/tests/misc/vis_queueInstr.i +++ b/tests/misc/vis_queueInstr.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print -then-on A -print +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print -then-on A -print */ int main(){ diff --git a/tests/misc/vis_spec.i b/tests/misc/vis_spec.i index 9515609a61d1cc5892d2bd348a2f5ffb61f4d9cd..c40858396b4be923663a262dc97a0cdc4b187771 100644 --- a/tests/misc/vis_spec.i +++ b/tests/misc/vis_spec.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/misc/vis_spec.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ //@ assigns \nothing; diff --git a/tests/misc/visitor_creates_func_bts_1349.i b/tests/misc/visitor_creates_func_bts_1349.i index 3fc9e30144b24c39aacd54b9183f1f5617cb66e7..a03c0cd1c45050418effd185243b6dff7a1f7e3e 100644 --- a/tests/misc/visitor_creates_func_bts_1349.i +++ b/tests/misc/visitor_creates_func_bts_1349.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/misc/Visitor_creates_func_bts_1349.ml -then-on test -print + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-script @PTEST_DIR@/@PTEST_NAME@ -then-on test -print */ int a = 10; diff --git a/tests/misc/Visitor_creates_func_bts_1349.ml b/tests/misc/visitor_creates_func_bts_1349.ml similarity index 100% rename from tests/misc/Visitor_creates_func_bts_1349.ml rename to tests/misc/visitor_creates_func_bts_1349.ml diff --git a/tests/misc/well_typed_alarm.i b/tests/misc/well_typed_alarm.i index ec5f84df44fadd1ae56dfd540851c7dc198c0794..236200877af3a87006d77bafa01de09eef090645 100644 --- a/tests/misc/well_typed_alarm.i +++ b/tests/misc/well_typed_alarm.i @@ -1,7 +1,7 @@ /* run.config* -OPT: -load-script @PTEST_DIR@/@PTEST_NAME@.ml +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ - int main(int c) { int x = 0; int y = 0; diff --git a/tests/pdg/dyn_dpds.c b/tests/pdg/dyn_dpds.c index 459bd5a60d78cfeaf7100d5e608388f1caaa6a41..20168cf1621c6ed2ae366c5dc958e353dd524c74 100644 --- a/tests/pdg/dyn_dpds.c +++ b/tests/pdg/dyn_dpds.c @@ -1,17 +1,17 @@ /* run.config - OPT: -load-script tests/pdg/dyn_dpds.ml -eva-show-progress -deps -journal-disable -pdg-print -pdg-verbose 2 + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -eva-show-progress -deps -journal-disable -pdg-print -pdg-verbose 2 */ /* To have a look at the dot PDG : - bin/toplevel.byte -deps -pdg-dot pdg -eva-show-progress -fct-pdg main tests/pdg/dyn_dpds.c ; + bin/toplevel.byte -deps -pdg-dot pdg -eva-show-progress -fct-pdg main @PTEST_DIR@/@PTEST_NAME@.c ; zgrviewer pdg.main.dot - or use tests/pdg/dyn_dpds.ml to test the dynamic dependencies. + or use @PTEST_DIR@/@PTEST_NAME@.ml to test the dynamic dependencies. */ - int G; int main (int a, int b, int c) { diff --git a/tests/pdg/sets.c b/tests/pdg/sets.c index 9623e013f31c3dbe56f85351cb8bb66e57864cc7..3efc61ce72bd3318339f327989bcf123587acb84 100644 --- a/tests/pdg/sets.c +++ b/tests/pdg/sets.c @@ -1,9 +1,9 @@ /* run.config - OPT: -eva-show-progress -load-script tests/pdg/sets.ml -lib-entry -main f -pdg -inout -journal-disable -pdg-print -pdg-verbose 2 + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -eva-show-progress -load-module @PTEST_DIR@/@PTEST_NAME@ -lib-entry -main f -pdg -inout -journal-disable -pdg-print -pdg-verbose 2 */ - int b, c, x, y, z, t; void f(int a) { y = 0; // 1, node 9 diff --git a/tests/rte/precond2.c b/tests/rte/precond2.c index 2c3844e757435034d26935ecf9cfd2dcc952e029..72d360e0d96667335f976b60727fdeb9843b965c 100644 --- a/tests/rte/precond2.c +++ b/tests/rte/precond2.c @@ -1,5 +1,6 @@ /* run.config - OPT: -warn-special-float none -load-script tests/rte/compute_annot/compute_annot.ml -journal-disable + EXECNOW: make -s @PTEST_DIR@/compute_annot/compute_annot.cmxs + OPT: -warn-special-float none -load-module @PTEST_DIR@/compute_annot/compute_annot -journal-disable */ int global = 15; diff --git a/tests/rte/threefunc.c b/tests/rte/threefunc.c index 44aa8d37cd24c7e8fbd3027e21a2ead6d43c24d6..03b2ad3b373fd5dcc26253574999f9bccfa59a30 100644 --- a/tests/rte/threefunc.c +++ b/tests/rte/threefunc.c @@ -1,5 +1,6 @@ /* run.config -OPT: -load-script tests/rte/my_annotation/my_annotation.ml +EXECNOW: make -s @PTEST_DIR@/my_annotation/my_annotation.cmxs +OPT: -load-module @PTEST_DIR@/my_annotation/my_annotation */ diff --git a/tests/rte/twofunc.c b/tests/rte/twofunc.c index 38ce35dac65ffdac7071447de3145e63aa84bed7..2732ad9f1f99b79c79b2f9450870d3904a69cd71 100644 --- a/tests/rte/twofunc.c +++ b/tests/rte/twofunc.c @@ -1,5 +1,6 @@ /* run.config -OPT: -load-script tests/rte/my_annot_proxy/my_annot_proxy.ml +EXECNOW: make -s @PTEST_DIR@/my_annot_proxy/my_annot_proxy.cmxs +OPT: -load-module @PTEST_DIR@/my_annot_proxy/my_annot_proxy */ diff --git a/tests/rte/twofunc3.c b/tests/rte/twofunc3.c index 8894e7cbee4a51fb176dc870a4302db5171ae2ad..b7102aaf7086db45e0bfbf0924a346a8edab1bcb 100644 --- a/tests/rte/twofunc3.c +++ b/tests/rte/twofunc3.c @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/rte/rte_api/rte_get_annot.ml -journal-disable + EXECNOW: make -s @PTEST_DIR@/rte_api/rte_get_annot.cmxs + OPT: -load-module @PTEST_DIR@/rte_api/rte_get_annot -journal-disable */ diff --git a/tests/saveload/basic.i b/tests/saveload/basic.i index d091c2203be2d30c683283c29998dddb3d416940..e0d5d8f8b74aa58031d88339800120da3fb0c659 100644 --- a/tests/saveload/basic.i +++ b/tests/saveload/basic.i @@ -1,13 +1,14 @@ /* run.config - EXECNOW: make -s ./tests/saveload/basic.cmxs - EXECNOW: LOG basic_sav.res LOG basic_sav.err BIN basic.sav @frama-c@ -load-module ./tests/saveload/basic -eva -out -input -deps -eva-show-progress ./tests/saveload/basic.i -save ./tests/saveload/result/basic.sav > ./tests/saveload/result/basic_sav.res 2> ./tests/saveload/result/basic_sav.err - EXECNOW: LOG basic_sav.1.res LOG basic_sav.1.err BIN basic.1.sav ./bin/toplevel.opt -save ./tests/saveload/result/basic.1.sav ./tests/saveload/basic.i -eva -out -input -deps -eva-show-progress > ./tests/saveload/result/basic_sav.1.res 2> ./tests/saveload/result/basic_sav.1.err + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + EXECNOW: LOG basic_sav.res LOG basic_sav.err BIN basic.sav @frama-c@ -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -eva -out -input -deps -eva-show-progress ./@PTEST_DIR@/@PTEST_NAME@.i -save ./tests/saveload/result/basic.sav > ./tests/saveload/result/basic_sav.res 2> ./tests/saveload/result/basic_sav.err + EXECNOW: LOG basic_sav.1.res LOG basic_sav.1.err BIN basic.1.sav ./bin/toplevel.opt -save ./tests/saveload/result/basic.1.sav @PTEST_DIR@/@PTEST_NAME@.i -eva -out -input -deps -eva-show-progress > ./tests/saveload/result/basic_sav.1.res 2> ./tests/saveload/result/basic_sav.1.err OPT: -load ./tests/saveload/result/basic.sav -eva -out -input -deps -journal-disable - CMD: @frama-c@ -load-module ./tests/saveload/basic + CMD: @frama-c@ -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -load ./tests/saveload/result/basic.1.sav -eva -out -input -deps -journal-disable -print OPT: -load ./tests/saveload/result/basic.1.sav -eva -out -input -deps -journal-disable - EXECNOW: LOG status_sav.res LOG status_sav.err BIN status.sav @frama-c@ -load-script tests/saveload/status.ml -save ./tests/saveload/result/status.sav ./tests/saveload/basic.i > ./tests/saveload/result/status_sav.res 2> ./tests/saveload/result/status_sav.err - OPT: -load-script tests/saveload/status.ml -load ./tests/saveload/result/status.sav + EXECNOW: make -s @PTEST_DIR@/status.cmxs + EXECNOW: LOG status_sav.res LOG status_sav.err BIN status.sav @frama-c@ -load-module @PTEST_DIR@/status -save ./tests/saveload/result/status.sav @PTEST_DIR@/@PTEST_NAME@.i > ./tests/saveload/result/status_sav.res 2> ./tests/saveload/result/status_sav.err + OPT: -load-module @PTEST_DIR@/status -load ./tests/saveload/result/status.sav OPT: -load ./tests/saveload/result/status.sav */ diff --git a/tests/saveload/load_one.i b/tests/saveload/load_one.i index 2c6aa23233a1a0d9baf17cbd8442b40a14c40e4f..8f58edd16793be9f8f058ad48543ab1df2132096 100644 --- a/tests/saveload/load_one.i +++ b/tests/saveload/load_one.i @@ -1,7 +1,7 @@ /* run.config - OPT: -load-script tests/saveload/load_one.ml -eva-show-progress + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -eva-show-progress */ - int G; int f (int x, int y) { diff --git a/tests/saveload/multi_project.i b/tests/saveload/multi_project.i index b3a6c55cc1ba9915f315ba8f5d8273e37f63a6bc..e8c3589515cd3bdca84e5679e3a52330cfbbbb50 100644 --- a/tests/saveload/multi_project.i +++ b/tests/saveload/multi_project.i @@ -1,8 +1,8 @@ /* run.config - EXECNOW: BIN multi_project.sav LOG multi_project_sav.res LOG multi_project_sav.err ./bin/toplevel.opt -save ./tests/saveload/result/multi_project.sav -eva-show-progress -semantic-const-folding ./tests/saveload/multi_project.i > tests/saveload/result/multi_project_sav.res 2> tests/saveload/result/multi_project_sav.err - EXECNOW: make -s ./tests/saveload/multi_project.cmxs + EXECNOW: BIN multi_project.sav LOG multi_project_sav.res LOG multi_project_sav.err ./bin/toplevel.opt -save ./tests/saveload/result/multi_project.sav -eva-show-progress -semantic-const-folding @PTEST_DIR@/@PTEST_NAME@.i > tests/saveload/result/multi_project_sav.res 2> tests/saveload/result/multi_project_sav.err + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -load ./tests/saveload/result/multi_project.sav -journal-disable - CMD: @frama-c@ -load-module ./tests/saveload/multi_project + CMD: @frama-c@ -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva -eva-show-progress */ int f(int x) { diff --git a/tests/saveload/oracle/basic_sav.1.res b/tests/saveload/oracle/basic_sav.1.res index 985eb96467566d2d7978358d57e350538de45307..056059606204259f47c4619d6aa71f6dd14adaa0 100644 --- a/tests/saveload/oracle/basic_sav.1.res +++ b/tests/saveload/oracle/basic_sav.1.res @@ -4,9 +4,9 @@ [eva] Initial state computed [eva:initial-state] Values of globals at initialization -[eva] tests/saveload/basic.i:18: assertion got status valid. -[eva] tests/saveload/basic.i:19: starting to merge loop iterations -[eva:alarm] tests/saveload/basic.i:19: Warning: +[eva] tests/saveload/basic.i:19: assertion got status valid. +[eva] tests/saveload/basic.i:20: starting to merge loop iterations +[eva:alarm] tests/saveload/basic.i:20: Warning: signed overflow. assert -2147483648 ≤ i - 1; [eva] Recording results for main [eva] done for function main diff --git a/tests/saveload/oracle/basic_sav.res b/tests/saveload/oracle/basic_sav.res index 985eb96467566d2d7978358d57e350538de45307..056059606204259f47c4619d6aa71f6dd14adaa0 100644 --- a/tests/saveload/oracle/basic_sav.res +++ b/tests/saveload/oracle/basic_sav.res @@ -4,9 +4,9 @@ [eva] Initial state computed [eva:initial-state] Values of globals at initialization -[eva] tests/saveload/basic.i:18: assertion got status valid. -[eva] tests/saveload/basic.i:19: starting to merge loop iterations -[eva:alarm] tests/saveload/basic.i:19: Warning: +[eva] tests/saveload/basic.i:19: assertion got status valid. +[eva] tests/saveload/basic.i:20: starting to merge loop iterations +[eva:alarm] tests/saveload/basic.i:20: Warning: signed overflow. assert -2147483648 ≤ i - 1; [eva] Recording results for main [eva] done for function main diff --git a/tests/saveload/serialized_queue.i b/tests/saveload/serialized_queue.i index fe5a57bd8f72e2e63b0b2930443f942be55eecc4..3d2c450536e513b1580c0197708c6f78599e4c31 100644 --- a/tests/saveload/serialized_queue.i +++ b/tests/saveload/serialized_queue.i @@ -1,5 +1,6 @@ /* run.config -OPT: -load-script @PTEST_DIR@/@PTEST_NAME@.ml +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ // empty C file, we're only interested in the script itself diff --git a/tests/scope/bts971.c b/tests/scope/bts971.c index d23783b30da5267e2f5364fa961f46bd80ee0847..b50076a1a38082a0c1f3d15ae9b1cfa66e8fa6e0 100644 --- a/tests/scope/bts971.c +++ b/tests/scope/bts971.c @@ -1,7 +1,7 @@ /* run.config - OPT: -journal-disable -load-script tests/scope/bts971.ml -then -main main2 + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -journal-disable -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -then -main main2 */ - /* bug 971: */ volatile foo; int v; diff --git a/tests/scope/zones.c b/tests/scope/zones.c index b60197f2d884c12dbf8d011b0de8cc5a5cefce94..884e57b2162c1665bbac00b98c150d5e02c6373c 100644 --- a/tests/scope/zones.c +++ b/tests/scope/zones.c @@ -1,10 +1,10 @@ /* run.config - OPT: -load-script tests/scope/zones.ml -eva -eva-show-progress -journal-disable +# EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -load-module @PTEST_DIR@/@PTEST_NAME@ -eva -eva-show-progress -journal-disable */ - -/* bin/viewer.opt -eva tests/scope/zones.c */ +/* bin/viewer.opt -eva @PTEST_DIR@/@PTEST_NAME@.c */ int T [10]; struct Tstr { int a; int b; } S; diff --git a/tests/slicing/adpcm.c b/tests/slicing/adpcm.c index 3ca387a3406fa599e26887b96303c2ae4bc6f396..88dbc4dbda0d8a796d81743dfda2b7dfab5b14e1 100644 --- a/tests/slicing/adpcm.c +++ b/tests/slicing/adpcm.c @@ -1,6 +1,6 @@ /* run.config - EXECNOW: make -s tests/slicing/adpcm.cmxs - OPT: -eva-show-progress -load-module ./tests/slicing/libSelect.cmxs -load-module ./tests/slicing/adpcm.cmxs -ulevel -1 -deps -slicing-level 2 -journal-disable + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -eva-show-progress -load-module ./tests/slicing/libSelect.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -ulevel -1 -deps -slicing-level 2 -journal-disable */ #include "tests/test/adpcm.c" diff --git a/tests/slicing/combine.i b/tests/slicing/combine.i index 983a97af1402259919d337a17cf10b82544f227b..16d12c1adcd6a2813d481d626b1535c4714bb64f 100644 --- a/tests/slicing/combine.i +++ b/tests/slicing/combine.i @@ -1,6 +1,6 @@ /* run.config - EXECNOW: make -s tests/slicing/combine.cmxs - CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/combine.cmxs + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva-show-progress -deps -journal-disable */ diff --git a/tests/slicing/ex_spec_interproc.i b/tests/slicing/ex_spec_interproc.i index 9f6d8ca13606bc64e5756bdca896f27205dc580f..962dd869e61cbda26e097423225fba45df9b3713 100644 --- a/tests/slicing/ex_spec_interproc.i +++ b/tests/slicing/ex_spec_interproc.i @@ -1,6 +1,6 @@ /* run.config - EXECNOW: make -s tests/slicing/ex_spec_interproc.cmxs - CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/ex_spec_interproc.cmxs + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva-show-progress -deps -journal-disable */ diff --git a/tests/slicing/horwitz.i b/tests/slicing/horwitz.i index 3cc83fb2dd7b2f056e084b53fc52f6c15b18ed94..0178857313f549f260b26554f05c18a927bde711 100644 --- a/tests/slicing/horwitz.i +++ b/tests/slicing/horwitz.i @@ -1,12 +1,12 @@ /* run.config - EXECNOW: make -s tests/slicing/horwitz.cmxs - CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/horwitz.cmxs + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva-show-progress -deps -slicing-level 0 -journal-disable */ -/* bin/toplevel.opt -deps -eva tests/slicing/horwitz.c */ -/* bin/toplevel.opt -deps -pdg-debug -pdg tests/slicing/horwitz.c */ -/* cf aussi tests/slicing/horwitz.ml */ +/* bin/toplevel.opt -deps -eva @PTEST_DIR@/@PTEST_NAME@.c */ +/* bin/toplevel.opt -deps -pdg-debug -pdg @PTEST_DIR@/@PTEST_NAME@.c */ +/* cf aussi @PTEST_DIR@/@PTEST_NAME@.ml */ int add (int a, int b) { return a+b; diff --git a/tests/slicing/mark_all_slices.i b/tests/slicing/mark_all_slices.i index 3454c9e2befc3c6b0162dc468a7115f5e1d2c9a8..d25812226596c855a7380ef38ddc9520f0f0c405 100644 --- a/tests/slicing/mark_all_slices.i +++ b/tests/slicing/mark_all_slices.i @@ -1,6 +1,6 @@ /* run.config - EXECNOW: make -s tests/slicing/mark_all_slices.cmxs - CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/mark_all_slices.cmxs + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva-show-progress -deps -slicing-level 3 -no-slice-callers -journal-disable */ int A, B, C, D; diff --git a/tests/slicing/merge.i b/tests/slicing/merge.i index b25108129ad6606803c84d0febb9df5497bea6d5..bf0509784e30e9adfe5159b4e8cff4be9597d3b9 100644 --- a/tests/slicing/merge.i +++ b/tests/slicing/merge.i @@ -1,6 +1,6 @@ /* run.config - EXECNOW: make -s tests/slicing/merge.cmxs - CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/libAnim.cmxs -load-module tests/slicing/merge.cmxs + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/libAnim.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva-show-progress -deps -slicing-level 3 -journal-disable */ diff --git a/tests/slicing/min_call.i b/tests/slicing/min_call.i index bb033d1fc639504a1224b21697fc0ff03975a26d..f7cc89e6a8dd1b8e1b9b580e0a2bdc2dc0457a75 100644 --- a/tests/slicing/min_call.i +++ b/tests/slicing/min_call.i @@ -1,6 +1,6 @@ /* run.config - EXECNOW: make -s tests/slicing/min_call.cmxs - CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/min_call.cmxs + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva-show-progress -deps -lib-entry -main g -journal-disable -slicing-level 3 */ diff --git a/tests/slicing/select_by_annot.i b/tests/slicing/select_by_annot.i index fe285f2541c43f31036a42f891208315269498bb..a0cd4471cf1e72b7b7e5ecfc74212bbc83f1bfb2 100644 --- a/tests/slicing/select_by_annot.i +++ b/tests/slicing/select_by_annot.i @@ -1,6 +1,6 @@ /* run.config - EXECNOW: make -s tests/slicing/select_by_annot.cmxs - CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/select_by_annot.cmxs + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva-show-progress -deps -lib-entry -main main -journal-disable CMD: bin/toplevel.opt OPT: -eva-show-progress -check -deps -lib-entry -main main -slice-pragma main -journal-disable -then-on 'Slicing export' -set-project-as-default -print -check -then -print -ocode @PTEST_DIR@/result/ocode_@PTEST_NUMBER@_@PTEST_NAME@.i -then @PTEST_DIR@/result/ocode_@PTEST_NUMBER@_@PTEST_NAME@.i -check -no-deps diff --git a/tests/slicing/select_simple.i b/tests/slicing/select_simple.i index 9e30123cd9bd1662a26cdb7c74e287e2aaa2e79f..9883f3ff5832c4114b5d9af361e3bdc732257829 100644 --- a/tests/slicing/select_simple.i +++ b/tests/slicing/select_simple.i @@ -1,6 +1,6 @@ /* run.config - EXECNOW: make -s tests/slicing/select_simple.cmxs - CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/select_simple.cmxs + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva-show-progress -deps -journal-disable */ diff --git a/tests/slicing/simple_intra_slice.i b/tests/slicing/simple_intra_slice.i index 065111000339285f6f469292a3d992d89d795d98..e335e824fe8810dc5832f1d524f0a9f00728b079 100644 --- a/tests/slicing/simple_intra_slice.i +++ b/tests/slicing/simple_intra_slice.i @@ -1,6 +1,6 @@ /* run.config - EXECNOW: make -s tests/slicing/simple_intra_slice.cmxs - CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/simple_intra_slice.cmxs + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva-show-progress -deps -no-slice-callers -journal-disable */ int Unknown; diff --git a/tests/slicing/slice_no_body.i b/tests/slicing/slice_no_body.i index 0f261cfc5c8e0be129134359987f92540895e34e..9c249f20d9f10a391b1ad939bb7e8605473596a7 100644 --- a/tests/slicing/slice_no_body.i +++ b/tests/slicing/slice_no_body.i @@ -1,6 +1,6 @@ /* run.config - EXECNOW: make -s tests/slicing/slice_no_body.cmxs - CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/slice_no_body.cmxs + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva-show-progress -deps -lib-entry -main h -journal-disable */ diff --git a/tests/slicing/switch.i b/tests/slicing/switch.i index 11e453ccb719566980ce711bea9d90cdd5d820cd..0b1ca36ce07a809cf0c2cbbaec82b11bd2150ed1 100644 --- a/tests/slicing/switch.i +++ b/tests/slicing/switch.i @@ -1,6 +1,6 @@ /* run.config - EXECNOW: make -s tests/slicing/switch.cmxs - CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module tests/slicing/switch.cmxs + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + CMD: @frama-c@ -load-module tests/slicing/libSelect.cmxs -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs OPT: -eva-show-progress -deps -journal-disable */ int main (char choix) { diff --git a/tests/spec/Extend.i b/tests/spec/Extend.i index dd42b2180708242016365f0c6c3518062ca0b972..ff81bb51cab62adebb757548a563b5c5c4ac1a00 100644 --- a/tests/spec/Extend.i +++ b/tests/spec/Extend.i @@ -1,6 +1,6 @@ /* run.config -EXECNOW: make @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@ -copy -kernel-warn-key=annot-error=active +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -copy -kernel-warn-key=annot-error=active */ /*@ foo x == 0; diff --git a/tests/spec/add_global.i b/tests/spec/add_global.i index 0eeae27f26ff17543f3219293e44182bc5e22337..7ed406648a9ae0f6d2d9f3d5357314714edf358c 100644 --- a/tests/spec/add_global.i +++ b/tests/spec/add_global.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print */ int main () { return 0; } diff --git a/tests/spec/bts0578.i b/tests/spec/bts0578.i index 4d3a94ab5cecf0919d35a0beeea9433f38f410c8..c94e20665e6bda514c2d2f3460c2c132504d509c 100644 --- a/tests/spec/bts0578.i +++ b/tests/spec/bts0578.i @@ -1,5 +1,6 @@ /* run.config - OPT: -print -load-script ./tests/spec/bts0578.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -print -load-module ./@PTEST_DIR@/@PTEST_NAME@ */ /*@ behavior foo: ensures \true; */ diff --git a/tests/spec/bts0655.i b/tests/spec/bts0655.i index b994e76793c1467df1e4d2dc3af4ba9bda747209..b5947620ab99b29f05efcec6781e7549d0ff63c8 100644 --- a/tests/spec/bts0655.i +++ b/tests/spec/bts0655.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/spec/bts0655.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ /*@ @ ensures \result == \max( a, b ); diff --git a/tests/spec/comparison.i b/tests/spec/comparison.i index 9fc56fc54cfb485abfc7007da7dfae3add8102e1..a62a8a65c779ed28e8b1795d4182dc1a0897c66e 100644 --- a/tests/spec/comparison.i +++ b/tests/spec/comparison.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/spec/comparison.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ /*@ predicate foo(boolean a, boolean b) = a == b; */ diff --git a/tests/spec/expr_to_term.i b/tests/spec/expr_to_term.i index 74bd6f5aa8b625b8e0099467e25d85794a6b5922..12078604eca0f6f0bf50d630d939b9539203ff83 100644 --- a/tests/spec/expr_to_term.i +++ b/tests/spec/expr_to_term.i @@ -1,8 +1,7 @@ /* run.config -EXECNOW: make @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print */ - int x[10]; struct S { int y; int z; } s; diff --git a/tests/spec/location_char.c b/tests/spec/location_char.c index 3b9e457c7bbc26bda4de6536508d5f914e28b97a..99339a087cfd144ae6a400c10249fa9394530e4b 100644 --- a/tests/spec/location_char.c +++ b/tests/spec/location_char.c @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ /*@ requires x <= 0; diff --git a/tests/spec/model.i b/tests/spec/model.i index 0d4fe0b8b8f4672fb9ff0bc29b15e1669f8375c2..840ab0193bc7883a50f8671c43f01ad4264e3c08 100644 --- a/tests/spec/model.i +++ b/tests/spec/model.i @@ -1,8 +1,8 @@ /* run.config -STDOPT: +"-load-script tests/spec/model.ml" +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +STDOPT: +"-no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs" */ struct S { int x; int y; }; - typedef struct S T; /*@ model struct S { integer z }; */ diff --git a/tests/spec/pp_empty_spec.i b/tests/spec/pp_empty_spec.i index 0835b8c2332205289f637c06c42bcf7597904778..6d337f8500a51c4c764145969e8ef1c73bcff1f0 100644 --- a/tests/spec/pp_empty_spec.i +++ b/tests/spec/pp_empty_spec.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script @PTEST_DIR@/@PTEST_NAME@.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ int main(void) { int x = 0; diff --git a/tests/spec/property_test.i b/tests/spec/property_test.i index 07866538d3b1fcd413af495a25efa29e3c5d35c2..6f1de940f0cb8b128f6d9fefa4c635c806f5a267 100644 --- a/tests/spec/property_test.i +++ b/tests/spec/property_test.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/spec/property_test.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ int X; diff --git a/tests/spec/type_constructors_in_env.i b/tests/spec/type_constructors_in_env.i index f60aaadd9d224592b2297d6df9eab1cf6c096d68..636049ed329cfd848d51760fd52d2d84701261fc 100644 --- a/tests/spec/type_constructors_in_env.i +++ b/tests/spec/type_constructors_in_env.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ /*@ type foo = A | B; */ diff --git a/tests/syntax/Refresh_visitor.i b/tests/syntax/Refresh_visitor.i index 07ebc38f1b1206f7404b2cb9c4aa0c4782d79e89..0786760a68f8f6abcb244f9485e74fdeac8cbee5 100644 --- a/tests/syntax/Refresh_visitor.i +++ b/tests/syntax/Refresh_visitor.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@ -eva-show-progress +OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -eva-show-progress */ struct S { int i; }; diff --git a/tests/syntax/add_allocates.i b/tests/syntax/add_allocates.i index de0ffa3fe47e7ec04c07eda84e9e262a483a07c4..2153e41ea67e6f54eeaf4a2b2719f3abb359eeac 100644 --- a/tests/syntax/add_allocates.i +++ b/tests/syntax/add_allocates.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/syntax/add_allocates.ml -print + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print */ diff --git a/tests/syntax/ast_init.i b/tests/syntax/ast_init.i index 77d503529616cf024179a591aa65f33bf83c04d0..1e9aad67b5d3289f2c50f423edf4697fb2fb77fa 100644 --- a/tests/syntax/ast_init.i +++ b/tests/syntax/ast_init.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ int f(int x) { return x; } diff --git a/tests/syntax/char_is_unsigned.i b/tests/syntax/char_is_unsigned.i index f87954814a8e3d056d969c21a0df2de678014fe9..a3fbe427e1e26c1733ff8eecd4e4bd29fa9270d3 100644 --- a/tests/syntax/char_is_unsigned.i +++ b/tests/syntax/char_is_unsigned.i @@ -1,5 +1,6 @@ -/* run.config - OPT:-print -load-script tests/syntax/machdep_char_unsigned.ml -machdep unsigned_char -then -constfold -rte +/* run.config + EXECNOW: make -s @PTEST_DIR@/machdep_char_unsigned.cmxs + OPT:-print -load-module @PTEST_DIR@/machdep_char_unsigned -machdep unsigned_char -then -constfold -rte */ char t[10]; diff --git a/tests/syntax/clone_test.i b/tests/syntax/clone_test.i index e0a82386a6c8f795a3e7d70252220e76f625f0e2..7d94b47b61384b15dac0b60062acd1148947726a 100644 --- a/tests/syntax/clone_test.i +++ b/tests/syntax/clone_test.i @@ -1,5 +1,6 @@ /* run.config -OPT: -load-script @PTEST_DIR@/@PTEST_NAME@.ml +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ /*@ diff --git a/tests/syntax/copy_visitor_bts_1073.c b/tests/syntax/copy_visitor_bts_1073.c index 1c03240bfff694e5541238663e80381011ac77e7..a20b81af83fc0cb5b769207afd287f77450a2a17 100644 --- a/tests/syntax/copy_visitor_bts_1073.c +++ b/tests/syntax/copy_visitor_bts_1073.c @@ -1,6 +1,8 @@ /* run.config -OPT: -load-script tests/syntax/copy_visitor_bts_1073.ml -OPT: -load-script tests/syntax/copy_visitor_bts_1073_bis.ml -test -then-on filtered -print +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@_bis.cmxs +OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -load-module @PTEST_DIR@/@PTEST_NAME@_bis -test -then-on filtered -print */ #include "stdio.h" diff --git a/tests/syntax/forloophook.i b/tests/syntax/forloophook.i index 6fee07446ff502447a466480a7b40e3b9708cddb..d9e38bd7b222e52182a102421f32151e285020ec 100644 --- a/tests/syntax/forloophook.i +++ b/tests/syntax/forloophook.i @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/syntax/forloophook.ml + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ void f() { for (int i=0; i< 10; i++); diff --git a/tests/syntax/formals_decl_leak.i b/tests/syntax/formals_decl_leak.i index 6a521af4ade9356c5ed4431debc0970ff9d87596..93a7dc265a729926ce94aac380f8ec67a67198b8 100644 --- a/tests/syntax/formals_decl_leak.i +++ b/tests/syntax/formals_decl_leak.i @@ -1,5 +1,6 @@ /* run.config -OPT: -print -load-script tests/syntax/formals_decl_leak.ml tests/syntax/formals_decl_leak_1.i +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -print -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs @PTEST_DIR@/@PTEST_NAME@_1.i */ void f(int x); diff --git a/tests/syntax/get_astinfo_bts1136.i b/tests/syntax/get_astinfo_bts1136.i index bbb4f115aa35e1323469e5de9abb7633af777c9b..694aacdf37979df8db7e8043f9ed6268c82efa73 100644 --- a/tests/syntax/get_astinfo_bts1136.i +++ b/tests/syntax/get_astinfo_bts1136.i @@ -1,5 +1,6 @@ /* run.config -OPT: -load-script tests/syntax/get_astinfo_bts1136.ml +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ int f (int x) { return x; } int g (int x) { return x; } diff --git a/tests/syntax/inserted_casts.c b/tests/syntax/inserted_casts.c index 62ce8c000f283dfbfa406daaa8ab0f9b59805724..805496d3d23a36a8bb973199a0e95203a72363ab 100644 --- a/tests/syntax/inserted_casts.c +++ b/tests/syntax/inserted_casts.c @@ -1,7 +1,7 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs - STDOPT: +"-load-module @PTEST_DIR@/@PTEST_NAME@.cmxs" - STDOPT: +"-load-module @PTEST_DIR@/@PTEST_NAME@.cmxs" +"-machdep x86_64" + STDOPT: +"-no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs" + STDOPT: +"-no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs" +"-machdep x86_64" */ #include "stddef.h" int f(int b) diff --git a/tests/syntax/logic_env.i b/tests/syntax/logic_env.i index 6d8082506687116f05472ed8e711b5cee580024e..9570e109382c07d8d19a57248a384cbc372b9e66 100644 --- a/tests/syntax/logic_env.i +++ b/tests/syntax/logic_env.i @@ -1,5 +1,6 @@ /* run.config -OPT: -load-script tests/syntax/logic_env_script.ml +EXECNOW: make -s @PTEST_DIR@/logic_env_script.cmxs +OPT: -load-module @PTEST_DIR@/logic_env_script */ //@ predicate foo(integer x) = x == 0; diff --git a/tests/syntax/mutable_test.i b/tests/syntax/mutable_test.i index b8ed2d45fb4ca9f14eedb77ca9b8522ad008c015..3c480aa053427eebf9bcf9ca6c5dcfd257cad058 100644 --- a/tests/syntax/mutable_test.i +++ b/tests/syntax/mutable_test.i @@ -1,6 +1,6 @@ /* run.config EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs -OPT: -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -print */ struct R_1 { diff --git a/tests/syntax/oracle/get_astinfo_bts1136.res.oracle b/tests/syntax/oracle/get_astinfo_bts1136.res.oracle index cffcd6e4b73cd1290264656bf7e80aefd76fe204..6366ae5e8ee9b4b79e1ce7de9a6dc6e2d8a70370 100644 --- a/tests/syntax/oracle/get_astinfo_bts1136.res.oracle +++ b/tests/syntax/oracle/get_astinfo_bts1136.res.oracle @@ -1,13 +1,13 @@ [kernel] Parsing tests/syntax/get_astinfo_bts1136.i (no preprocessing) -found variable vid:22 formal in f -found variable vid:25 formal in g -found variable vid:28 formal in h -found variable vid:30 formal in i -found variable vid:32 formal in j -found variable vid:34 formal in k -[do_v] vid:28 formal in h -[do_v] vid:25 formal in g -[do_v] vid:22 formal in f -[do_v] vid:34 local in k -[do_v] vid:32 local in j -[do_v] vid:30 local in i +found variable vid:20 formal in f +found variable vid:23 formal in g +found variable vid:26 formal in h +found variable vid:28 formal in i +found variable vid:30 formal in j +found variable vid:32 formal in k +[do_v] vid:26 formal in h +[do_v] vid:23 formal in g +[do_v] vid:20 formal in f +[do_v] vid:32 local in k +[do_v] vid:30 local in j +[do_v] vid:28 local in i diff --git a/tests/syntax/oracle/syntactic_hook.res.oracle b/tests/syntax/oracle/syntactic_hook.res.oracle index 4d15d03a3ad3423d6b318c306cfbdfe997c2aee2..f91bf389edacd90454102c87b50ef336951d9660 100644 --- a/tests/syntax/oracle/syntactic_hook.res.oracle +++ b/tests/syntax/oracle/syntactic_hook.res.oracle @@ -1,22 +1,22 @@ [kernel] Parsing tests/syntax/syntactic_hook.i (no preprocessing) [kernel] tests/syntax/syntactic_hook.i:5: - New global node introducing identifier f(22) + New global node introducing identifier f(20) [kernel] First occurrence of f [kernel] tests/syntax/syntactic_hook.i:7: - New global node introducing identifier k(25) + New global node introducing identifier k(23) [kernel] First occurrence of k [kernel] tests/syntax/syntactic_hook.i:9: - New global node introducing identifier k(25) + New global node introducing identifier k(23) [kernel] New occurrence of existing identifier k [kernel] tests/syntax/syntactic_hook.i:11: - New global node introducing identifier main(31) + New global node introducing identifier main(29) [kernel] First occurrence of main [kernel] tests/syntax/syntactic_hook.i:13: - New global node introducing identifier t(35) + New global node introducing identifier t(33) [kernel] First occurrence of t [kernel] tests/syntax/syntactic_hook.i:13: Warning: [SH]: definition of local function t -[kernel] :0: New global node introducing identifier g(37) +[kernel] :0: New global node introducing identifier g(35) [kernel] First occurrence of g [kernel:typing:implicit-function-declaration] tests/syntax/syntactic_hook.i:17: Warning: Calling undeclared function g. Old style K&R code? diff --git a/tests/syntax/reorder.i b/tests/syntax/reorder.i index a754b95d776a02a5cbdd5bba66b7b75ab834d7be..a611137930713ae5fbb4db09a2cbefdf59513905 100644 --- a/tests/syntax/reorder.i +++ b/tests/syntax/reorder.i @@ -1,5 +1,6 @@ /* run.config -OPT: -load-script tests/syntax/reorder.ml +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ int x; diff --git a/tests/syntax/syntactic_hook.i b/tests/syntax/syntactic_hook.i index e5c19d372e4d3f7ba2012a42514e35805d4e4d72..d887e89667ec5464d71f2d68e749dfe68465f196 100644 --- a/tests/syntax/syntactic_hook.i +++ b/tests/syntax/syntactic_hook.i @@ -1,7 +1,7 @@ /* run.config - STDOPT: +"-load-script tests/syntax/syntactic_hook.ml" + EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs + STDOPT: +"-no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs" */ - int f(void); int k(int *); diff --git a/tests/syntax/typedef_multi_1.c b/tests/syntax/typedef_multi_1.c index fac8ea328939009b61a97e51f0f01a2d5e03c945..33a8d6c3537a3452d299e6a481c5514bbdb93022 100644 --- a/tests/syntax/typedef_multi_1.c +++ b/tests/syntax/typedef_multi_1.c @@ -1,5 +1,6 @@ /* run.config - OPT: -load-script tests/syntax/typedef_multi.ml tests/syntax/typedef_multi_2.c + EXECNOW: make -s @PTEST_DIR@/typedef_multi.cmxs + OPT: -load-module @PTEST_DIR@/typedef_multi tests/syntax/typedef_multi_2.c */ #include "tests/syntax/typedef_multi.h" diff --git a/tests/syntax/vdescr_bts1387.i b/tests/syntax/vdescr_bts1387.i index 7ef2f74b3ccce4b99ef88b539449c45b24854699..b20b1226bd2c890329ecea47201df49299e8f69b 100644 --- a/tests/syntax/vdescr_bts1387.i +++ b/tests/syntax/vdescr_bts1387.i @@ -1,5 +1,6 @@ /* run.config -OPT: -load-script tests/syntax/vdescr_bts1387.ml +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs */ int f(int); int g(int); diff --git a/tests/syntax/visit_create_local.i b/tests/syntax/visit_create_local.i index 68bfe516292bfea1bbb41bc7327aa4acaf026ad1..6d9a88989bca1c8106862f9bb5dd304b6da357c0 100644 --- a/tests/syntax/visit_create_local.i +++ b/tests/syntax/visit_create_local.i @@ -1,4 +1,5 @@ /* run.config -OPT: -load-script tests/syntax/visit_create_local.ml -then-on bidon -print +EXECNOW: make -s @PTEST_DIR@/@PTEST_NAME@.cmxs +OPT: -no-autoload-plugins -load-module @PTEST_DIR@/@PTEST_NAME@.cmxs -then-on bidon -print */ void main() { int x,y; x = y; }