diff --git a/.gitignore b/.gitignore index e6739e774c8..edac3d3e326 100644 --- a/.gitignore +++ b/.gitignore @@ -31,8 +31,6 @@ src/ansi-c/gcc_builtin_headers_ia32-2.inc src/ansi-c/gcc_builtin_headers_ia32.inc src/ansi-c/gcc_builtin_headers_mips.inc src/ansi-c/gcc_builtin_headers_power.inc -src/util/irep_ids.h -src/util/irep_ids.inc # regression/test files *.out diff --git a/.travis.yml b/.travis.yml index 8c98d3e8e9b..3318b3abe67 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,30 +7,46 @@ matrix: - os: linux sudo: required compiler: gcc + cache: ccache services: - docker before_install: - - docker pull diffblue/cbmc-builder:alpine + - docker pull diffblue/cbmc-builder:alpine-0.0.1 env: - - PRE_COMMAND="docker run -v ${TRAVIS_BUILD_DIR}:/cbmc diffblue/cbmc-builder:alpine" - - COMPILER=g++ + - PRE_COMMAND="docker run -v ${TRAVIS_BUILD_DIR}:/cbmc -v ${HOME}/.ccache:/root/.ccache diffblue/cbmc-builder:alpine-0.0.1" + - COMPILER="ccache g++" # OS X using g++ - os: osx sudo: false compiler: gcc + cache: ccache + before_install: + #we create symlink to non-ccache gcc, to be used in tests + - mkdir bin ; ln -s /usr/bin/gcc bin/gcc + - HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache + - export PATH=/usr/local/opt/ccache/libexec:$PATH + - ccache -M 1G env: COMPILER=g++ # OS X using clang++ - os: osx sudo: false compiler: clang - env: COMPILER=clang++ + cache: ccache + before_install: + - HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache + - export PATH=/usr/local/opt/ccache/libexec:$PATH + - ccache -M 1G + env: + - COMPILER="ccache clang++ -Qunused-arguments -fcolor-diagnostics" + - CCACHE_CPP2=yes # Ubuntu Linux with glibc using g++-5 - os: linux sudo: false compiler: gcc + cache: ccache addons: apt: sources: @@ -42,12 +58,57 @@ matrix: before_install: - mkdir bin ; ln -s /usr/bin/gcc-5 bin/gcc # env: COMPILER=g++-5 SAN_FLAGS="-fsanitize=undefined -fno-sanitize-recover -fno-omit-frame-pointer" - env: COMPILER=g++-5 + env: COMPILER="g++-5" + + # Ubuntu Linux with glibc using g++-5, debug mode + - os: linux + sudo: false + compiler: gcc + cache: ccache + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - libwww-perl + - g++-5 + - libubsan0 + before_install: + - mkdir bin ; ln -s /usr/bin/gcc-5 bin/gcc + # env: COMPILER=g++-5 SAN_FLAGS="-fsanitize=undefined -fno-sanitize-recover -fno-omit-frame-pointer" + env: + - COMPILER="g++-5" + - EXTRA_CXXFLAGS="-DDEBUG" + script: echo "Not running any tests for a debug build." # Ubuntu Linux with glibc using clang++-3.7 - os: linux sudo: false compiler: clang + cache: ccache + addons: + apt: + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.7 + packages: + - libwww-perl + - clang-3.7 + - libstdc++-5-dev + - libubsan0 + before_install: + - mkdir bin ; ln -s /usr/bin/clang-3.7 bin/gcc + - export CCACHE_CPP2=yes + # env: COMPILER=clang++-3.7 SAN_FLAGS="-fsanitize=undefined -fno-sanitize-recover=undefined,integer -fno-omit-frame-pointer" + env: + - COMPILER="ccache clang++-3.7 -Qunused-arguments -fcolor-diagnostics" + - CCACHE_CPP2=yes + + # Ubuntu Linux with glibc using clang++-3.7, debug mode + - os: linux + sudo: false + compiler: clang + cache: ccache addons: apt: sources: @@ -60,25 +121,39 @@ matrix: - libubsan0 before_install: - mkdir bin ; ln -s /usr/bin/clang-3.7 bin/gcc + - export CCACHE_CPP2=yes # env: COMPILER=clang++-3.7 SAN_FLAGS="-fsanitize=undefined -fno-sanitize-recover=undefined,integer -fno-omit-frame-pointer" - env: COMPILER=clang++-3.7 + env: + - COMPILER="ccache clang++-3.7 -Qunused-arguments -fcolor-diagnostics" + - CCACHE_CPP2=yes + - EXTRA_CXXFLAGS="-DDEBUG" + script: echo "Not running any tests for a debug build." - env: NAME="CPP-LINT" - script: scripts/travis_lint.sh || true + install: + script: scripts/travis_lint.sh + before_cache: + + allow_failures: + - env: NAME="CPP-LINT" + install: + script: scripts/travis_lint.sh + before_cache: + +install: + - COMMAND="make -C src minisat2-download" && + eval ${PRE_COMMAND} ${COMMAND} + - COMMAND="make -C src boost-download" && + eval ${PRE_COMMAND} ${COMMAND} + - COMMAND="make -C src CXX=\"$COMPILER\" CXXFLAGS=\"-Wall -O2 -g -Werror -Wno-deprecated-register -pedantic -Wno-sign-compare -DUSE_BOOST $EXTRA_CXXFLAGS\" -j2" && + eval ${PRE_COMMAND} ${COMMAND} + - COMMAND="make -C src CXX=\"$COMPILER\" CXXFLAGS=\"$FLAGS $EXTRA_CXXFLAGS\" -j2 cegis.dir clobber.dir memory-models.dir musketeer.dir" && + eval ${PRE_COMMAND} ${COMMAND} script: - - if [ -L bin/gcc ] ; then export PATH=$PWD/bin:$PATH ; fi ; - COMMAND="make -C src minisat2-download" && - eval ${PRE_COMMAND} ${COMMAND} && - COMMAND="make -C src boost-download" && - eval ${PRE_COMMAND} ${COMMAND} && - COMMAND="make -C src CXX=$COMPILER CXXFLAGS=\"-Wall -O2 -g -Werror -Wno-deprecated-register -pedantic -Wno-sign-compare -DUSE_BOOST\" -j2" && - eval ${PRE_COMMAND} ${COMMAND} && + - if [ -e bin/gcc ] ; then export PATH=$PWD/bin:$PATH ; fi ; COMMAND="env UBSAN_OPTIONS=print_stacktrace=1 make -C regression test" && - eval ${PRE_COMMAND} ${COMMAND} && - COMMAND="make -C src CXX=$COMPILER CXXFLAGS=$FLAGS -j2 cegis.dir clobber.dir memory-models.dir musketeer.dir" && - eval ${PRE_COMMAND} ${COMMAND} && - COMMAND="make -C src clean" && - eval ${PRE_COMMAND} ${COMMAND} && - COMMAND="make -C src CXX=$COMPILER CXXFLAGS=\"-Wall -O0 -ggdb3 -Werror -Wno-deprecated-register -pedantic -Wno-sign-compare -DDEBUG\" -j2" && eval ${PRE_COMMAND} ${COMMAND} + +before_cache: + - ccache -s diff --git a/CHANGELOG b/CHANGELOG index 0f15c3d5081..1718d32243d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,14 @@ +5.8 +=== + +* GOTO-INSTRUMENT: --reachability-slice can be used with --property to slice + down to a single property only. +* GOTO-INSTRUMENT: New option --list-calls-args +* GOTO-INSTRUMENT: New option --print-path-lenghts +* GOTO-ANALYZER: New option --unreachable-functions, --reachable-functions +* GOTO-INSTRUMENT: New option --undefined-function-is-assume-false + + 5.7 === diff --git a/README.md b/README.md index bb1bf51de0a..e1c2b090091 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status][build_img]][travis] +[![Build Status][travis_img]][travis] [![Build Status][appveyor_img]][appveyor] [CProver Wiki](http://www.cprover.org/wiki) @@ -19,5 +19,7 @@ License ======= 4-clause BSD license, see `LICENSE` file. -[build_img]: https://travis-ci.org/diffblue/cbmc.svg?branch=master [travis]: https://travis-ci.org/diffblue/cbmc +[travis_img]: https://travis-ci.org/diffblue/cbmc.svg?branch=master +[appveyor]: https://ci.appveyor.com/project/diffblue/cbmc/ +[appveyor_img]: https://ci.appveyor.com/api/projects/status/github/diffblue/cbmc?svg=true&branch=master \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000000..5f287b193d4 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,110 @@ +version: 1.0.{build} +image: Visual Studio 2013 +clone_depth: 50 +environment: + BUILD_ENV: MSVC + PATH: C:\projects\cbmc\deps\bin;%PATH% + INCLUDE: C:\projects\cbmc\deps\include +install: +- ps: | + #check if dependencies were copied from cache, if not, download them. + if (!(Test-Path deps)) { + md deps + } + cd deps + if (!(Test-Path bin\bison.exe)) { + & appveyor DownloadFile "https://storage.googleapis.com/diffblue-mirror/appveyor-deps/bison-2.4.1-bin.zip?GoogleAccessId=diffbluemaster@diffblue-cr.iam.gserviceaccount.com&Expires=1519839050&Signature=JAPFzNPMJDI4IViAVlJAEc6l8aHB3k17NpZRdoWDMLbALaJNX88vfwocuezU1tfhyrSJxfo2fTK4rgP5OULkikJs7MBZI9ovp2V%2BMT6yg87KDdH9EIOlMgltGfbP%2BoZkwBY7kXb3W5puSlt4OTE%2Bw7CRlHF9MNqFXVBqVBfa%2BGw0gXDe5Jd9qV%2BvUXZzRuBl9ERSQkSD%2B%2B%2BxFo24FZoOeYkgBHJz03%2BHuIMnlmcLgneTB2aiZZU3%2B6UTPceUxLus9%2Bksb5UbqEVaVE06TIXl76VKwqAgXM2LWaNyeJDog%2BT%2BhjW4v4ypxh6mIBo5KRNXVLPc1MxSPFQB3ITlIXv9Zg%3D%3D" + & 7z x bison-2.4.1-bin.zip + } + if (!(Test-Path bin\flex.exe)) { + & appveyor DownloadFile "https://storage.googleapis.com/diffblue-mirror/appveyor-deps/flex-2.5.4a-1-bin.zip?GoogleAccessId=diffbluemaster@diffblue-cr.iam.gserviceaccount.com&Expires=1519839050&Signature=WriP8S047Mmq271ZHWL0MCPGx1gEFsuc%2BKMmChoXhXFRkn0GlIgCxZEiOu52ke9fT1kAvycWXePNBFAyCHjpF%2BJkXCwisQ6FLIf3NL%2F92849YgQKdJkDUOcZ%2Bh82XVTwNBrljKIkExkak7QEyhOf3buTC1oeuatCUV5Ez42RZjgtRiJaqcFW6xLbhfuVONr39KxH5hGx%2FDUi2RRXPbgoKDwavc9s56NP1rNbWMTE6NdNHzJeaf43E%2BSMemlVO%2BhhIY6W0f%2FtaQ7fYF%2F6YaqxdQ0sB8W5DnG4Hb%2F0CyQlrTZpGDXGr301rV0M4WBkYLmfauq4IyJsBaR095tXGW%2BzmA%3D%3D" + & 7z x flex-2.5.4a-1-bin.zip + } + if (!(Test-Path include\FlexLexer.h)) { + & appveyor DownloadFile "https://storage.googleapis.com/diffblue-mirror/appveyor-deps/flex-2.5.4a-1-lib.zip?GoogleAccessId=diffbluemaster@diffblue-cr.iam.gserviceaccount.com&Expires=1519839050&Signature=H%2FLeKGv2QqKAGDTP%2F6TYPhDzuL6K%2F5dFOt61HfYBm1vUWVUNmAYVGvUAcvnUqBnhEHwZgtc8vZt1H7k3W8azxCUc7l6ZhlCDbqQ6Mg2VhfpBaQMbL1V%2BjSq5ePpWcuLMBntKk2br38PF1NtiAwCCpRTRPptaYPeGs%2BOjAH%2BN8aIIxjvj45QAgt9mcg6dfBsyfj5fdJmpHRQFuJ7%2FnsG50fmN5JDvdvmBWloB6rjxVWaN4XO6VTWZFZ34JWFyOqgWNEw9aDN3HdsSuJ0Uz19AbdwZBIWe5Elrl71rRJjn1lijCknDB7D4sAmP33k71e%2BB0qvsNl1Shuh9FkY8Z6y05Q%3D%3D" + & 7z x flex-2.5.4a-1-lib.zip + } + if (!(Test-Path bin\iconv.exe)) { + & appveyor DownloadFile "https://storage.googleapis.com/diffblue-mirror/appveyor-deps/libiconv-1.9.2-1-bin.zip?GoogleAccessId=diffbluemaster@diffblue-cr.iam.gserviceaccount.com&Expires=1519839050&Signature=sS3Y2lC1oWOhBDsL8C9ASuO4LOM%2BpB%2F8PwG5w5CdB9JnPfLqhb3FnA1zkkZJoSNuIYS3DM6CN2qxoWjpJbLEtVQe0PpxziQZjLpJw2MpxXdJiJHRDu8x9THgzwuZ3ze5BWHzPoCBQPdRkKzVPezf1HwptUsm3Y9c2jlWljQjhc8NVsI4iPmjEOwT8E%2BYpR5fsLs2GsRjuoyqKa%2Bi4JJ6MbpXVX1IgR4fzp1Li9SnE39ujHDb%2FyI3c96eCdVm1Oa6jNxzSJNfq%2FgOZM8BIxlR55a%2BtM3oBQhU0voEtDOABwuO7ZBay8dLt%2FG5vz1%2Bi%2FIlRLFxQfICaprPLzw6pXRm8Q%3D%3D" + & 7z x libiconv-1.9.2-1-bin.zip + } + if (!(Test-Path bin\libintl3.dll)) { + & appveyor DownloadFile "https://storage.googleapis.com/diffblue-mirror/appveyor-deps/libintl-0.14.4-bin.zip?GoogleAccessId=diffbluemaster@diffblue-cr.iam.gserviceaccount.com&Expires=1519839050&Signature=lJViGr6bl%2F4i%2B6nIfeYChreq%2FKfgid9QqGSq7Ie%2FMG%2Fmr9nPyPUA%2BLtT7jn1ogunTzQLZP%2FNxVFcYqyd8gyuT%2Bn2MF80Ds4Whw4cRYnXPb2LZg4%2FiEqZV6wgBMIQfq5v2l3lAsglISVErOik%2BQAHec5gZe2%2BKaVjRnJnhPRziZkQyzF9Xdf2xsPi28hBaX4RQx8XqSLcY1kQpY13PDBZDi9lmdKHf0pBKu%2F0WXspmRAU02HtleMk6Zeg5vEDFcwoe8C3fb4vwtpwGwN9TX5ddaq56yUVn70zh%2BH2KgKIsRl26avnrCpeWF9M5lLck0ngaqFX84w%2BgxmZu40IVU%2Ff0A%3D%3D" + & 7z x libintl-0.14.4-bin.zip + } + if (!(Test-Path bin\make.exe)) { + & appveyor DownloadFile "https://storage.googleapis.com/diffblue-mirror/appveyor-deps/make-3.81-bin.zip?GoogleAccessId=diffbluemaster@diffblue-cr.iam.gserviceaccount.com&Expires=1519839050&Signature=PRC97AWzJ2ZAyjEK4p7eCbA3RAEr8sTf8TUK5zoMBcrXPUHWYjnCwXRMnIxUUufBYjsAx8t1XnOQdlTuAPJYpcha%2FFJRlcxMmfQjNbpNEQFJuqEpA5c%2FGhFYxSD3a26vjpgReUW5MuQXeLeNh7PziLB0GP0sdRHN%2B1eDiHeCJWYNMYhrEY9BAkf5rXeRQWr1ZG0Hzq%2FxZEHceypx8xyaT%2BFzREYQOyKjGdre1QXtI%2FXo4ImA1xWt%2F8TnlGcAnCEaTltxuSRVB%2F7s1ShMr9KoagCb%2BjBWq6BgbcNGxyzyOZfi2Sjjo39mhudF9DNbKbkczes9Kp3ySgXmrXSWjIG4Iw%3D%3D" + & 7z x make-3.81-bin.zip + } + if (!(Test-Path bin\regex2.dll)) { + & appveyor DownloadFile "https://storage.googleapis.com/diffblue-mirror/appveyor-deps/regex-2.7-bin.zip?GoogleAccessId=diffbluemaster@diffblue-cr.iam.gserviceaccount.com&Expires=1519839050&Signature=bXRvFV%2Be4Dpm8vzp%2F1bJWwgkERE6WakcPTBN57n9vNh0dr42jDTXv8JF%2BWCmTIb%2Fy4XzxYl0faggt3g6TqTLYn5UDVUBYx%2FMLmNVVNEv%2BaBlDd87UAZGLi6fkEV5oAP4W4FYsqEnKRDfGPOBoL7D7CuW9Kcxy3Moubxdl%2Bmes%2BMI%2FzWJ6BgLD3Oj04GyD42zLCYVtAzkeDAX0UADoh06ExhpTjI4BNnQ%2FhzSlPtPG7mon4q81%2F2tDNskKVJS466eR%2F8XV6H4QT3LoCkh6dxQ9%2B9ZnkWJplundRbiIlpj43vmdvjIChczl4jbAgL6zFj5Gz6u58uvCV%2FbOuyx3Sw1fg%3D%3D" + & 7z x regex-2.7-bin.zip + } + if (!(Test-Path minisat2-2.2.1)) { + & appveyor DownloadFile http://ftp.debian.org/debian/pool/main/m/minisat2/minisat2_2.2.1.orig.tar.gz + & 7z x minisat2_2.2.1.orig.tar.gz + &7z x minisat2_2.2.1.orig.tar + } + cd .. + +cache: deps + +build_script: +- cmd: | + cp -r deps/minisat2-2.2.1 minisat-2.2.1 + patch -d minisat-2.2.1 -p1 < scripts/minisat-2.2.1-patch + call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x64 + sed -i "s/BUILD_ENV.*/BUILD_ENV = MSVC/" src/config.inc + make -C src -j2 + +test_script: +- cmd: | + cd regression + sed -i "s/goto-cc\/goto-cc/goto-cc\/goto-cl/" ansi-c/Makefile + sed -i "s/goto-cc\/goto-cc/goto-cc\/goto-cl/" cpp/Makefile + sed -i "s/goto-cc\/goto-cc/goto-cc\/goto-cl/" goto-instrument/chain.sh + sed -i "15s/.*/$goto_cc $name.c/" goto-instrument/chain.sh + sed -i "16i mv $name.exe $name.gb" goto-instrument/chain.sh + sed -i "23s/.*/ $goto_cc ${name}-mod.c/" goto-instrument/chain.sh + sed -i "24i mv ${name}-mod.exe $name-mod.gb" goto-instrument/chain.sh + cat goto-instrument/chain.sh + + sed -i "s/goto-cc\/goto-cc/goto-cc\/goto-cl/" goto-instrument-typedef/chain.sh || true + sed -i "12s/.*/$GC $NAME.c --function fun/" goto-instrument-typedef/chain.sh || true + sed -i "13i mv $NAME.exe $NAME.gb" goto-instrument-typedef/chain.sh || true + cat goto-instrument-typedef/chain.sh || true + + rem HACK disable failing tests + rmdir /s /q ansi-c\Forward_Declaration2 + rmdir /s /q ansi-c\Incomplete_Type1 + rmdir /s /q ansi-c\Union_Padding1 + rmdir /s /q ansi-c\Universal_characters1 + rmdir /s /q ansi-c\function_return1 + rmdir /s /q ansi-c\gcc_attributes7 + rmdir /s /q ansi-c\struct6 + rmdir /s /q ansi-c\struct7 + rmdir /s /q cbmc\Malloc23 + rmdir /s /q cbmc\byte_update2 + rmdir /s /q cbmc\byte_update3 + rmdir /s /q cbmc\byte_update4 + rmdir /s /q cbmc\byte_update5 + rmdir /s /q cbmc\byte_update6 + rmdir /s /q cbmc\byte_update7 + rmdir /s /q cbmc\pipe1 + rmdir /s /q cbmc\unsigned___int128 + rmdir /s /q cpp\Decltype1 + rmdir /s /q cpp\Decltype2 + rmdir /s /q cpp\Function_Overloading1 + rmdir /s /q cpp\enum2 + rmdir /s /q cpp\enum7 + rmdir /s /q cpp\enum8 + rmdir /s /q cpp\nullptr1 + rmdir /s /q cpp\sizeof1 + rmdir /s /q cpp\static_assert1 + rmdir /s /q cbmc-java\VarLengthArrayTrace1 + rmdir /s /q cbmc-java\classpath1 + rmdir /s /q cbmc-java\jar-file3 + rmdir /s /q cbmc-java\tableswitch2 + rmdir /s /q goto-instrument\slice08 + + make test diff --git a/regression/Makefile b/regression/Makefile index 5c59fd6e34c..296f583cc5e 100644 --- a/regression/Makefile +++ b/regression/Makefile @@ -5,6 +5,7 @@ DIRS = ansi-c \ cbmc-java \ goto-analyzer \ goto-instrument \ + goto-instrument-typedef \ test-script \ # Empty last line diff --git a/regression/acceleration/Makefile b/regression/acceleration/Makefile index 396fa63f22d..805ebaec1e8 100644 --- a/regression/acceleration/Makefile +++ b/regression/acceleration/Makefile @@ -14,5 +14,5 @@ show: done; clean: - rm -f tests.log - rm -f */main.out + $(RM) tests.log + $(RM) */main.out diff --git a/regression/acceleration/array_unsafe1/test.desc b/regression/acceleration/array_unsafe1/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/array_unsafe1/test.desc +++ b/regression/acceleration/array_unsafe1/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/array_unsafe2/test.desc b/regression/acceleration/array_unsafe2/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/array_unsafe2/test.desc +++ b/regression/acceleration/array_unsafe2/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/array_unsafe3/test.desc b/regression/acceleration/array_unsafe3/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/array_unsafe3/test.desc +++ b/regression/acceleration/array_unsafe3/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/array_unsafe4/test.desc b/regression/acceleration/array_unsafe4/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/array_unsafe4/test.desc +++ b/regression/acceleration/array_unsafe4/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/const_unsafe1/test.desc b/regression/acceleration/const_unsafe1/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/const_unsafe1/test.desc +++ b/regression/acceleration/const_unsafe1/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/diamond_unsafe1/test.desc b/regression/acceleration/diamond_unsafe1/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/diamond_unsafe1/test.desc +++ b/regression/acceleration/diamond_unsafe1/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/diamond_unsafe2/test.desc b/regression/acceleration/diamond_unsafe2/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/diamond_unsafe2/test.desc +++ b/regression/acceleration/diamond_unsafe2/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/functions_unsafe1/test.desc b/regression/acceleration/functions_unsafe1/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/functions_unsafe1/test.desc +++ b/regression/acceleration/functions_unsafe1/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/multivar_unsafe1/test.desc b/regression/acceleration/multivar_unsafe1/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/multivar_unsafe1/test.desc +++ b/regression/acceleration/multivar_unsafe1/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/nested_unsafe1/test.desc b/regression/acceleration/nested_unsafe1/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/nested_unsafe1/test.desc +++ b/regression/acceleration/nested_unsafe1/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/overflow_unsafe1/test.desc b/regression/acceleration/overflow_unsafe1/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/overflow_unsafe1/test.desc +++ b/regression/acceleration/overflow_unsafe1/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/phases_unsafe1/test.desc b/regression/acceleration/phases_unsafe1/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/phases_unsafe1/test.desc +++ b/regression/acceleration/phases_unsafe1/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/simple_unsafe1/test.desc b/regression/acceleration/simple_unsafe1/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/simple_unsafe1/test.desc +++ b/regression/acceleration/simple_unsafe1/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/simple_unsafe2/test.desc b/regression/acceleration/simple_unsafe2/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/simple_unsafe2/test.desc +++ b/regression/acceleration/simple_unsafe2/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/simple_unsafe3/test.desc b/regression/acceleration/simple_unsafe3/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/simple_unsafe3/test.desc +++ b/regression/acceleration/simple_unsafe3/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/acceleration/simple_unsafe4/test.desc b/regression/acceleration/simple_unsafe4/test.desc index 200554d997b..e6fe08aeb20 100644 --- a/regression/acceleration/simple_unsafe4/test.desc +++ b/regression/acceleration/simple_unsafe4/test.desc @@ -1,7 +1,6 @@ CORE main.c --no-unwinding-assertions - ^EXIT=10$ ^SIGNAL=0$ ^VERIFICATION FAILED$ diff --git a/regression/ansi-c/Makefile b/regression/ansi-c/Makefile index b03e120015b..87af55e3306 100644 --- a/regression/ansi-c/Makefile +++ b/regression/ansi-c/Makefile @@ -18,3 +18,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/ansi-c/gcc_types_compatible_p1/main.c b/regression/ansi-c/gcc_types_compatible_p1/main.c index 403596c4276..4f327d51085 100644 --- a/regression/ansi-c/gcc_types_compatible_p1/main.c +++ b/regression/ansi-c/gcc_types_compatible_p1/main.c @@ -7,6 +7,14 @@ double d; typedef enum T1 { hot, dog, poo, bear } dingos; typedef enum T2 { janette, laura, amanda } cranberry; +typedef enum AnonEnum { jim, bob, fred } names; + +typedef dingos altdingos; +typedef dingos diffdingos; + +typedef names altnames; +typedef names diffnames; + typedef float same1; typedef float same2; @@ -52,6 +60,9 @@ STATIC_ASSERT(__builtin_types_compatible_p(typeof (dingos), unsigned)); // ha! STATIC_ASSERT(__builtin_types_compatible_p(typeof (hot), typeof (laura))); STATIC_ASSERT(__builtin_types_compatible_p(int[5], int[])); STATIC_ASSERT(__builtin_types_compatible_p(same1, same2)); +STATIC_ASSERT(__builtin_types_compatible_p(dingos, altdingos)); +STATIC_ASSERT(__builtin_types_compatible_p(diffdingos, altdingos)); +STATIC_ASSERT(__builtin_types_compatible_p(diffnames, altnames)); STATIC_ASSERT(__builtin_types_compatible_p(typeof (hot) *, int *)); STATIC_ASSERT(__builtin_types_compatible_p(typeof (hot), typeof (janette))); STATIC_ASSERT(__builtin_types_compatible_p(__int128, signed __int128)); @@ -84,7 +95,6 @@ STATIC_ASSERT(!__builtin_types_compatible_p(__float128, long double)); STATIC_ASSERT(!__builtin_types_compatible_p(__float128, double)); STATIC_ASSERT(!__builtin_types_compatible_p(__int128, unsigned __int128)); #endif - #endif int main(void) diff --git a/regression/ansi-c/gcc_types_compatible_p4/main.c b/regression/ansi-c/gcc_types_compatible_p4/main.c new file mode 100644 index 00000000000..69b84a8304b --- /dev/null +++ b/regression/ansi-c/gcc_types_compatible_p4/main.c @@ -0,0 +1,27 @@ +#define STATIC_ASSERT(condition) \ + int some_array[(condition) ? 1 : -1]; + +typedef struct struct_tag +{ + int x; + float y; +} struct_typedef; + +typedef struct struct_tag alt_typedef; +typedef struct_typedef another_typedef; + +#ifdef __GNUC__ + + +STATIC_ASSERT(__builtin_types_compatible_p(struct struct_tag, struct_typedef)); +STATIC_ASSERT(__builtin_types_compatible_p(struct struct_tag, alt_typedef)); +STATIC_ASSERT(__builtin_types_compatible_p(struct struct_tag, another_typedef)); +STATIC_ASSERT(__builtin_types_compatible_p(struct_typedef, alt_typedef)); +STATIC_ASSERT(__builtin_types_compatible_p(struct_typedef, another_typedef)); +STATIC_ASSERT(__builtin_types_compatible_p(alt_typedef, another_typedef)); + +#endif + +int main(void) +{ +} diff --git a/regression/ansi-c/gcc_types_compatible_p4/test.desc b/regression/ansi-c/gcc_types_compatible_p4/test.desc new file mode 100644 index 00000000000..466da18b2b5 --- /dev/null +++ b/regression/ansi-c/gcc_types_compatible_p4/test.desc @@ -0,0 +1,8 @@ +CORE +main.c + +^EXIT=0$ +^SIGNAL=0$ +-- +^warning: ignoring +^CONVERSION ERROR$ diff --git a/regression/ansi-c/static_inline1/test.desc b/regression/ansi-c/static_inline1/test.desc index 5717777037a..52168c7eba4 100644 --- a/regression/ansi-c/static_inline1/test.desc +++ b/regression/ansi-c/static_inline1/test.desc @@ -4,6 +4,5 @@ main.c ^EXIT=0$ ^SIGNAL=0$ ^VERIFICATION SUCCESSFUL$ - -- ^warning: ignoring diff --git a/regression/ansi-c/static_inline2/test.desc b/regression/ansi-c/static_inline2/test.desc index c5c5692745d..6a006f47021 100644 --- a/regression/ansi-c/static_inline2/test.desc +++ b/regression/ansi-c/static_inline2/test.desc @@ -4,6 +4,5 @@ main.c ^EXIT=0$ ^SIGNAL=0$ ^VERIFICATION SUCCESSFUL$ - -- ^warning: ignoring diff --git a/regression/array-refinement-with-incr/Makefile b/regression/array-refinement-with-incr/Makefile index 579de53f6c3..67153d5df71 100644 --- a/regression/array-refinement-with-incr/Makefile +++ b/regression/array-refinement-with-incr/Makefile @@ -14,3 +14,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/array-refinement/Makefile b/regression/array-refinement/Makefile index 41e06e86158..0fd2a56b6f6 100644 --- a/regression/array-refinement/Makefile +++ b/regression/array-refinement/Makefile @@ -14,3 +14,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/cbmc-concurrency/Makefile b/regression/cbmc-concurrency/Makefile index f40172c17a2..bf0682a5381 100644 --- a/regression/cbmc-concurrency/Makefile +++ b/regression/cbmc-concurrency/Makefile @@ -12,3 +12,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/cbmc-cover/Makefile b/regression/cbmc-cover/Makefile index cbdd3378bac..9a14abc905f 100644 --- a/regression/cbmc-cover/Makefile +++ b/regression/cbmc-cover/Makefile @@ -18,3 +18,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/cbmc-cpp/Makefile b/regression/cbmc-cpp/Makefile index f40172c17a2..bf0682a5381 100644 --- a/regression/cbmc-cpp/Makefile +++ b/regression/cbmc-cpp/Makefile @@ -12,3 +12,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/cbmc-from-CVS/Makefile b/regression/cbmc-from-CVS/Makefile index f40172c17a2..bf0682a5381 100644 --- a/regression/cbmc-from-CVS/Makefile +++ b/regression/cbmc-from-CVS/Makefile @@ -12,3 +12,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/cbmc-incr-oneloop/Makefile b/regression/cbmc-incr-oneloop/Makefile index 4c5b7ceffd3..00c5ea25db4 100644 --- a/regression/cbmc-incr-oneloop/Makefile +++ b/regression/cbmc-incr-oneloop/Makefile @@ -14,5 +14,5 @@ show: done; clean: - @rm -f *.log - @(for dir in *; do rm -f $$dir/*.out; done;) + @$(RM) *.log + @(for dir in *; do $(RM) $$dir/*.out; done;) diff --git a/regression/cbmc-incr-oneloop/unwind-forever1/test.desc b/regression/cbmc-incr-oneloop/unwind-forever1/test.desc index 617547e56ad..5d03502707e 100644 --- a/regression/cbmc-incr-oneloop/unwind-forever1/test.desc +++ b/regression/cbmc-incr-oneloop/unwind-forever1/test.desc @@ -3,6 +3,5 @@ main.c --incremental-check main.0 ^EXIT=142$ ^SIGNAL=0$ - -- ^warning: ignoring diff --git a/regression/cbmc-incr-oneloop/unwind-forever2/test.desc b/regression/cbmc-incr-oneloop/unwind-forever2/test.desc index bff68c7e0c8..920f3890da5 100644 --- a/regression/cbmc-incr-oneloop/unwind-forever2/test.desc +++ b/regression/cbmc-incr-oneloop/unwind-forever2/test.desc @@ -3,6 +3,5 @@ main.c --incremental-check main.0 ^EXIT=142$ ^SIGNAL=0$ - -- ^warning: ignoring diff --git a/regression/cbmc-incr/Makefile b/regression/cbmc-incr/Makefile index 965ce493fc5..08b694ea9b5 100644 --- a/regression/cbmc-incr/Makefile +++ b/regression/cbmc-incr/Makefile @@ -17,5 +17,5 @@ show: done; clean: - @rm -f *.log - @(for dir in *; do rm -f $$dir/*.out; done;) + @$(RM) *.log + @(for dir in *; do $(RM) $$dir/*.out; done;) diff --git a/regression/cbmc-java/Makefile b/regression/cbmc-java/Makefile index cee83cba67a..a1b44c5a948 100644 --- a/regression/cbmc-java/Makefile +++ b/regression/cbmc-java/Makefile @@ -18,3 +18,8 @@ show: vim -o "$$dir/*.java" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/cbmc-java/classpath2/jarfile3$A.class b/regression/cbmc-java/classpath2/jarfile3$A.class new file mode 100644 index 00000000000..22a9c4c39f9 Binary files /dev/null and b/regression/cbmc-java/classpath2/jarfile3$A.class differ diff --git a/regression/cbmc-java/classpath2/jarfile3$B.class b/regression/cbmc-java/classpath2/jarfile3$B.class new file mode 100644 index 00000000000..11284e5ebe1 Binary files /dev/null and b/regression/cbmc-java/classpath2/jarfile3$B.class differ diff --git a/regression/cbmc-java/classpath2/jarfile3.class b/regression/cbmc-java/classpath2/jarfile3.class new file mode 100644 index 00000000000..ececc4cc305 Binary files /dev/null and b/regression/cbmc-java/classpath2/jarfile3.class differ diff --git a/regression/cbmc-java/classpath2/jarfile3.java b/regression/cbmc-java/classpath2/jarfile3.java new file mode 100644 index 00000000000..c9c0cff46d1 --- /dev/null +++ b/regression/cbmc-java/classpath2/jarfile3.java @@ -0,0 +1,19 @@ +public class jarfile3 +{ + public class A + { + int x=1; + } + public class B + { + int x=1; + } + + void f(int i) + { + A a=new A(); + B b=new B(); + assert(a.x==1); + assert(b.x==1); + } +} diff --git a/regression/cbmc-java/classpath2/test.desc b/regression/cbmc-java/classpath2/test.desc new file mode 100644 index 00000000000..ba3ea35b785 --- /dev/null +++ b/regression/cbmc-java/classpath2/test.desc @@ -0,0 +1,10 @@ +CORE +jarfile3.class +--function jarfile3.f --java-cp-include-files "jarfile3\.class" +^EXIT=10$ +^SIGNAL=0$ +.*SUCCESS$ +.*FAILURE$ +^VERIFICATION FAILED +-- +^warning: ignoring diff --git a/regression/cbmc-java/exceptions1/test.desc b/regression/cbmc-java/exceptions1/test.desc index 638351f4397..1405444f649 100644 --- a/regression/cbmc-java/exceptions1/test.desc +++ b/regression/cbmc-java/exceptions1/test.desc @@ -4,7 +4,7 @@ test.class ^EXIT=10$ ^SIGNAL=0$ ^.*assertion at file test.java line 26 function.*: FAILURE$ -\*\* 1 of 9 failed \(2 iterations\)$ +\*\* 1 of [0-9]* failed \(2 iterations\)$ ^VERIFICATION FAILED$ -- ^warning: ignoring diff --git a/regression/cbmc-java/exceptions2/test.desc b/regression/cbmc-java/exceptions2/test.desc index 8645e5ea074..724e37b0677 100644 --- a/regression/cbmc-java/exceptions2/test.desc +++ b/regression/cbmc-java/exceptions2/test.desc @@ -4,7 +4,7 @@ test.class ^EXIT=10$ ^SIGNAL=0$ ^.*assertion at file test.java line 15 function.*: FAILURE$ -^\*\* 1 of 5 failed \(2 iterations\)$ +^\*\* 1 of [0-9]* failed \(2 iterations\)$ ^VERIFICATION FAILED$ -- ^warning: ignoring diff --git a/regression/cbmc-java/lazyloading3/A.class b/regression/cbmc-java/lazyloading3/A.class index affb565d625..3c3c1f09997 100644 Binary files a/regression/cbmc-java/lazyloading3/A.class and b/regression/cbmc-java/lazyloading3/A.class differ diff --git a/regression/cbmc-java/lazyloading3/B.class b/regression/cbmc-java/lazyloading3/B.class index 9a4ab54d369..092984f5b11 100644 Binary files a/regression/cbmc-java/lazyloading3/B.class and b/regression/cbmc-java/lazyloading3/B.class differ diff --git a/regression/cbmc-java/lazyloading3/C.class b/regression/cbmc-java/lazyloading3/C.class index c249e24ace4..ba5fbcb0c55 100644 Binary files a/regression/cbmc-java/lazyloading3/C.class and b/regression/cbmc-java/lazyloading3/C.class differ diff --git a/regression/cbmc-java/lazyloading3/D.class b/regression/cbmc-java/lazyloading3/D.class index 7e16bd6527d..33579be8902 100644 Binary files a/regression/cbmc-java/lazyloading3/D.class and b/regression/cbmc-java/lazyloading3/D.class differ diff --git a/regression/cbmc-java/lazyloading3/test.class b/regression/cbmc-java/lazyloading3/test.class index 8e470f64650..5df466fc9ea 100644 Binary files a/regression/cbmc-java/lazyloading3/test.class and b/regression/cbmc-java/lazyloading3/test.class differ diff --git a/regression/cbmc-java/lazyloading3/test.java b/regression/cbmc-java/lazyloading3/test.java index 6d3129d1261..f69a9898472 100644 --- a/regression/cbmc-java/lazyloading3/test.java +++ b/regression/cbmc-java/lazyloading3/test.java @@ -5,6 +5,8 @@ public class test { public static void main(C c) { + if(c==null) + return; c.a.f(); } } diff --git a/regression/cbmc-java/tableswitch2/test.desc b/regression/cbmc-java/tableswitch2/test.desc index b9e08d5d49b..baee77bb8e9 100644 --- a/regression/cbmc-java/tableswitch2/test.desc +++ b/regression/cbmc-java/tableswitch2/test.desc @@ -1,7 +1,6 @@ CORE table_switch_neg_offset.class --function table_switch_neg_offset.f - ^EXIT=0$ ^SIGNAL=0$ ^VERIFICATION SUCCESSFUL$ diff --git a/regression/cbmc-with-incr/Makefile b/regression/cbmc-with-incr/Makefile index 4ab60f487d0..4389f3bb8ef 100644 --- a/regression/cbmc-with-incr/Makefile +++ b/regression/cbmc-with-incr/Makefile @@ -14,5 +14,5 @@ show: done; clean: - @rm -f *.log - @for dir in *; do rm -f $$dir/*.out; done; + @$(RM) *.log + @for dir in *; do $(RM) $$dir/*.out; done; diff --git a/regression/cbmc/Makefile b/regression/cbmc/Makefile index cbdd3378bac..9a14abc905f 100644 --- a/regression/cbmc/Makefile +++ b/regression/cbmc/Makefile @@ -18,3 +18,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/cbmc/graphml_witness1/test.desc b/regression/cbmc/graphml_witness1/test.desc index bfd4cf4f3f4..cb22eaba5d0 100644 --- a/regression/cbmc/graphml_witness1/test.desc +++ b/regression/cbmc/graphml_witness1/test.desc @@ -49,7 +49,7 @@ main.c true - + main.c 21 diff --git a/regression/cbmc/typedef-anon-struct1/main.c b/regression/cbmc/typedef-anon-struct1/main.c new file mode 100644 index 00000000000..d1e7196a3b1 --- /dev/null +++ b/regression/cbmc/typedef-anon-struct1/main.c @@ -0,0 +1,11 @@ + +typedef struct +{ + int x; + float y; +} MYSTRUCT; + +void fun() +{ + MYSTRUCT mystruct_var = {.x = 3, .y = 2.1f}; +} diff --git a/regression/cbmc/typedef-anon-struct1/test.desc b/regression/cbmc/typedef-anon-struct1/test.desc new file mode 100644 index 00000000000..d9d9769f677 --- /dev/null +++ b/regression/cbmc/typedef-anon-struct1/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-anon-struct2/main.c b/regression/cbmc/typedef-anon-struct2/main.c new file mode 100644 index 00000000000..35475513f7d --- /dev/null +++ b/regression/cbmc/typedef-anon-struct2/main.c @@ -0,0 +1,11 @@ + +typedef struct +{ + int x; + float y; +} MYSTRUCT; + +void fun() +{ + MYSTRUCT mystruct_var = {.x = 10, .y = 3.1f}, another_mystruct_var = {.x = 3, .y = 2.1f}; +} diff --git a/regression/cbmc/typedef-anon-struct2/test.desc b/regression/cbmc/typedef-anon-struct2/test.desc new file mode 100644 index 00000000000..83af4f59a9f --- /dev/null +++ b/regression/cbmc/typedef-anon-struct2/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT +Base name\.+: another_mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-anon-union1/main.c b/regression/cbmc/typedef-anon-union1/main.c new file mode 100644 index 00000000000..9322c77cb6e --- /dev/null +++ b/regression/cbmc/typedef-anon-union1/main.c @@ -0,0 +1,11 @@ + +typedef union +{ + int x; + float y; +} MYUNION; + +void fun() +{ + MYUNION myunion_var = {.y = 2.1f}; +} diff --git a/regression/cbmc/typedef-anon-union1/test.desc b/regression/cbmc/typedef-anon-union1/test.desc new file mode 100644 index 00000000000..6f74f9f5574 --- /dev/null +++ b/regression/cbmc/typedef-anon-union1/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: myunion_var\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring diff --git a/regression/cbmc/typedef-anon-union2/main.c b/regression/cbmc/typedef-anon-union2/main.c new file mode 100644 index 00000000000..b2dd6594432 --- /dev/null +++ b/regression/cbmc/typedef-anon-union2/main.c @@ -0,0 +1,11 @@ + +typedef union +{ + int x; + float y; +} MYUNION; + +void fun() +{ + MYUNION myunion_var = {.y = 2.1f}, another_myunion_var = {.y = 2.1f}; +} diff --git a/regression/cbmc/typedef-anon-union2/test.desc b/regression/cbmc/typedef-anon-union2/test.desc new file mode 100644 index 00000000000..f5242dc7ac7 --- /dev/null +++ b/regression/cbmc/typedef-anon-union2/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: myunion_var\nMode\.+: C\nType\.+: MYUNION +Base name\.+: another_myunion_var\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring diff --git a/regression/cbmc/typedef-const-struct1/main.c b/regression/cbmc/typedef-const-struct1/main.c new file mode 100644 index 00000000000..ab8137e82e4 --- /dev/null +++ b/regression/cbmc/typedef-const-struct1/main.c @@ -0,0 +1,12 @@ + +typedef struct tag_struct_name +{ + int x; + float y; +} MYSTRUCT; + +void fun() +{ + const struct tag_struct_name tag_struct_var = {.x = 1, .y = 3.14f}; + const MYSTRUCT mystruct_var = {.x = 3, .y = 2.1f}; +} diff --git a/regression/cbmc/typedef-const-struct1/test.desc b/regression/cbmc/typedef-const-struct1/test.desc new file mode 100644 index 00000000000..f6c2d8e4b48 --- /dev/null +++ b/regression/cbmc/typedef-const-struct1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_struct_var\nMode\.+: C\nType\.+: const struct tag_struct_name +Base name\.+: mystruct_var\nMode\.+: C\nType\.+: const MYSTRUCT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-const-type1/main.c b/regression/cbmc/typedef-const-type1/main.c new file mode 100644 index 00000000000..8cd4a4346eb --- /dev/null +++ b/regression/cbmc/typedef-const-type1/main.c @@ -0,0 +1,8 @@ + +typedef int MYINT; + +void fun() +{ + const int int_var = 3; + const MYINT myint_var = 5; +} diff --git a/regression/cbmc/typedef-const-type1/test.desc b/regression/cbmc/typedef-const-type1/test.desc new file mode 100644 index 00000000000..0e1b67ce3da --- /dev/null +++ b/regression/cbmc/typedef-const-type1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_var\nMode\.+: C\nType\.+: const signed int +Base name\.+: myint_var\nMode\.+: C\nType\.+: const MYINT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-const-union1/main.c b/regression/cbmc/typedef-const-union1/main.c new file mode 100644 index 00000000000..b8defe635a6 --- /dev/null +++ b/regression/cbmc/typedef-const-union1/main.c @@ -0,0 +1,12 @@ + +typedef union tag_union_name +{ + int x; + float y; +} MYUNION; + +void fun() +{ + const union tag_union_name tag_union_var = {1}; + const MYUNION myunion_var = {.y = 2.1f}; +} diff --git a/regression/cbmc/typedef-const-union1/test.desc b/regression/cbmc/typedef-const-union1/test.desc new file mode 100644 index 00000000000..019a6551911 --- /dev/null +++ b/regression/cbmc/typedef-const-union1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_union_var\nMode\.+: C\nType\.+: const union tag_union_name +Base name\.+: myunion_var\nMode\.+: C\nType\.+: const MYUNION +-- +warning: ignoring diff --git a/regression/cbmc/typedef-param-anon-struct1/main.c b/regression/cbmc/typedef-param-anon-struct1/main.c new file mode 100644 index 00000000000..e8f3fb8fd7c --- /dev/null +++ b/regression/cbmc/typedef-param-anon-struct1/main.c @@ -0,0 +1,11 @@ + +typedef struct +{ + int x; + float y; +} MYSTRUCT; + +void fun(MYSTRUCT mystruct_param) +{ + +} diff --git a/regression/cbmc/typedef-param-anon-struct1/test.desc b/regression/cbmc/typedef-param-anon-struct1/test.desc new file mode 100644 index 00000000000..1d7c939008a --- /dev/null +++ b/regression/cbmc/typedef-param-anon-struct1/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: mystruct_param\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-param-anon-union1/main.c b/regression/cbmc/typedef-param-anon-union1/main.c new file mode 100644 index 00000000000..71791d9adfc --- /dev/null +++ b/regression/cbmc/typedef-param-anon-union1/main.c @@ -0,0 +1,10 @@ + +typedef union +{ + int x; + float y; +} MYUNION; + +void fun(MYUNION myunion_param) +{ +} diff --git a/regression/cbmc/typedef-param-anon-union1/test.desc b/regression/cbmc/typedef-param-anon-union1/test.desc new file mode 100644 index 00000000000..34c29cefda9 --- /dev/null +++ b/regression/cbmc/typedef-param-anon-union1/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: myunion_param\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring diff --git a/regression/cbmc/typedef-param-struct1/main.c b/regression/cbmc/typedef-param-struct1/main.c new file mode 100644 index 00000000000..a358c15a030 --- /dev/null +++ b/regression/cbmc/typedef-param-struct1/main.c @@ -0,0 +1,10 @@ + +typedef struct tag_struct_name +{ + int x; + float y; +} MYSTRUCT; + +void fun(struct tag_struct_name tag_struct_param, MYSTRUCT mystruct_param) +{ +} diff --git a/regression/cbmc/typedef-param-struct1/test.desc b/regression/cbmc/typedef-param-struct1/test.desc new file mode 100644 index 00000000000..ad0d23ed7a9 --- /dev/null +++ b/regression/cbmc/typedef-param-struct1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_struct_param\nMode\.+: C\nType\.+: struct tag_struct_name +Base name\.+: mystruct_param\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-param-type1/main.c b/regression/cbmc/typedef-param-type1/main.c new file mode 100644 index 00000000000..b4c915066b6 --- /dev/null +++ b/regression/cbmc/typedef-param-type1/main.c @@ -0,0 +1,7 @@ + +typedef int MYINT; + +void fun(int int_param, MYINT myint_param) +{ + +} diff --git a/regression/cbmc/typedef-param-type1/test.desc b/regression/cbmc/typedef-param-type1/test.desc new file mode 100644 index 00000000000..14659940cde --- /dev/null +++ b/regression/cbmc/typedef-param-type1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_param\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_param\nMode\.+: C\nType\.+: MYINT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-param-type2/main.c b/regression/cbmc/typedef-param-type2/main.c new file mode 100644 index 00000000000..b5974fb6bbb --- /dev/null +++ b/regression/cbmc/typedef-param-type2/main.c @@ -0,0 +1,8 @@ + +typedef int MYINT; +typedef int ALTINT; + +void fun(int int_param, MYINT myint_param, ALTINT altint_param) +{ + +} diff --git a/regression/cbmc/typedef-param-type2/test.desc b/regression/cbmc/typedef-param-type2/test.desc new file mode 100644 index 00000000000..14e7db9d3d4 --- /dev/null +++ b/regression/cbmc/typedef-param-type2/test.desc @@ -0,0 +1,12 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_param\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_param\nMode\.+: C\nType\.+: MYINT +Base name\.+: altint_param\nMode\.+: C\nType\.+: ALTINT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-param-type3/main.c b/regression/cbmc/typedef-param-type3/main.c new file mode 100644 index 00000000000..4d542e10c13 --- /dev/null +++ b/regression/cbmc/typedef-param-type3/main.c @@ -0,0 +1,7 @@ + +typedef int MYINT; +typedef MYINT CHAINEDINT; + +void fun(int int_param, MYINT myint_param, CHAINEDINT chainedint_param) +{ +} diff --git a/regression/cbmc/typedef-param-type3/test.desc b/regression/cbmc/typedef-param-type3/test.desc new file mode 100644 index 00000000000..1f10dea2551 --- /dev/null +++ b/regression/cbmc/typedef-param-type3/test.desc @@ -0,0 +1,12 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_param\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_param\nMode\.+: C\nType\.+: MYINT +Base name\.+: chainedint_param\nMode\.+: C\nType\.+: CHAINEDINT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-param-union1/main.c b/regression/cbmc/typedef-param-union1/main.c new file mode 100644 index 00000000000..8f961614e5d --- /dev/null +++ b/regression/cbmc/typedef-param-union1/main.c @@ -0,0 +1,10 @@ + +typedef union tag_union_name +{ + int x; + float y; +} MYUNION; + +void fun(union tag_union_name tag_union_param, MYUNION myunion_param) +{ +} diff --git a/regression/cbmc/typedef-param-union1/test.desc b/regression/cbmc/typedef-param-union1/test.desc new file mode 100644 index 00000000000..37ab0aee08c --- /dev/null +++ b/regression/cbmc/typedef-param-union1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_union_param\nMode\.+: C\nType\.+: union tag_union_name +Base name\.+: myunion_param\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring diff --git a/regression/cbmc/typedef-return-anon-struct1/main.c b/regression/cbmc/typedef-return-anon-struct1/main.c new file mode 100644 index 00000000000..0195b955cdd --- /dev/null +++ b/regression/cbmc/typedef-return-anon-struct1/main.c @@ -0,0 +1,12 @@ + +typedef struct +{ + int x; + float y; +} MYSTRUCT; + +MYSTRUCT fun() +{ + MYSTRUCT return_variable = {.x = 1, .y = 3.14f}; + return return_variable; +} diff --git a/regression/cbmc/typedef-return-anon-struct1/test.desc b/regression/cbmc/typedef-return-anon-struct1/test.desc new file mode 100644 index 00000000000..420ac1295ac --- /dev/null +++ b/regression/cbmc/typedef-return-anon-struct1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: return\nMode\.+: C\nType\.+: MYSTRUCT +Base name\.+: fun\nMode\.+: C\nType\.+: MYSTRUCT \(\) +-- +warning: ignoring diff --git a/regression/cbmc/typedef-return-anon-union1/main.c b/regression/cbmc/typedef-return-anon-union1/main.c new file mode 100644 index 00000000000..3bc7d19d5b7 --- /dev/null +++ b/regression/cbmc/typedef-return-anon-union1/main.c @@ -0,0 +1,15 @@ + +typedef union +{ + int x; + float y; +} MYUNION; + + +MYUNION fun() +{ + MYUNION return_variable = {1}; + return return_variable; +} + + diff --git a/regression/cbmc/typedef-return-anon-union1/test.desc b/regression/cbmc/typedef-return-anon-union1/test.desc new file mode 100644 index 00000000000..8d8d41a4dfe --- /dev/null +++ b/regression/cbmc/typedef-return-anon-union1/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: fun\nMode\.+: C\nType\.+: MYUNION \(\) +-- +warning: ignoring diff --git a/regression/cbmc/typedef-return-struct1/main.c b/regression/cbmc/typedef-return-struct1/main.c new file mode 100644 index 00000000000..30c1323555c --- /dev/null +++ b/regression/cbmc/typedef-return-struct1/main.c @@ -0,0 +1,20 @@ + +typedef struct tag_struct_name +{ + int x; + float y; +} MYSTRUCT; + +struct tag_struct_name fun() +{ + struct tag_struct_name return_variable = { .x = 1, .y = 3.14f}; + return return_variable; +} + +MYSTRUCT fun2() +{ + MYSTRUCT return_variable = { .x = 1, .y = 3.14f}; + return return_variable; +} + + diff --git a/regression/cbmc/typedef-return-struct1/test.desc b/regression/cbmc/typedef-return-struct1/test.desc new file mode 100644 index 00000000000..c4a9dc3550c --- /dev/null +++ b/regression/cbmc/typedef-return-struct1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: fun\nMode\.+: C\nType\.+: struct tag_struct_name \(\) +Base name\.+: fun2\nMode\.+: C\nType\.+: MYSTRUCT \(\) +-- +warning: ignoring diff --git a/regression/cbmc/typedef-return-type1/main.c b/regression/cbmc/typedef-return-type1/main.c new file mode 100644 index 00000000000..1ba7f426f89 --- /dev/null +++ b/regression/cbmc/typedef-return-type1/main.c @@ -0,0 +1,12 @@ + +typedef int MYINT; + +int fun() +{ + return 4; +} + +MYINT fun2() +{ + return 5; +} diff --git a/regression/cbmc/typedef-return-type1/test.desc b/regression/cbmc/typedef-return-type1/test.desc new file mode 100644 index 00000000000..0ebbe5109a7 --- /dev/null +++ b/regression/cbmc/typedef-return-type1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: fun\nMode\.+: C\nType\.+: signed int \(\) +Base name\.+: fun2\nMode\.+: C\nType\.+: MYINT \(\) +-- +warning: ignoring diff --git a/regression/cbmc/typedef-return-type2/main.c b/regression/cbmc/typedef-return-type2/main.c new file mode 100644 index 00000000000..0d94ab54da3 --- /dev/null +++ b/regression/cbmc/typedef-return-type2/main.c @@ -0,0 +1,13 @@ + +typedef int MYINT; +typedef int ALTINT; + +MYINT fun() +{ + +} + +ALTINT fun2() +{ + +} diff --git a/regression/cbmc/typedef-return-type2/test.desc b/regression/cbmc/typedef-return-type2/test.desc new file mode 100644 index 00000000000..27b2e77902d --- /dev/null +++ b/regression/cbmc/typedef-return-type2/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: fun\nMode\.+: C\nType\.+: MYINT \(\) +Base name\.+: fun2\nMode\.+: C\nType\.+: ALTINT \(\) +-- +warning: ignoring diff --git a/regression/cbmc/typedef-return-type3/main.c b/regression/cbmc/typedef-return-type3/main.c new file mode 100644 index 00000000000..e246757c692 --- /dev/null +++ b/regression/cbmc/typedef-return-type3/main.c @@ -0,0 +1,12 @@ + +typedef int MYINT; +typedef MYINT CHAINEDINT; + +MYINT fun() +{ +} + +CHAINEDINT fun2() +{ + +} \ No newline at end of file diff --git a/regression/cbmc/typedef-return-type3/test.desc b/regression/cbmc/typedef-return-type3/test.desc new file mode 100644 index 00000000000..7cfecafece9 --- /dev/null +++ b/regression/cbmc/typedef-return-type3/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +Base name\.+: fun\nMode\.+: C\nType\.+: MYINT \(\) +Base name\.+: fun2\nMode\.+: C\nType\.+: CHAINEDINT \(\) +-- +warning: ignoring diff --git a/regression/cbmc/typedef-return-union1/main.c b/regression/cbmc/typedef-return-union1/main.c new file mode 100644 index 00000000000..ad69cb04545 --- /dev/null +++ b/regression/cbmc/typedef-return-union1/main.c @@ -0,0 +1,20 @@ + +typedef union tag_union_name +{ + int x; + float y; +} MYUNION; + +union tag_union_name fun() +{ + union tag_union_name return_variable = {1}; + return return_variable; +} + +MYUNION fun2() +{ + MYUNION return_variable = {1}; + return return_variable; +} + + diff --git a/regression/cbmc/typedef-return-union1/test.desc b/regression/cbmc/typedef-return-union1/test.desc new file mode 100644 index 00000000000..b1668066f08 --- /dev/null +++ b/regression/cbmc/typedef-return-union1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: fun\nMode\.+: C\nType\.+: union tag_union_name \(\) +Base name\.+: fun2\nMode\.+: C\nType\.+: MYUNION \(\) +-- +warning: ignoring diff --git a/regression/cbmc/typedef-struct1/main.c b/regression/cbmc/typedef-struct1/main.c new file mode 100644 index 00000000000..dac5abf77b8 --- /dev/null +++ b/regression/cbmc/typedef-struct1/main.c @@ -0,0 +1,12 @@ + +typedef struct tag_struct_name +{ + int x; + float y; +} MYSTRUCT; + +void fun() +{ + struct tag_struct_name tag_struct_var = {.x = 1, .y = 3.14f}; + MYSTRUCT mystruct_var = {.x = 3, .y = 2.1f}; +} diff --git a/regression/cbmc/typedef-struct1/test.desc b/regression/cbmc/typedef-struct1/test.desc new file mode 100644 index 00000000000..90f1c22933a --- /dev/null +++ b/regression/cbmc/typedef-struct1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_struct_var\nMode\.+: C\nType\.+: struct tag_struct_name +Base name\.+: mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-struct2/main.c b/regression/cbmc/typedef-struct2/main.c new file mode 100644 index 00000000000..dac5abf77b8 --- /dev/null +++ b/regression/cbmc/typedef-struct2/main.c @@ -0,0 +1,12 @@ + +typedef struct tag_struct_name +{ + int x; + float y; +} MYSTRUCT; + +void fun() +{ + struct tag_struct_name tag_struct_var = {.x = 1, .y = 3.14f}; + MYSTRUCT mystruct_var = {.x = 3, .y = 2.1f}; +} diff --git a/regression/cbmc/typedef-struct2/test.desc b/regression/cbmc/typedef-struct2/test.desc new file mode 100644 index 00000000000..90f1c22933a --- /dev/null +++ b/regression/cbmc/typedef-struct2/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_struct_var\nMode\.+: C\nType\.+: struct tag_struct_name +Base name\.+: mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-type1/main.c b/regression/cbmc/typedef-type1/main.c new file mode 100644 index 00000000000..43f028c7772 --- /dev/null +++ b/regression/cbmc/typedef-type1/main.c @@ -0,0 +1,8 @@ + +typedef int MYINT; + +void fun() +{ + int int_var = 3; + MYINT myint_var = 5; +} diff --git a/regression/cbmc/typedef-type1/test.desc b/regression/cbmc/typedef-type1/test.desc new file mode 100644 index 00000000000..08d1f5abfcd --- /dev/null +++ b/regression/cbmc/typedef-type1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_var\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_var\nMode\.+: C\nType\.+: MYINT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-type2/main.c b/regression/cbmc/typedef-type2/main.c new file mode 100644 index 00000000000..acb1cce2da4 --- /dev/null +++ b/regression/cbmc/typedef-type2/main.c @@ -0,0 +1,10 @@ + +typedef int MYINT; +typedef int ALTINT; + +void fun() +{ + int int_var = 3; + MYINT myint_var = 5; + ALTINT altint_var = 7; +} diff --git a/regression/cbmc/typedef-type2/test.desc b/regression/cbmc/typedef-type2/test.desc new file mode 100644 index 00000000000..76d1d114a19 --- /dev/null +++ b/regression/cbmc/typedef-type2/test.desc @@ -0,0 +1,12 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_var\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_var\nMode\.+: C\nType\.+: MYINT +Base name\.+: altint_var\nMode\.+: C\nType\.+: ALTINT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-type3/main.c b/regression/cbmc/typedef-type3/main.c new file mode 100644 index 00000000000..5855e0c24cb --- /dev/null +++ b/regression/cbmc/typedef-type3/main.c @@ -0,0 +1,10 @@ + +typedef int MYINT; +typedef MYINT CHAINEDINT; + +void fun() +{ + int int_var = 3; + MYINT myint_var = 5; + CHAINEDINT chainedint_var = 5; +} diff --git a/regression/cbmc/typedef-type3/test.desc b/regression/cbmc/typedef-type3/test.desc new file mode 100644 index 00000000000..cc5ad52d953 --- /dev/null +++ b/regression/cbmc/typedef-type3/test.desc @@ -0,0 +1,12 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_var\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_var\nMode\.+: C\nType\.+: MYINT +Base name\.+: chainedint_var\nMode\.+: C\nType\.+: CHAINEDINT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-type4/main.c b/regression/cbmc/typedef-type4/main.c new file mode 100644 index 00000000000..aa2ec9ad7fb --- /dev/null +++ b/regression/cbmc/typedef-type4/main.c @@ -0,0 +1,8 @@ + +typedef int MYINT; + +void fun() +{ + int int_var = 3; + MYINT myint_var = 5, another_myint_var = 10; +} diff --git a/regression/cbmc/typedef-type4/test.desc b/regression/cbmc/typedef-type4/test.desc new file mode 100644 index 00000000000..1c0c063b8e1 --- /dev/null +++ b/regression/cbmc/typedef-type4/test.desc @@ -0,0 +1,12 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_var\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_var\nMode\.+: C\nType\.+: MYINT +Base name\.+: another_myint_var\nMode\.+: C\nType\.+: MYINT +-- +warning: ignoring diff --git a/regression/cbmc/typedef-union1/main.c b/regression/cbmc/typedef-union1/main.c new file mode 100644 index 00000000000..6f56f3c731b --- /dev/null +++ b/regression/cbmc/typedef-union1/main.c @@ -0,0 +1,12 @@ + +typedef union tag_union_name +{ + int x; + float y; +} MYUNION; + +void fun() +{ + union tag_union_name tag_union_var = {1}; + MYUNION myunion_var = {.y = 2.1f}; +} diff --git a/regression/cbmc/typedef-union1/test.desc b/regression/cbmc/typedef-union1/test.desc new file mode 100644 index 00000000000..e7ce9b6b459 --- /dev/null +++ b/regression/cbmc/typedef-union1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_union_var\nMode\.+: C\nType\.+: union tag_union_name +Base name\.+: myunion_var\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring diff --git a/regression/cbmc/typedef-union2/main.c b/regression/cbmc/typedef-union2/main.c new file mode 100644 index 00000000000..9ca707cf767 --- /dev/null +++ b/regression/cbmc/typedef-union2/main.c @@ -0,0 +1,12 @@ + +typedef union tag_union_name +{ + int x; + float y; +} MYUNION; + +void fun() +{ + union tag_union_name tag_union_var = {1}, another_tag_union_var = {1}; + MYUNION myunion_var = {.y = 2.1f}, another_myunion_var = {.y = 3.1f}; +} diff --git a/regression/cbmc/typedef-union2/test.desc b/regression/cbmc/typedef-union2/test.desc new file mode 100644 index 00000000000..33cbbff29af --- /dev/null +++ b/regression/cbmc/typedef-union2/test.desc @@ -0,0 +1,13 @@ +CORE +main.c +--show-symbol-table --function fun +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_union_var\nMode\.+: C\nType\.+: union tag_union_name +Base name\.+: another_tag_union_var\nMode\.+: C\nType\.+: union tag_union_name +Base name\.+: myunion_var\nMode\.+: C\nType\.+: MYUNION +Base name\.+: another_myunion_var\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring diff --git a/regression/cbmc/unsigned___int128/main.c b/regression/cbmc/unsigned___int128/main.c index b695484a332..b3bfbd5ea28 100644 --- a/regression/cbmc/unsigned___int128/main.c +++ b/regression/cbmc/unsigned___int128/main.c @@ -1,6 +1,6 @@ # include -typedef unsigned __int128 uint128_t; +typedef unsigned __int128 uint128_t; typedef uint64_t limb; typedef uint128_t widelimb; @@ -8,9 +8,9 @@ typedef uint128_t widelimb; typedef limb felem[4]; typedef widelimb widefelem[7]; -felem p = {0x1FFFFFFFFFFFFFF, - 0xFFFFFFFFFFFFFF, - 0xFFFFE000000000, +felem p = {0x1FFFFFFFFFFFFFF, + 0xFFFFFFFFFFFFFF, + 0xFFFFE000000000, 0x00000000000002}; @@ -18,13 +18,20 @@ felem p = {0x1FFFFFFFFFFFFFF, * Reduce seven 128-bit coefficients to four 64-bit coefficients. * Requires in[i] < 2^126, * ensures out[0] < 2^56, out[1] < 2^56, out[2] < 2^56, out[3] <= 2^56 + 2^16 */ -void reduce(felem out, const widefelem in) +void reduce( + limb out0, limb out1, limb out2, limb out3, widelimb in0, widelimb in1, + widelimb in2, widelimb in3, widelimb in4, widelimb in5, widelimb in6) { + felem out = {out0, out1, out2, out3}; + const widefelem in = {in0, in1, in2, in3, in4, in5, in6}; __CPROVER_assume(in[0]<(widelimb)((widelimb)1<<126)); __CPROVER_assume(in[1]<((widelimb)1<<126)); __CPROVER_assume(in[2]<((widelimb)1<<126)); __CPROVER_assume(in[3]<((widelimb)1<<126)); + __CPROVER_assume(in[4]<((widelimb)1<<126)); + __CPROVER_assume(in[5]<((widelimb)1<<126)); + __CPROVER_assume(in[6]<((widelimb)1<<126)); static const widelimb two127p15 = (((widelimb) 1) << 127) + (((widelimb) 1) << 15); @@ -75,9 +82,9 @@ void reduce(felem out, const widefelem in) output[2] += output[1] >> 56; /* output[2] < 2^57 + 2^72 */ - + assert(output[2] < (((widelimb)1)<<57)+(((widelimb)1)<<72)); - + out[1] = output[1] & 0x00ffffffffffffff; output[3] += output[2] >> 56; /* output[3] <= 2^56 + 2^16 */ diff --git a/regression/cpp-from-CVS/Makefile b/regression/cpp-from-CVS/Makefile index b092e240b99..e28536a2988 100644 --- a/regression/cpp-from-CVS/Makefile +++ b/regression/cpp-from-CVS/Makefile @@ -12,3 +12,8 @@ show: vim -o "$$dir/main.c" "$$dir/main.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/cpp-linter/Makefile b/regression/cpp-linter/Makefile index b84f9ae3d18..097b463fce5 100644 --- a/regression/cpp-linter/Makefile +++ b/regression/cpp-linter/Makefile @@ -18,3 +18,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/cpp-linter/function-comment-header1/test.desc b/regression/cpp-linter/function-comment-header1/test.desc index efaae0b7391..708eecf0783 100644 --- a/regression/cpp-linter/function-comment-header1/test.desc +++ b/regression/cpp-linter/function-comment-header1/test.desc @@ -3,6 +3,5 @@ main.cpp ^main\.cpp:26: Could not find function header comment for foo \[readability/function_comment\] \[4\] ^Total errors found: 1$ - ^SIGNAL=0$ -- diff --git a/regression/cpp-linter/struct-inline-decl/test.desc b/regression/cpp-linter/struct-inline-decl/test.desc index 4a53c26c870..12418d892f4 100644 --- a/regression/cpp-linter/struct-inline-decl/test.desc +++ b/regression/cpp-linter/struct-inline-decl/test.desc @@ -1,7 +1,6 @@ CORE main.cpp - ^Total errors found: 0$ ^EXIT=0$ ^SIGNAL=0$ diff --git a/regression/cpp/Makefile b/regression/cpp/Makefile index b03e120015b..87af55e3306 100644 --- a/regression/cpp/Makefile +++ b/regression/cpp/Makefile @@ -18,3 +18,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/fault-localization/Makefile b/regression/fault-localization/Makefile index cbdd3378bac..9a14abc905f 100644 --- a/regression/fault-localization/Makefile +++ b/regression/fault-localization/Makefile @@ -18,3 +18,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/goto-analyzer/Makefile b/regression/goto-analyzer/Makefile index 2630bf17097..ca7e7707afe 100644 --- a/regression/goto-analyzer/Makefile +++ b/regression/goto-analyzer/Makefile @@ -18,3 +18,8 @@ show: vim -o "$$dir/*.java" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/goto-analyzer/approx-array-variable-const-fp/main.c b/regression/goto-analyzer/approx-array-variable-const-fp/main.c new file mode 100644 index 00000000000..7896e3402c0 --- /dev/null +++ b/regression/goto-analyzer/approx-array-variable-const-fp/main.c @@ -0,0 +1,34 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +const void_fp fp_tbl[] = {f2, f3 ,f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i) +{ + fp_tbl[i](); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} diff --git a/regression/goto-analyzer/approx-array-variable-const-fp/test.desc b/regression/goto-analyzer/approx-array-variable-const-fp/test.desc new file mode 100644 index 00000000000..38027f70600 --- /dev/null +++ b/regression/goto-analyzer/approx-array-variable-const-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f2 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f3 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f4 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f9 THEN GOTO [0-9]$ +^warning: ignoring diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/main.c new file mode 100644 index 00000000000..8fda2e71af4 --- /dev/null +++ b/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/main.c @@ -0,0 +1,41 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void(* const fp_tbl[3])(void) = +{ + (void(*)())f2, + (void(*)())f3, + (void(*)())f4, +}; + + +void func(int i) +{ + const void_fp fp = fp_tbl[i]; + fp(); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc new file mode 100644 index 00000000000..e6f1f4b5752 --- /dev/null +++ b/regression/goto-analyzer/approx-const-fp-array-variable-cast-const-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring +^\s*IF fp_tbl\[\(signed long int\)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f9 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/main.c new file mode 100644 index 00000000000..72a600aa80c --- /dev/null +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/main.c @@ -0,0 +1,35 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +const void_fp fp_tbl[] = {f2, f3 ,f4, 0}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i) +{ + const void_fp fp = fp_tbl[i]; + fp(); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc new file mode 100644 index 00000000000..e6f1f4b5752 --- /dev/null +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp-with-null/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring +^\s*IF fp_tbl\[\(signed long int\)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f9 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/main.c new file mode 100644 index 00000000000..7eea22141bd --- /dev/null +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/main.c @@ -0,0 +1,35 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +const void_fp fp_tbl[] = {f2, f3 ,f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i) +{ + const void_fp fp = fp_tbl[i]; + fp(); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc new file mode 100644 index 00000000000..e6f1f4b5752 --- /dev/null +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring +^\s*IF fp_tbl\[\(signed long int\)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f9 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/main.c new file mode 100644 index 00000000000..67d256f0c7b --- /dev/null +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/main.c @@ -0,0 +1,50 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +struct action +{ + void_fp fun; +}; + +const struct action rec = { .fun = f2 }; +const struct action rec2 = { .fun = f3 }; +const struct action rec3 = { .fun = f4 }; + +const struct action * const action_list[4] = +{ + &rec, + &rec2, + &rec3, + &rec +}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i) +{ + const void_fp fp = action_list[i]->fun; + fp(); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc new file mode 100644 index 00000000000..e6f1f4b5752 --- /dev/null +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring +^\s*IF fp_tbl\[\(signed long int\)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f9 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/main.c new file mode 100644 index 00000000000..e058e5f3c4f --- /dev/null +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/main.c @@ -0,0 +1,51 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +struct stable +{ + int x; + void (*fp)(void); +}; + +const struct stable stable_table [3] = +{ + { 1, f2 }, + { 2, f3 }, + { 3, f4 } +}; + +const struct stable another_table = { 4, f5 }; + + +void func(int i) +{ + const void_fp fp = stable_table[i].fp; + + // Illegal + // stable_table[1] = another_table; + fp(); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + return 0; +} diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc new file mode 100644 index 00000000000..e6f1f4b5752 --- /dev/null +++ b/regression/goto-analyzer/approx-const-fp-array-variable-const-struct-non-const-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring +^\s*IF fp_tbl\[\(signed long int\)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f9 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/main.c b/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/main.c new file mode 100644 index 00000000000..ca882ffd6b3 --- /dev/null +++ b/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/main.c @@ -0,0 +1,77 @@ +#include + +int f1 (void) +{ + printf("%i\n", 1); + return 1; +} +int f2 (void) +{ + printf("%i\n", 2); + return 2; +} +int f3 (void) +{ + printf("%i\n", 3); + return 3; +} +int f4 (void) +{ + printf("%i\n", 4); + return 4; +} +int f5 (void) +{ + printf("%i\n", 5); + return 5; +} +int f6 (void) +{ + printf("%i\n", 6); + return 6; +} +int f7 (void) +{ + printf("%i\n", 7); + return 7; +} +int f8 (void) +{ + printf("%i\n", 8); + return 8; +} +int f9 (void) +{ + printf("%i\n", 9); + return 9; +} + +typedef void(*void_fp)(void); +typedef int(*int_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const int_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void(* const fp_tbl[3])(void) = +{ + (void(*)())f2, + (void(*)())f3, + (void(*)())f4, +}; + + +void func(int i) +{ + const void_fp fp = fp_tbl[i]; + fp(); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + return 0; +} diff --git a/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc b/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc new file mode 100644 index 00000000000..661ac93a14f --- /dev/null +++ b/regression/goto-analyzer/approx-const-fp-array-variable-invalid-cast-const-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp == \(const void_fp\)f2 THEN GOTO [0-9]$ +^\s*IF fp == \(const void_fp\)f3 THEN GOTO [0-9]$ +^\s*IF fp == \(const void_fp\)f4 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring +^\s*IF fp_tbl\[\(signed long int\)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed long int\)i\] == f9 THEN GOTO [0-9]$ diff --git a/regression/goto-analyzer/constant_propagation_01/constant_propagation1.c b/regression/goto-analyzer/constant_propagation_01/constant_propagation1.c new file mode 100644 index 00000000000..801a21535a9 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_01/constant_propagation1.c @@ -0,0 +1,14 @@ +#include + +int main() +{ + int i, j=20; + + if (j==20) + { + int x=1,y=2,z; + z=x+y; + assert(z==3); + } + +} diff --git a/regression/goto-analyzer/constant_propagation_01/test.desc b/regression/goto-analyzer/constant_propagation_01/test.desc new file mode 100644 index 00000000000..1eb849c3c7a --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_01/test.desc @@ -0,0 +1,9 @@ +FUTURE +constant_propagation1.c +--constants --simplify out.goto +^EXIT=0$ +^SIGNAL=0$ +^SIMPLIFIED: assert: 1, assume: 0, goto: 2, assigns: 5, function calls: 0$ +^UNMODIFIED: assert: 0, assume: 0, goto: 0, assigns: 12, function calls: 2$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_02/constant_propagation_02.c b/regression/goto-analyzer/constant_propagation_02/constant_propagation_02.c new file mode 100644 index 00000000000..ff139437bd8 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_02/constant_propagation_02.c @@ -0,0 +1,13 @@ +#include + +int main() +{ + int i=0, j=2; + + if (i==0) + { + i++; + j++; + } + assert(j!=3); +} diff --git a/regression/goto-analyzer/constant_propagation_02/original b/regression/goto-analyzer/constant_propagation_02/original new file mode 100644 index 00000000000..13a9e245c81 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_02/original @@ -0,0 +1,3 @@ +Task defaults to --show +Domain defaults to --constants +GOTO-ANALYSER version 5.5 64-bit x86_64 linux diff --git a/regression/goto-analyzer/constant_propagation_02/simplified b/regression/goto-analyzer/constant_propagation_02/simplified new file mode 100644 index 00000000000..6c722a607de --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_02/simplified @@ -0,0 +1,81 @@ +Reading GOTO program from `out.goto' +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +main /* main */ + // 0 file constant_propagation_02.c line 5 function main + signed int i; + // 1 file constant_propagation_02.c line 5 function main + i = 0; + // 2 file constant_propagation_02.c line 5 function main + signed int j; + // 3 file constant_propagation_02.c line 5 function main + j = 2; + // 4 file constant_propagation_02.c line 7 function main + IF FALSE THEN GOTO 1 + // 5 file constant_propagation_02.c line 9 function main + 0 = 1; + // 6 file constant_propagation_02.c line 10 function main + 2 = 3; + // 7 no location + 1: SKIP + // 8 file constant_propagation_02.c line 12 function main + ASSERT FALSE // assertion j!=3 + // 9 file constant_propagation_02.c line 12 function main + GOTO 2 + // 10 file constant_propagation_02.c line 12 function main + (void)0; + // 11 no location + 2: SKIP + // 12 file constant_propagation_02.c line 13 function main + dead j; + // 13 file constant_propagation_02.c line 13 function main + dead i; + // 14 file constant_propagation_02.c line 13 function main + main#return_value = NONDET(signed int); + // 15 file constant_propagation_02.c line 13 function main + END_FUNCTION +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +_start /* _start */ + // 16 no location + __CPROVER_initialize(); + // 17 file constant_propagation_02.c line 3 + main(); + // 18 file constant_propagation_02.c line 3 + return' = main#return_value; + // 19 file constant_propagation_02.c line 3 + dead main#return_value; + // 20 file constant_propagation_02.c line 3 + OUTPUT("return", return'); + // 21 no location + END_FUNCTION +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +__CPROVER_initialize /* __CPROVER_initialize */ + // 22 no location + // Labels: __CPROVER_HIDE + SKIP + // 23 file line 39 + __CPROVER_dead_object = NULL; + // 24 file line 38 + __CPROVER_deallocated = NULL; + // 25 file line 42 + __CPROVER_malloc_is_new_array = FALSE; + // 26 file line 40 + __CPROVER_malloc_object = NULL; + // 27 file line 41 + __CPROVER_malloc_size = 0ul; + // 28 file line 43 + __CPROVER_memory_leak = NULL; + // 29 file line 31 + __CPROVER_next_thread_id = 0ul; + // 30 file line 85 + __CPROVER_pipe_count = 0u; + // 31 file line 65 + __CPROVER_rounding_mode = 0; + // 32 file line 29 + __CPROVER_thread_id = 0ul; + // 33 file line 30 + __CPROVER_threads_exited = ARRAY_OF(FALSE); + // 34 no location + END_FUNCTION diff --git a/regression/goto-analyzer/constant_propagation_02/test.desc b/regression/goto-analyzer/constant_propagation_02/test.desc new file mode 100644 index 00000000000..20cc5fcf86e --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_02/test.desc @@ -0,0 +1,9 @@ +FUTURE +constant_propagation_02.c +--constants --simplify out.goto +^EXIT=0$ +^SIGNAL=0$ +^SIMPLIFIED: assert: 1, assume: 0, goto: 2, assigns: 6, function calls: 0$ +^UNMODIFIED: assert: 0, assume: 0, goto: 0, assigns: 11, function calls: 2$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_03/constant_propagation_03.c b/regression/goto-analyzer/constant_propagation_03/constant_propagation_03.c new file mode 100644 index 00000000000..f08f6020d82 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_03/constant_propagation_03.c @@ -0,0 +1,13 @@ +#include + +int main() +{ + int i=0, j=2; + + if (i==0) + { + i++; + j++; + } + assert(j==3); +} diff --git a/regression/goto-analyzer/constant_propagation_03/test.desc b/regression/goto-analyzer/constant_propagation_03/test.desc new file mode 100644 index 00000000000..2225c1a666e --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_03/test.desc @@ -0,0 +1,9 @@ +FUTURE +constant_propagation_03.c +--constants --simplify out.goto +^EXIT=0$ +^SIGNAL=0$ +^SIMPLIFIED: assert: 1, assume: 0, goto: 2, assigns: 6, function calls: 0$ +^UNMODIFIED: assert: 0, assume: 0, goto: 0, assigns: 11, function calls: 2$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_04/constant_propagation_04.c b/regression/goto-analyzer/constant_propagation_04/constant_propagation_04.c new file mode 100644 index 00000000000..ca003ccd2b8 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_04/constant_propagation_04.c @@ -0,0 +1,13 @@ +#include + +int main() +{ + int i=0, j=2; + + if (i<50) + { + i++; + j++; + } + assert(j==3); +} diff --git a/regression/goto-analyzer/constant_propagation_04/test.desc b/regression/goto-analyzer/constant_propagation_04/test.desc new file mode 100644 index 00000000000..2510b3f8a5e --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_04/test.desc @@ -0,0 +1,9 @@ +FUTURE +constant_propagation_04.c +--constants --simplify out.goto +^EXIT=0$ +^SIGNAL=0$ +^SIMPLIFIED: assert: 1, assume: 0, goto: 2, assigns: 6, function calls: 0$ +^UNMODIFIED: assert: 0, assume: 0, goto: 0, assigns: 11, function calls: 2$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_05/constant_propagation_05.c b/regression/goto-analyzer/constant_propagation_05/constant_propagation_05.c new file mode 100644 index 00000000000..037fbbe0632 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_05/constant_propagation_05.c @@ -0,0 +1,13 @@ +#include + +int main() +{ + int i=0, j=2; + + if (i<50) + { + i++; + j++; + } + assert(j!=3); +} diff --git a/regression/goto-analyzer/constant_propagation_05/test.desc b/regression/goto-analyzer/constant_propagation_05/test.desc new file mode 100644 index 00000000000..ddb22cc3616 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_05/test.desc @@ -0,0 +1,8 @@ +FUTURE +constant_propagation_05.c +--constants --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] file constant_propagation_05.c line 12 function main, assertion j!=3: FAILURE (if reachable)$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_06/constant_propagation_06.c b/regression/goto-analyzer/constant_propagation_06/constant_propagation_06.c new file mode 100644 index 00000000000..d1d29427250 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_06/constant_propagation_06.c @@ -0,0 +1,30 @@ +#include + +int main() +{ + int i, j=20; + + if(i>=20) + assert(i>=10); // success + + if(i>=10 && i<=20) + assert(i!=30); // success + + if(i>=10 && i<=20) + assert(i!=15); // fails + + if(i<1 && i>10) + assert(0); // success + + if(i>=10 && j>=i) + assert(j>=10); // success + + if(i>=j) + assert(i>=j); // unknown + + if(i>10) + assert(i>=11); // success + + if(i<=100 && j=10: SUCCESS$ +^\[main.assertion.2\] file constant_propagation_06.c line 11 function main, assertion i!=30: SUCCESS$ +^\[main.assertion.3\] file constant_propagation_06.c line 14 function main, assertion i!=15: UNKNOWN$ +^\[main.assertion.4\] file constant_propagation_06.c line 17 function main, assertion 0: SUCCESS$ +^\[main.assertion.5\] file constant_propagation_06.c line 20 function main, assertion j>=10: SUCCESS$ +^\[main.assertion.6\] file constant_propagation_06.c line 23 function main, assertion i>=j: UNKNOWN$ +^\[main.assertion.7\] file constant_propagation_06.c line 26 function main, assertion i>=11: SUCCESS$ +^\[main.assertion.8\] file constant_propagation_06.c line 29 function main, assertion j<100: SUCCESS$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_07/constant_propagation_07.c b/regression/goto-analyzer/constant_propagation_07/constant_propagation_07.c new file mode 100644 index 00000000000..40b04edfdd0 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_07/constant_propagation_07.c @@ -0,0 +1,14 @@ +#include + +int main() +{ + int i=0, j=2; + + while (i<50) + { + i++; + j++; + } + assert(i<51); +} + diff --git a/regression/goto-analyzer/constant_propagation_07/test.desc b/regression/goto-analyzer/constant_propagation_07/test.desc new file mode 100644 index 00000000000..615893d4f78 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_07/test.desc @@ -0,0 +1,8 @@ +FUTURE +constant_propagation_07.c +--constants --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] file constant_propagation_07.c line 12 function main, assertion i<51: UNKNOWN$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_08/constant_propagation_08.c b/regression/goto-analyzer/constant_propagation_08/constant_propagation_08.c new file mode 100644 index 00000000000..3909e3889e4 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_08/constant_propagation_08.c @@ -0,0 +1,16 @@ +#include + +int main() +{ + int i=0, j=2; + + while (i<=50) + { + i++; + j++; + } + assert(i<50); + assert(i<51); + assert(i<52); +} + diff --git a/regression/goto-analyzer/constant_propagation_08/test.desc b/regression/goto-analyzer/constant_propagation_08/test.desc new file mode 100644 index 00000000000..994c2c532df --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_08/test.desc @@ -0,0 +1,10 @@ +FUTURE +constant_propagation_08.c +--intervals --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] file constant_propagation_08.c line 12 function main, assertion i<50: UNKNOWN$ +^\[main.assertion.2\] file constant_propagation_08.c line 13 function main, assertion i<51: UNKNOWN$ +^\[main.assertion.3\] file constant_propagation_08.c line 14 function main, assertion i<52: SUCCESS$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_09/constant_propagation_09.c b/regression/goto-analyzer/constant_propagation_09/constant_propagation_09.c new file mode 100644 index 00000000000..002e9063228 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_09/constant_propagation_09.c @@ -0,0 +1,14 @@ +#include + +int main() +{ + int i=0, j=2; + + while (i<=50) + { + i++; + j++; + } + assert(j<52); +} + diff --git a/regression/goto-analyzer/constant_propagation_09/test.desc b/regression/goto-analyzer/constant_propagation_09/test.desc new file mode 100644 index 00000000000..6a1b75f0c1b --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_09/test.desc @@ -0,0 +1,9 @@ +FUTURE +constant_propagation_09.c +--intervals --verify +^EXIT=0$ +^SIGNAL=0$ +******** Function main +^\[main.assertion.1\] file constant_propagation_09.c line 12 function main, assertion j<52: UNKNOWN$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_10/constant_propagation_10.c b/regression/goto-analyzer/constant_propagation_10/constant_propagation_10.c new file mode 100644 index 00000000000..169f7965b9d --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_10/constant_propagation_10.c @@ -0,0 +1,25 @@ +#include +int main() +{ + signed int i; + signed int j; + i = 0; + if(!(i >= 2)) + { + j = j + 1; + i = i + 1; + if(!(i >= 2)) + { + j = j + 1; + i = i + 1; + if(!(i >= 2)) + { + j = j + 1; + i = i + 1; + } + assert(!(i < 2)); + } + } + return 0; +} + diff --git a/regression/goto-analyzer/constant_propagation_10/test.desc b/regression/goto-analyzer/constant_propagation_10/test.desc new file mode 100644 index 00000000000..52d98cb611b --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_10/test.desc @@ -0,0 +1,9 @@ +FUTURE +constant_propagation_10.c +--constants --simplify out.goto +^EXIT=0$ +^SIGNAL=0$ +^SIMPLIFIED: assert: 1, assume: 0, goto: 4, assigns: 10, function calls: 0$ +^UNMODIFIED: assert: 0, assume: 0, goto: 1, assigns: 10, function calls: 2$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_11/constant_propagation_11.c b/regression/goto-analyzer/constant_propagation_11/constant_propagation_11.c new file mode 100644 index 00000000000..3022a4f0f19 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_11/constant_propagation_11.c @@ -0,0 +1,17 @@ +#include +int main() +{ + int a[2]; + int i; + i = 0; + + if (i==0) + a[0]=1; + else + a[1]=2; + + assert(a[0]==1 || a[1]==2); + + return 0; +} + diff --git a/regression/goto-analyzer/constant_propagation_11/test.desc b/regression/goto-analyzer/constant_propagation_11/test.desc new file mode 100644 index 00000000000..7c849326cf6 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_11/test.desc @@ -0,0 +1,9 @@ +FUTURE +constant_propagation_11.c +--constants --simplify out.goto +^EXIT=0$ +^SIGNAL=0$ +^SIMPLIFIED: assert: 1, assume: 0, goto: 2, assigns: 5, function calls: 0$ +^UNMODIFIED: assert: 0, assume: 0, goto: 4, assigns: 13, function calls: 2$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_12/constant_propagation_12.c b/regression/goto-analyzer/constant_propagation_12/constant_propagation_12.c new file mode 100644 index 00000000000..55ea9ac7fc2 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_12/constant_propagation_12.c @@ -0,0 +1,13 @@ +#include +int main() +{ + int a[2]={0,0}; + + if (a[0]==0) + a[0]=1; + + assert(a[0]==0); + + return 0; +} + diff --git a/regression/goto-analyzer/constant_propagation_12/test.desc b/regression/goto-analyzer/constant_propagation_12/test.desc new file mode 100644 index 00000000000..ca5803363ad --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_12/test.desc @@ -0,0 +1,9 @@ +FUTURE +constant_propagation_12.c +--constants --simplify out.goto +^EXIT=0$ +^SIGNAL=0$ +^SIMPLIFIED: assert: 1, assume: 0, goto: 3, assigns: 4, function calls: 0$ +^UNMODIFIED: assert: 0, assume: 0, goto: 0, assigns: 11, function calls: 2$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_13/constant_propagation_13.c b/regression/goto-analyzer/constant_propagation_13/constant_propagation_13.c new file mode 100644 index 00000000000..ac5933e9177 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_13/constant_propagation_13.c @@ -0,0 +1,14 @@ +#include +int main() +{ + int a[2]={0,0}; + int i, y; + + if (a[0]==0) + a[0]=1; + + assert(a[0]==2); + + return 0; +} + diff --git a/regression/goto-analyzer/constant_propagation_13/test.desc b/regression/goto-analyzer/constant_propagation_13/test.desc new file mode 100644 index 00000000000..22f10d125e3 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_13/test.desc @@ -0,0 +1,8 @@ +FUTURE +constant_propagation_13.c +--constants --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] file constant_propagation_13.c line 10 function main, assertion a\[0\]==2: FAILURE$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_14/constant_propagation_14.c b/regression/goto-analyzer/constant_propagation_14/constant_propagation_14.c new file mode 100644 index 00000000000..124d1e30a20 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_14/constant_propagation_14.c @@ -0,0 +1,13 @@ +#include +int main() +{ + int a[2]={0,0}; + + if (a[0]==0) + a[0]=1; + + assert(a[0]==1 /*|| a[0]==2*/); + + return 0; +} + diff --git a/regression/goto-analyzer/constant_propagation_14/test.desc b/regression/goto-analyzer/constant_propagation_14/test.desc new file mode 100644 index 00000000000..a39a1f66cda --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_14/test.desc @@ -0,0 +1,9 @@ +FUTURE +constant_propagation_14.c +--constants --simplify out.goto +^EXIT=0$ +^SIGNAL=0$ +^SIMPLIFIED: assert: 1, assume: 0, goto: 0$ +^UNKNOWN: assert: 0, assume: 0, goto: 0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_15/constant_propagation_15.c b/regression/goto-analyzer/constant_propagation_15/constant_propagation_15.c new file mode 100644 index 00000000000..9a7e7692d62 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_15/constant_propagation_15.c @@ -0,0 +1,13 @@ +#include +int main() +{ + int i=0, y; + + if (i==0) + y=1; + + assert(y==1); + + return 0; +} + diff --git a/regression/goto-analyzer/constant_propagation_15/test.desc b/regression/goto-analyzer/constant_propagation_15/test.desc new file mode 100644 index 00000000000..20d36183eb0 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_15/test.desc @@ -0,0 +1,9 @@ +FUTURE +constant_propagation_15.c +--constants --simplify out.goto +^EXIT=0$ +^SIGNAL=0$ +^SIMPLIFIED: assert: 1, assume: 0, goto: 1, assigns: 4, function calls: 0$ +^UNMODIFIED: assert: 0, assume: 0, goto: 2, assigns: 11, function calls: 2$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_16/constant_propagation_16.c b/regression/goto-analyzer/constant_propagation_16/constant_propagation_16.c new file mode 100644 index 00000000000..102cfd7f812 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_16/constant_propagation_16.c @@ -0,0 +1,13 @@ +#include +int main() +{ + int i=0, y; + + if (i==0) + y=1; + + assert(y==0); + + return 0; +} + diff --git a/regression/goto-analyzer/constant_propagation_16/test.desc b/regression/goto-analyzer/constant_propagation_16/test.desc new file mode 100644 index 00000000000..b56c871deb4 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_16/test.desc @@ -0,0 +1,8 @@ +FUTURE +constant_propagation_16.c +--constants --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] file constant_propagation_16.c line 9 function main, assertion y==0: FAILURE (if reachable)$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_17/constant_propagation_17.c b/regression/goto-analyzer/constant_propagation_17/constant_propagation_17.c new file mode 100644 index 00000000000..8b426fe84b5 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_17/constant_propagation_17.c @@ -0,0 +1,16 @@ +#include +int main() +{ + int a[2]={0,0}; + + if (a[0]==0) + a[0]=1; + else + a[0]=2; + + assert(a[0]==1 || a[0]==2); + assert(a[0]==1 && a[0]==2); + + return 0; +} + diff --git a/regression/goto-analyzer/constant_propagation_17/test.desc b/regression/goto-analyzer/constant_propagation_17/test.desc new file mode 100644 index 00000000000..acecb91eb0a --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_17/test.desc @@ -0,0 +1,9 @@ +FUTURE +constant_propagation_17.c +--constants --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] file constant_propagation_17.c line 11 function main, assertion a\[0\]==1 || a\[0\]==2: SUCCESS$ +^\[main.assertion.2\] file constant_propagation_17.c line 12 function main, assertion a\[0\]==1 && a\[0\]==2: FAILURE$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/constant_propagation_18/constant_propagation_18.c b/regression/goto-analyzer/constant_propagation_18/constant_propagation_18.c new file mode 100644 index 00000000000..6639f9b5c81 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_18/constant_propagation_18.c @@ -0,0 +1,13 @@ +#include +int main() +{ + int a[2]={0,0}; + + if (a[0]==0) + a[0]=1; + + assert(a[0]==2); + + return 0; +} + diff --git a/regression/goto-analyzer/constant_propagation_18/test.desc b/regression/goto-analyzer/constant_propagation_18/test.desc new file mode 100644 index 00000000000..7ea74c4d264 --- /dev/null +++ b/regression/goto-analyzer/constant_propagation_18/test.desc @@ -0,0 +1,8 @@ +FUTURE +constant_propagation_18.c +--constants --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] file constant_propagation_18.c line 9 function main, assertion a\[0\]==2: FAILURE$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/intervals1/intervals1.c b/regression/goto-analyzer/intervals1/intervals1.c index a797452b198..cdec490fe6d 100644 --- a/regression/goto-analyzer/intervals1/intervals1.c +++ b/regression/goto-analyzer/intervals1/intervals1.c @@ -2,8 +2,8 @@ int main() { - int i, j; - + int i, j=20; + if(i>=20) assert(i>=10); diff --git a/regression/goto-analyzer/intervals1/test.desc b/regression/goto-analyzer/intervals1/test.desc index 3e81f14023a..5a9802eeb20 100644 --- a/regression/goto-analyzer/intervals1/test.desc +++ b/regression/goto-analyzer/intervals1/test.desc @@ -1,6 +1,6 @@ -CORE +KNOWNBUG intervals1.c ---intervals +--intervals --verify ^EXIT=0$ ^SIGNAL=0$ ^\[main.assertion.1\] file intervals1.c line 8 function main, assertion i>=10: SUCCESS$ diff --git a/regression/goto-analyzer/intervals10/intervals10.c b/regression/goto-analyzer/intervals10/intervals10.c new file mode 100644 index 00000000000..b27cc6f2001 --- /dev/null +++ b/regression/goto-analyzer/intervals10/intervals10.c @@ -0,0 +1,21 @@ +#include + +int main() +{ + int i, j; + + if(i<=100 && j100); // fails + + if(i<=100 && j100: FAILURE (if reachable)$ +^\[main.assertion.4\] file intervals10.c line 17 function main, assertion j<99: UNKNOWN$ +^\[main.assertion.5\] file intervals10.c line 20 function main, assertion j==100: FAILURE (if reachable)$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/intervals11/intervals11.c b/regression/goto-analyzer/intervals11/intervals11.c new file mode 100644 index 00000000000..2f061cd554d --- /dev/null +++ b/regression/goto-analyzer/intervals11/intervals11.c @@ -0,0 +1,43 @@ +#include +const int xLen = 10; +const int Alen = 2; +const int Blen = 1; +float nondet_float(); +int main() { + float A[] = {1.0f,-0.5f}; + float B[] = {1.0f}; + int i,j; + float x[xLen]; + float x_aux[xLen]; + float y[xLen]; + float y_aux[xLen]; + float total=0; + for (i=0;i=-1 && x[i]<=1); + x_aux[i]=0; + y_aux[i]=0; + } + for(i=0;i=1;j--) + x_aux[j] = x_aux[j-1]; + x_aux[0] = x[i]; + /* Num, x values */ + for (j = 0; j < Blen; j++) { + y[i] = y[i] + B[j]*x_aux[j]; + assert(y[i]>=-1.0f && y[i]<=1.0f); //success + } + /* Den, y values */ + for(j=0;j=-1.0f && y[i]<=1.0f); //fails + } + /* Update past y values */ + for(j=Alen-2;j>=1;j--) + y_aux[j] = y_aux[j-1]; + y_aux[0] = y[i]; + } +} + diff --git a/regression/goto-analyzer/intervals11/test.desc b/regression/goto-analyzer/intervals11/test.desc new file mode 100644 index 00000000000..039cbffbeb0 --- /dev/null +++ b/regression/goto-analyzer/intervals11/test.desc @@ -0,0 +1,9 @@ +FUTURE +intervals11.c +--intervals --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] file intervals11.c line 30 function main, assertion y\[i\]>=-1.0f && y\[i\]<=1.0f: UNKNOWN$ +^\[main.assertion.2\] file intervals11.c line 35 function main, assertion y\[i\]>=-1.0f && y\[i\]<=1.0f: UNKNOWN$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/intervals12/intervals12.c b/regression/goto-analyzer/intervals12/intervals12.c new file mode 100644 index 00000000000..15d865adf80 --- /dev/null +++ b/regression/goto-analyzer/intervals12/intervals12.c @@ -0,0 +1,16 @@ +#include + +int main (void) { + int i; + int j; + + if (i <= 0 && j < i) + assert(j < 0); + + if (j < i && i <= 0) + assert(j < 0); + + return 0; +} + + diff --git a/regression/goto-analyzer/intervals12/test.desc b/regression/goto-analyzer/intervals12/test.desc new file mode 100644 index 00000000000..59a724c28b5 --- /dev/null +++ b/regression/goto-analyzer/intervals12/test.desc @@ -0,0 +1,9 @@ +FUTURE +intervals12.c +--intervals --verify +^EXIT=0$ +^SIGNAL=0$ +^[main.assertion.1] file intervals12.c line 8 function main, assertion j < 0: SUCCESS$ +^[main.assertion.2] file intervals12.c line 11 function main, assertion j < 0: SUCCESS$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/intervals2/intervals2.c b/regression/goto-analyzer/intervals2/intervals2.c index d1eaf25240e..d542854bb6a 100644 --- a/regression/goto-analyzer/intervals2/intervals2.c +++ b/regression/goto-analyzer/intervals2/intervals2.c @@ -2,10 +2,10 @@ int main(){ int x; - if (x > 0) { - if (x < 20) { + if (x > 0 && x < 20) { + //if (x < 20) { assert(x > -10 && x < 100); - } + //} } return 0; } diff --git a/regression/goto-analyzer/intervals2/test.desc b/regression/goto-analyzer/intervals2/test.desc index 16a8ca559e2..65aae030db1 100644 --- a/regression/goto-analyzer/intervals2/test.desc +++ b/regression/goto-analyzer/intervals2/test.desc @@ -1,6 +1,6 @@ KNOWNBUG intervals2.c ---intervals +--intervals --verify ^EXIT=0$ ^SIGNAL=0$ ^\[main.assertion.1\] file intervals2.c line 7 function main, assertion x > -10 && x < 100: SUCCESS$ diff --git a/regression/goto-analyzer/intervals3/test.desc b/regression/goto-analyzer/intervals3/test.desc index 5db07df08a4..69ded2182ee 100644 --- a/regression/goto-analyzer/intervals3/test.desc +++ b/regression/goto-analyzer/intervals3/test.desc @@ -1,6 +1,6 @@ -CORE +KNOWNBUG intervals3.c ---intervals +--intervals --verify ^EXIT=0$ ^SIGNAL=0$ ^\[main.assertion.1\] file intervals3.c line 7 function main, assertion x > -10 || x < 100: SUCCESS$ diff --git a/regression/goto-analyzer/intervals4/test.desc b/regression/goto-analyzer/intervals4/test.desc index 97d222012ad..2b725180e3f 100644 --- a/regression/goto-analyzer/intervals4/test.desc +++ b/regression/goto-analyzer/intervals4/test.desc @@ -1,6 +1,6 @@ KNOWNBUG intervals4.c ---intervals +--intervals --verify ^EXIT=0$ ^SIGNAL=0$ ^\[main.assertion.1\] file intervals4.c line 9 function main, assertion i >= 1 && i <= 2: SUCCESS$ diff --git a/regression/goto-analyzer/intervals5/test.desc b/regression/goto-analyzer/intervals5/test.desc index 42554724e2d..eb64fbc13d1 100644 --- a/regression/goto-analyzer/intervals5/test.desc +++ b/regression/goto-analyzer/intervals5/test.desc @@ -1,6 +1,6 @@ -CORE +KNOWNBUG intervals5.c ---intervals +--intervals --verify ^EXIT=0$ ^SIGNAL=0$ ^\[main.assertion.1\] file intervals5.c line 9 function main, assertion i >= 1 || i <= 2: SUCCESS$ diff --git a/regression/goto-analyzer/intervals6/test.desc b/regression/goto-analyzer/intervals6/test.desc index 14fd64f33dd..6e36b7948d2 100644 --- a/regression/goto-analyzer/intervals6/test.desc +++ b/regression/goto-analyzer/intervals6/test.desc @@ -1,8 +1,8 @@ -CORE +FUTURE intervals6.c ---intervals +--intervals --verify ^EXIT=0$ ^SIGNAL=0$ -^\[main.assertion.1\] file intervals6.c line 7 function main, assertion x < -10 || x > 100: UNKNOWN$ +^\[main.assertion.1\] file intervals6.c line 7 function main, assertion x < -10 || x > 100: FAILURE (if reachable)$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/intervals7/test.desc b/regression/goto-analyzer/intervals7/test.desc index aeeb24bd0a9..6a42b4a30ec 100644 --- a/regression/goto-analyzer/intervals7/test.desc +++ b/regression/goto-analyzer/intervals7/test.desc @@ -1,8 +1,8 @@ -CORE +FUTURE intervals7.c ---intervals +--intervals --verify ^EXIT=0$ ^SIGNAL=0$ -^\[main.assertion.1\] file intervals7.c line 7 function main, assertion x < -10 && x > 100: UNKNOWN$ +^\[main.assertion.1\] file intervals7.c line 7 function main, assertion x < -10 && x > 100: FAILURE (if reachable)$ -- ^warning: ignoring diff --git a/regression/goto-analyzer/intervals8/intervals8.c b/regression/goto-analyzer/intervals8/intervals8.c new file mode 100644 index 00000000000..4128ac07ce5 --- /dev/null +++ b/regression/goto-analyzer/intervals8/intervals8.c @@ -0,0 +1,9 @@ +#include + +int main(){ + int x; + if (x > 0 && x < 20) { + assert(x < -10 && x < 100); + } + return 0; +} diff --git a/regression/goto-analyzer/intervals8/test.desc b/regression/goto-analyzer/intervals8/test.desc new file mode 100644 index 00000000000..7500059a717 --- /dev/null +++ b/regression/goto-analyzer/intervals8/test.desc @@ -0,0 +1,8 @@ +FUTURE +intervals8.c +--intervals --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] file intervals8.c line 6 function main, assertion x < -10 && x < 100: FAILURE (if reachable)$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/intervals9/intervals9.c b/regression/goto-analyzer/intervals9/intervals9.c new file mode 100644 index 00000000000..27739c7aa28 --- /dev/null +++ b/regression/goto-analyzer/intervals9/intervals9.c @@ -0,0 +1,12 @@ +#include + +int main() +{ + int i; + + if(i>0) + if(i<3) + assert(i>=1 && i<=2); + + return 0; +} diff --git a/regression/goto-analyzer/intervals9/test.desc b/regression/goto-analyzer/intervals9/test.desc new file mode 100644 index 00000000000..37c33b97288 --- /dev/null +++ b/regression/goto-analyzer/intervals9/test.desc @@ -0,0 +1,8 @@ +KNOWNBUG +intervals9.c +--intervals --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] file intervals9.c line 9 function main, assertion i>=1 && i<=2: SUCCESS$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-array-literal-const-fp-null/main.c b/regression/goto-analyzer/no-match-array-literal-const-fp-null/main.c new file mode 100644 index 00000000000..93ed0af0d47 --- /dev/null +++ b/regression/goto-analyzer/no-match-array-literal-const-fp-null/main.c @@ -0,0 +1,31 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +const void_fp fp_tbl[] = {f2, NULL ,f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + fp_tbl[1](); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/no-match-array-literal-const-fp-null/test.desc b/regression/goto-analyzer/no-match-array-literal-const-fp-null/test.desc new file mode 100644 index 00000000000..4786993cade --- /dev/null +++ b/regression/goto-analyzer/no-match-array-literal-const-fp-null/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*ASSERT FALSE // invalid function pointer$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-array-const-pointer-const-fp-const-lost/main.c b/regression/goto-analyzer/no-match-const-array-const-pointer-const-fp-const-lost/main.c new file mode 100644 index 00000000000..a17acab6166 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-array-const-pointer-const-fp-const-lost/main.c @@ -0,0 +1,41 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp start_fp = f2; + const void_fp * const fp_tbl[] = { &start_fp, &start_fp, &start_fp }; + + // warning: loses const + void_fp * arr_ptr=fp_tbl[0]; + (*arr_ptr) = f5; + arr_ptr++; + (*arr_ptr) = f5; + + const void_fp * const fp = fp_tbl[1]; + + + (*fp)(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-array-const-pointer-const-fp-const-lost/test.desc b/regression/goto-analyzer/no-match-const-array-const-pointer-const-fp-const-lost/test.desc new file mode 100644 index 00000000000..cb389930278 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-array-const-pointer-const-fp-const-lost/test.desc @@ -0,0 +1,15 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF \*fp == f1 THEN GOTO [0-9]$ +^\s*IF \*fp == f2 THEN GOTO [0-9]$ +^\s*IF \*fp == f3 THEN GOTO [0-9]$ +^\s*IF \*fp == f4 THEN GOTO [0-9]$ +^\s*IF \*fp == f5 THEN GOTO [0-9]$ +^\s*IF \*fp == f6 THEN GOTO [0-9]$ +^\s*IF \*fp == f7 THEN GOTO [0-9]$ +^\s*IF \*fp == f8 THEN GOTO [0-9]$ +^\s*IF \*fp == f9 THEN GOTO [0-9]$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/main.c b/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/main.c new file mode 100644 index 00000000000..ee9ba95cb57 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/main.c @@ -0,0 +1,36 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i, int j) +{ + const void_fp fp_tbl[] = {fp_all[i*2], fp_all[j+1]}; + // Illegal: + //fp_tbl[1] = f4; + const void_fp fp = fp_tbl[1]; + fp(); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(i,0); + } + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/test.desc b/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/test.desc new file mode 100644 index 00000000000..a73805f5730 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-const-fp-run-time/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/main.c b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/main.c new file mode 100644 index 00000000000..fa1cf231a50 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/main.c @@ -0,0 +1,34 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i, int j) +{ + void_fp fp_tbl[] = {fp_all[i*2], fp_all[j+1]}; + const void_fp fp = fp_tbl[1]; + fp(); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(i,0); + } + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/test.desc b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/test.desc new file mode 100644 index 00000000000..a73805f5730 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp-run-time/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/main.c new file mode 100644 index 00000000000..88b4edcf448 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/main.c @@ -0,0 +1,38 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +void_fp fp_tbl[] = {f2, f3, f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(void_fp fp, int i) +{ + // It is concievable this could be checked and seen the first value + // of the array is unchanged but is kind of a weird edge case. + fp_tbl[2] = fp; + const void_fp fp2 = fp_tbl[1]; + fp2(); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(fp_all[i+3], i); + } + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/test.desc new file mode 100644 index 00000000000..13d0c5353ce --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-array-literal-non-const-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp2 == f1 THEN GOTO [0-9]$ +^\s*IF fp2 == f2 THEN GOTO [0-9]$ +^\s*IF fp2 == f3 THEN GOTO [0-9]$ +^\s*IF fp2 == f4 THEN GOTO [0-9]$ +^\s*IF fp2 == f5 THEN GOTO [0-9]$ +^\s*IF fp2 == f6 THEN GOTO [0-9]$ +^\s*IF fp2 == f7 THEN GOTO [0-9]$ +^\s*IF fp2 == f8 THEN GOTO [0-9]$ +^\s*IF fp2 == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/main.c new file mode 100644 index 00000000000..38d09cfb14e --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/main.c @@ -0,0 +1,36 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +void_fp fp_tbl[] = {f2, f3, f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(void_fp fp, int i) +{ + fp_tbl[2] = fp; + const void_fp fp2 = fp_tbl[2]; + fp2(); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(fp_all[i+3], i); + } + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/test.desc new file mode 100644 index 00000000000..13d0c5353ce --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-array-non-const-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp2 == f1 THEN GOTO [0-9]$ +^\s*IF fp2 == f2 THEN GOTO [0-9]$ +^\s*IF fp2 == f3 THEN GOTO [0-9]$ +^\s*IF fp2 == f4 THEN GOTO [0-9]$ +^\s*IF fp2 == f5 THEN GOTO [0-9]$ +^\s*IF fp2 == f6 THEN GOTO [0-9]$ +^\s*IF fp2 == f7 THEN GOTO [0-9]$ +^\s*IF fp2 == f8 THEN GOTO [0-9]$ +^\s*IF fp2 == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-binary-op-const-lost/main.c b/regression/goto-analyzer/no-match-const-fp-binary-op-const-lost/main.c new file mode 100644 index 00000000000..7f5c0ea3755 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-binary-op-const-lost/main.c @@ -0,0 +1,35 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = f2; + + // Warning: this loses const-ness of f2 + void_fp * p2fp = 0 + ((void_fp*)&fp); + *p2fp = &f4; + + fp(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-binary-op-const-lost/test.desc b/regression/goto-analyzer/no-match-const-fp-binary-op-const-lost/test.desc new file mode 100644 index 00000000000..b9a72f79cfe --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-binary-op-const-lost/test.desc @@ -0,0 +1,15 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-const-array-index-lost/main.c b/regression/goto-analyzer/no-match-const-fp-const-array-index-lost/main.c new file mode 100644 index 00000000000..b3dafeff777 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-array-index-lost/main.c @@ -0,0 +1,40 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp_tbl[] = {f2, f3 ,f4}; + + // warning: loses const + void_fp * arr_ptr=&fp_tbl[0]; + (*arr_ptr) = f5; + arr_ptr++; + (*arr_ptr) = f5; + + const void_fp * const fp = &fp_tbl[1]; + + + (*fp)(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-const-array-index-lost/test.desc b/regression/goto-analyzer/no-match-const-fp-const-array-index-lost/test.desc new file mode 100644 index 00000000000..cb389930278 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-array-index-lost/test.desc @@ -0,0 +1,15 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF \*fp == f1 THEN GOTO [0-9]$ +^\s*IF \*fp == f2 THEN GOTO [0-9]$ +^\s*IF \*fp == f3 THEN GOTO [0-9]$ +^\s*IF \*fp == f4 THEN GOTO [0-9]$ +^\s*IF \*fp == f5 THEN GOTO [0-9]$ +^\s*IF \*fp == f6 THEN GOTO [0-9]$ +^\s*IF \*fp == f7 THEN GOTO [0-9]$ +^\s*IF \*fp == f8 THEN GOTO [0-9]$ +^\s*IF \*fp == f9 THEN GOTO [0-9]$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-const-array-lost/main.c b/regression/goto-analyzer/no-match-const-fp-const-array-lost/main.c new file mode 100644 index 00000000000..d27da78d0b7 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-array-lost/main.c @@ -0,0 +1,40 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp_tbl[] = {f2, f3 ,f4}; + + // warning: loses const + void_fp * arr_ptr=fp_tbl; + (*arr_ptr) = f5; + arr_ptr++; + (*arr_ptr) = f5; + + const void_fp * const fp = &fp_tbl[1]; + + + (*fp)(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-const-array-lost/test.desc b/regression/goto-analyzer/no-match-const-fp-const-array-lost/test.desc new file mode 100644 index 00000000000..cb389930278 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-array-lost/test.desc @@ -0,0 +1,15 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF \*fp == f1 THEN GOTO [0-9]$ +^\s*IF \*fp == f2 THEN GOTO [0-9]$ +^\s*IF \*fp == f3 THEN GOTO [0-9]$ +^\s*IF \*fp == f4 THEN GOTO [0-9]$ +^\s*IF \*fp == f5 THEN GOTO [0-9]$ +^\s*IF \*fp == f6 THEN GOTO [0-9]$ +^\s*IF \*fp == f7 THEN GOTO [0-9]$ +^\s*IF \*fp == f8 THEN GOTO [0-9]$ +^\s*IF \*fp == f9 THEN GOTO [0-9]$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-const-cast/main.c b/regression/goto-analyzer/no-match-const-fp-const-cast/main.c new file mode 100644 index 00000000000..b9bd141e6f0 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-cast/main.c @@ -0,0 +1,35 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = f2; + + // Warning: this loses const-ness of f2 + void_fp * p2fp = (void_fp*)&fp; + *p2fp = &f4; + + fp(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-const-cast/test.desc b/regression/goto-analyzer/no-match-const-fp-const-cast/test.desc new file mode 100644 index 00000000000..b9a72f79cfe --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-cast/test.desc @@ -0,0 +1,15 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-const-fp-null/main.c b/regression/goto-analyzer/no-match-const-fp-const-fp-null/main.c new file mode 100644 index 00000000000..67c501302a6 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-fp-null/main.c @@ -0,0 +1,31 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = NULL; + const void_fp fp2 = fp; + fp2(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-const-fp-null/test.desc b/regression/goto-analyzer/no-match-const-fp-const-fp-null/test.desc new file mode 100644 index 00000000000..4786993cade --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-fp-null/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*ASSERT FALSE // invalid function pointer$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-const-lost/main.c b/regression/goto-analyzer/no-match-const-fp-const-lost/main.c new file mode 100644 index 00000000000..d2724684066 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-lost/main.c @@ -0,0 +1,35 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = f2; + + // Warning: this loses const-ness of f2 + void_fp * p2fp = &fp; + *p2fp = &f4; + + fp(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-const-lost/test.desc b/regression/goto-analyzer/no-match-const-fp-const-lost/test.desc new file mode 100644 index 00000000000..b9a72f79cfe --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-lost/test.desc @@ -0,0 +1,15 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-const-pointer-const-struct-const-fp-null/main.c b/regression/goto-analyzer/no-match-const-fp-const-pointer-const-struct-const-fp-null/main.c new file mode 100644 index 00000000000..76671ef3829 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-pointer-const-struct-const-fp-null/main.c @@ -0,0 +1,44 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + + +typedef struct fp_container +{ + int x; + const void_fp pointer; +} fp_container; + + + +void func() +{ + const fp_container container = {.x = 10, .pointer = f3}; + const fp_container container2 = {.x = 10, .pointer = f4}; + const fp_container * const container_ptr = NULL; + + // Illegal: + //container_ptr = &container2; + //container_ptr->pointer = f4; + + container_ptr->pointer(); +} + +int main() +{ + func(); +} diff --git a/regression/goto-analyzer/no-match-const-fp-const-pointer-const-struct-const-fp-null/test.desc b/regression/goto-analyzer/no-match-const-fp-const-pointer-const-struct-const-fp-null/test.desc new file mode 100644 index 00000000000..4786993cade --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-pointer-const-struct-const-fp-null/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*ASSERT FALSE // invalid function pointer$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/main.c new file mode 100644 index 00000000000..3f55ff255dd --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/main.c @@ -0,0 +1,47 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +struct state +{ + int x; // Mutable! + const void_fp go; +}; +struct state thing = {0, &f2}; +struct state other_thing = {0, &f4}; +struct state * const pts = &thing; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i) +{ + // Illegal + //pts=&other_thing; + // thing.go=&f6; + thing = other_thing; + const void_fp fp = pts->go; + + fp(); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/test.desc new file mode 100644 index 00000000000..a73805f5730 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-const-pointer-non-const-struct-const-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-dereference-const-pointer-null/main.c b/regression/goto-analyzer/no-match-const-fp-dereference-const-pointer-null/main.c new file mode 100644 index 00000000000..e4048adb8cb --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-dereference-const-pointer-null/main.c @@ -0,0 +1,36 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = f3; + const void_fp fp2 = f4; + const void_fp* const p2fp = NULL; + // Illegal: + //p2fp = &fp2; + //fp = f5; + const void_fp final_fp=*p2fp; + final_fp(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-dereference-const-pointer-null/test.desc b/regression/goto-analyzer/no-match-const-fp-dereference-const-pointer-null/test.desc new file mode 100644 index 00000000000..4786993cade --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-dereference-const-pointer-null/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*ASSERT FALSE // invalid function pointer$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/main.c new file mode 100644 index 00000000000..30e4947c2d7 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/main.c @@ -0,0 +1,40 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = f3; + const void_fp fp2 = f4; + const void_fp* p2fp = &fp; + + + // Illegal: + //fp = f5; + + // legal: + p2fp = &fp2; + const void_fp final_fp=*p2fp; + final_fp(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/test.desc new file mode 100644 index 00000000000..f7f42277bae --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-dereference-non-const-pointer-const-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF final_fp == f1 THEN GOTO [0-9]$ +^\s*IF final_fp == f2 THEN GOTO [0-9]$ +^\s*IF final_fp == f3 THEN GOTO [0-9]$ +^\s*IF final_fp == f4 THEN GOTO [0-9]$ +^\s*IF final_fp == f5 THEN GOTO [0-9]$ +^\s*IF final_fp == f6 THEN GOTO [0-9]$ +^\s*IF final_fp == f7 THEN GOTO [0-9]$ +^\s*IF final_fp == f8 THEN GOTO [0-9]$ +^\s*IF final_fp == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/main.c new file mode 100644 index 00000000000..d7d4820d29c --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/main.c @@ -0,0 +1,39 @@ +#include +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + void_fp * const fp_tbl= malloc(sizeof(void_fp) * 3); + fp_tbl[0]=f2; + fp_tbl[1]=f3; + fp_tbl[2]=f4; + + // Illegal + //fp_tbl = malloc(sizeof(void_fp) * 10); + + const void_fp fp = fp_tbl[1]; + fp(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/test.desc new file mode 100644 index 00000000000..a73805f5730 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-dynamic-array-non-const-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/main.c b/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/main.c new file mode 100644 index 00000000000..6c9ba5514e7 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/main.c @@ -0,0 +1,32 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + void_fp fp = f2; + fp = f3; + const void_fp fp2 = fp; + fp2(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/test.desc b/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/test.desc new file mode 100644 index 00000000000..13d0c5353ce --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-non-const-fp-direct-assignment/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp2 == f1 THEN GOTO [0-9]$ +^\s*IF fp2 == f2 THEN GOTO [0-9]$ +^\s*IF fp2 == f3 THEN GOTO [0-9]$ +^\s*IF fp2 == f4 THEN GOTO [0-9]$ +^\s*IF fp2 == f5 THEN GOTO [0-9]$ +^\s*IF fp2 == f6 THEN GOTO [0-9]$ +^\s*IF fp2 == f7 THEN GOTO [0-9]$ +^\s*IF fp2 == f8 THEN GOTO [0-9]$ +^\s*IF fp2 == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/main.c new file mode 100644 index 00000000000..bb40b1a53c1 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/main.c @@ -0,0 +1,47 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +struct state +{ + int x; // Mutable! + const void_fp go; +}; +struct state thing = {0, &f2}; +struct state other_thing = {0, &f4}; + +// This shouldn't work +struct state * pts = &thing; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i) +{ + // This shouldn't work since + pts = &other_thing; + const void_fp fp = pts->go; + fp(); +} + + +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/test.desc new file mode 100644 index 00000000000..a73805f5730 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-non-const-pointer-non-const-struct-const-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/main.c new file mode 100644 index 00000000000..ed86d4c39c6 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/main.c @@ -0,0 +1,43 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +struct state +{ + int x; // Mutable! + const void_fp go; +}; +struct state thing = {0, &f2}; + +struct state other_thing = {0, &f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i) +{ + thing = other_thing; + const void_fp fp = thing.go; + fp(); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/test.desc new file mode 100644 index 00000000000..a73805f5730 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-non-const-struct-const-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/main.c b/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/main.c new file mode 100644 index 00000000000..7d8b2584388 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/main.c @@ -0,0 +1,43 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +struct action +{ + int x; + void_fp fun; +}; + +struct action rec = { .x = 4, .fun = f2 }; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i) +{ + // Can mutate + rec.fun=f4; + const void_fp fp = rec.fun; + fp(); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/test.desc new file mode 100644 index 00000000000..a73805f5730 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-non-const-struct-non-const-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-null/main.c b/regression/goto-analyzer/no-match-const-fp-null/main.c new file mode 100644 index 00000000000..16c65f9f845 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-null/main.c @@ -0,0 +1,30 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = NULL; + fp(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-null/test.desc b/regression/goto-analyzer/no-match-const-fp-null/test.desc new file mode 100644 index 00000000000..d8e8d833238 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-null/test.desc @@ -0,0 +1,7 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*ASSERT FALSE // invalid function pointer$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-fp-ternerary-op-const-lost/main.c b/regression/goto-analyzer/no-match-const-fp-ternerary-op-const-lost/main.c new file mode 100644 index 00000000000..ba5bcad694a --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-ternerary-op-const-lost/main.c @@ -0,0 +1,36 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int x) +{ + const void_fp fp = f2; + void_fp non_const_fp = f7; + + // Warning: this loses const-ness of f2 + void_fp * p2fp = x > 0 ? ((void_fp*)&fp) : &non_const_fp; + *p2fp = &f4; + + fp(); +} + +int main() +{ + func(1); + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-fp-ternerary-op-const-lost/test.desc b/regression/goto-analyzer/no-match-const-fp-ternerary-op-const-lost/test.desc new file mode 100644 index 00000000000..b9a72f79cfe --- /dev/null +++ b/regression/goto-analyzer/no-match-const-fp-ternerary-op-const-lost/test.desc @@ -0,0 +1,15 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-pointer-const-struct-const-fp-const-cast/main.c b/regression/goto-analyzer/no-match-const-pointer-const-struct-const-fp-const-cast/main.c new file mode 100644 index 00000000000..b7b9e4d2b30 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-pointer-const-struct-const-fp-const-cast/main.c @@ -0,0 +1,45 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +typedef struct fp_cc +{ + int x; + void_fp fp; +} fp_cc; + + + +void func() +{ + const fp_cc container_container = { .fp = f2, .x = 4 }; + + const fp_cc * const container_pointer = &container_container; + + fp_cc* container_pointer_modifier = (fp_cc*) container_pointer; + container_pointer_modifier->fp = f4; + + // Illegal: + // container_container.container = &f4; + + container_pointer->fp(); +} + +int main() +{ + func(); +} diff --git a/regression/goto-analyzer/no-match-const-pointer-const-struct-const-fp-const-cast/test.desc b/regression/goto-analyzer/no-match-const-pointer-const-struct-const-fp-const-cast/test.desc new file mode 100644 index 00000000000..4e6fda43498 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-pointer-const-struct-const-fp-const-cast/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF container_pointer->fp == f1 THEN GOTO [0-9]$ +^\s*IF container_pointer->fp == f2 THEN GOTO [0-9]$ +^\s*IF container_pointer->fp == f3 THEN GOTO [0-9]$ +^\s*IF container_pointer->fp == f4 THEN GOTO [0-9]$ +^\s*IF container_pointer->fp == f5 THEN GOTO [0-9]$ +^\s*IF container_pointer->fp == f6 THEN GOTO [0-9]$ +^\s*IF container_pointer->fp == f7 THEN GOTO [0-9]$ +^\s*IF container_pointer->fp == f8 THEN GOTO [0-9]$ +^\s*IF container_pointer->fp == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/main.c b/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/main.c new file mode 100644 index 00000000000..bf4bb45d094 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/main.c @@ -0,0 +1,43 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +struct state +{ + int x; // Mutable! + const void_fp go; +}; +struct state thing = {0, &f2}; +struct state other_thing = {0, &f4}; +struct state const * const pts = &thing; + + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i) +{ + thing = other_thing; + pts->go(); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/test.desc b/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/test.desc new file mode 100644 index 00000000000..eaad08aafe0 --- /dev/null +++ b/regression/goto-analyzer/no-match-const-pointer-non-const-struct-const-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF pts->go == f1 THEN GOTO [0-9]$ +^\s*IF pts->go == f2 THEN GOTO [0-9]$ +^\s*IF pts->go == f3 THEN GOTO [0-9]$ +^\s*IF pts->go == f4 THEN GOTO [0-9]$ +^\s*IF pts->go == f5 THEN GOTO [0-9]$ +^\s*IF pts->go == f6 THEN GOTO [0-9]$ +^\s*IF pts->go == f7 THEN GOTO [0-9]$ +^\s*IF pts->go == f8 THEN GOTO [0-9]$ +^\s*IF pts->go == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-const-struct-non-const-fp-null/main.c b/regression/goto-analyzer/no-match-const-struct-non-const-fp-null/main.c new file mode 100644 index 00000000000..6e24a0d8d4c --- /dev/null +++ b/regression/goto-analyzer/no-match-const-struct-non-const-fp-null/main.c @@ -0,0 +1,40 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +struct action +{ + int x; + const void_fp fun; +}; + +const struct action rec = { .x = 4, .fun = NULL }; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i) +{ + rec.fun(); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} diff --git a/regression/goto-analyzer/no-match-const-struct-non-const-fp-null/test.desc b/regression/goto-analyzer/no-match-const-struct-non-const-fp-null/test.desc new file mode 100644 index 00000000000..4786993cade --- /dev/null +++ b/regression/goto-analyzer/no-match-const-struct-non-const-fp-null/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*ASSERT FALSE // invalid function pointer$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/main.c b/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/main.c new file mode 100644 index 00000000000..5d857ffcfe7 --- /dev/null +++ b/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/main.c @@ -0,0 +1,52 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +typedef struct fp_container +{ + int x; + const void_fp* const fp_tbl[3]; +} fp_container; + + + +void func() +{ + void_fp f2meta = &f2; + void_fp f3meta = &f3; + void_fp f4meta = &f4; + + void_fp f5meta = &f5; + void_fp f6meta = &f6; + void_fp f7meta = &f7; + + const fp_container container = { .x = 4, .fp_tbl = {&f2meta ,&f3meta, &f4meta} }; + const fp_container container2 = { .x = 5, .fp_tbl = {&f5meta ,&f6meta, &f7meta} }; + + f3meta = &f5; + // Illegal: + // container.fp_tbl = alternatate_fp_tbl; + // container.fp_tbl[1] = f4; + const fp_container * const container_ptr=&container; + //container_ptr=&container2; + (*container_ptr->fp_tbl[1])(); +} + +int main() +{ + func(); +} diff --git a/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc b/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc new file mode 100644 index 00000000000..ef491f67113 --- /dev/null +++ b/regression/goto-analyzer/no-match-dereference-const-pointer-const-array-literal-pointer-const-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF \*container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f1 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f2 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f3 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f4 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f5 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f6 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f7 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f8 THEN GOTO [0-9]$ +^\s*IF \*container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/main.c b/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/main.c new file mode 100644 index 00000000000..b0be4e4837c --- /dev/null +++ b/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/main.c @@ -0,0 +1,46 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +typedef struct fp_cc +{ + int x; + const void_fp * const container; +} fp_cc; + + + +void func() +{ + const void_fp meta_fp = &f3; + const void_fp meta_fp2 = &f4; + + fp_cc container_container2 = { .container = &meta_fp2, .x = 4 }; + fp_cc container_container = { .container = &meta_fp, .x = 4 }; + container_container = container_container2; + + // Illegal: + //meta_fp = &f4; + //container_container.container = &f4; + + (*container_container.container)(); +} + +int main() +{ + func(); +} diff --git a/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/test.desc b/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/test.desc new file mode 100644 index 00000000000..662bd323844 --- /dev/null +++ b/regression/goto-analyzer/no-match-dereference-non-const-struct-const-pointer-const-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF \*container_container\.container == f1 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f2 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f3 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f4 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f5 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f6 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f7 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f8 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/main.c b/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/main.c new file mode 100644 index 00000000000..28110c56d01 --- /dev/null +++ b/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/main.c @@ -0,0 +1,43 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +typedef struct fp_cc +{ + int x; + const void_fp * container; +} fp_cc; + + + +void func() +{ + const void_fp meta_fp = &f3; + const void_fp meta_fp2 = &f4; + fp_cc container_container = { .container = &meta_fp, .x = 4 }; + + // Illegal: + //meta_fp = &f4; + container_container.container = &meta_fp2; + + (*container_container.container)(); +} + +int main() +{ + func(); +} diff --git a/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/test.desc b/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/test.desc new file mode 100644 index 00000000000..662bd323844 --- /dev/null +++ b/regression/goto-analyzer/no-match-dereference-non-const-struct-non-const-pointer-const-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF \*container_container\.container == f1 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f2 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f3 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f4 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f5 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f6 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f7 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f8 THEN GOTO [0-9]$ +^\s*IF \*container_container\.container == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/main.c b/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/main.c new file mode 100644 index 00000000000..4487db8b047 --- /dev/null +++ b/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/main.c @@ -0,0 +1,33 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = f2; + const void_fp fp3 = f4; + void_fp fp2 = fp; + fp2 = fp3; + fp2(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/test.desc b/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/test.desc new file mode 100644 index 00000000000..13d0c5353ce --- /dev/null +++ b/regression/goto-analyzer/no-match-non-const-fp-const-fp-direct-assignment/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp2 == f1 THEN GOTO [0-9]$ +^\s*IF fp2 == f2 THEN GOTO [0-9]$ +^\s*IF fp2 == f3 THEN GOTO [0-9]$ +^\s*IF fp2 == f4 THEN GOTO [0-9]$ +^\s*IF fp2 == f5 THEN GOTO [0-9]$ +^\s*IF fp2 == f6 THEN GOTO [0-9]$ +^\s*IF fp2 == f7 THEN GOTO [0-9]$ +^\s*IF fp2 == f8 THEN GOTO [0-9]$ +^\s*IF fp2 == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-non-const-fp/main.c b/regression/goto-analyzer/no-match-non-const-fp/main.c new file mode 100644 index 00000000000..80c8c863ff5 --- /dev/null +++ b/regression/goto-analyzer/no-match-non-const-fp/main.c @@ -0,0 +1,31 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + void_fp fp = f2; + fp = f3; + fp(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/no-match-non-const-fp/test.desc b/regression/goto-analyzer/no-match-non-const-fp/test.desc new file mode 100644 index 00000000000..a73805f5730 --- /dev/null +++ b/regression/goto-analyzer/no-match-non-const-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-parameter-const-fp/main.c b/regression/goto-analyzer/no-match-parameter-const-fp/main.c new file mode 100644 index 00000000000..23e73aabdc0 --- /dev/null +++ b/regression/goto-analyzer/no-match-parameter-const-fp/main.c @@ -0,0 +1,32 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(const void_fp fp) +{ + fp(); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(fp_all[i]); + } + + return 0; +} diff --git a/regression/goto-analyzer/no-match-parameter-const-fp/test.desc b/regression/goto-analyzer/no-match-parameter-const-fp/test.desc new file mode 100644 index 00000000000..a73805f5730 --- /dev/null +++ b/regression/goto-analyzer/no-match-parameter-const-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-parameter-fp/main.c b/regression/goto-analyzer/no-match-parameter-fp/main.c new file mode 100644 index 00000000000..332df257368 --- /dev/null +++ b/regression/goto-analyzer/no-match-parameter-fp/main.c @@ -0,0 +1,32 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(void_fp fp) +{ + fp(); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(fp_all[i]); + } + + return 0; +} diff --git a/regression/goto-analyzer/no-match-parameter-fp/test.desc b/regression/goto-analyzer/no-match-parameter-fp/test.desc new file mode 100644 index 00000000000..a73805f5730 --- /dev/null +++ b/regression/goto-analyzer/no-match-parameter-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/main.c b/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/main.c new file mode 100644 index 00000000000..c9d632f43b9 --- /dev/null +++ b/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/main.c @@ -0,0 +1,42 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +typedef struct fp_container +{ + void_fp fp_tbl[3]; +} fp_container; + + + +void func() +{ + const fp_container container = { .fp_tbl = {f2 ,f3, f4} }; + const void_fp alternatate_fp_tbl[] = {f5 ,f6, f7}; + const fp_container container2 = { .fp_tbl = {f5 ,f6, f7} }; + // Illegal: + // container.fp_tbl = alternatate_fp_tbl; + // container.fp_tbl[1] = f4; + const fp_container *container_ptr=&container; + container_ptr=&container2; + container_ptr->fp_tbl[1](); +} + +int main() +{ + func(); +} diff --git a/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc b/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc new file mode 100644 index 00000000000..a85714b51a1 --- /dev/null +++ b/regression/goto-analyzer/no-match-pointer-const-struct-array-literal-non-const-fp/test.desc @@ -0,0 +1,16 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*IF container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f1 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f2 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f3 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f4 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f5 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f6 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f7 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f8 THEN GOTO [0-9]$ +^\s*IF container_ptr->fp_tbl\[\(signed (long )*long int\)1\] == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/precise-array-calculation-const-fp/main.c b/regression/goto-analyzer/precise-array-calculation-const-fp/main.c new file mode 100644 index 00000000000..a61d95186aa --- /dev/null +++ b/regression/goto-analyzer/precise-array-calculation-const-fp/main.c @@ -0,0 +1,32 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +const void_fp fp_tbl[] = {f2, f3 ,f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const short short_const_variable=1; + fp_tbl[(signed long int)((signed int)short_const_variable & 0x1)](); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/precise-array-calculation-const-fp/test.desc b/regression/goto-analyzer/precise-array-calculation-const-fp/test.desc new file mode 100644 index 00000000000..fad0e6c7a1d --- /dev/null +++ b/regression/goto-analyzer/precise-array-calculation-const-fp/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*f3\(\);$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/precise-array-literal-const-fp/main.c b/regression/goto-analyzer/precise-array-literal-const-fp/main.c new file mode 100644 index 00000000000..55dab779802 --- /dev/null +++ b/regression/goto-analyzer/precise-array-literal-const-fp/main.c @@ -0,0 +1,31 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +const void_fp fp_tbl[] = {f2, f3 ,f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + fp_tbl[1](); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/precise-array-literal-const-fp/test.desc b/regression/goto-analyzer/precise-array-literal-const-fp/test.desc new file mode 100644 index 00000000000..fad0e6c7a1d --- /dev/null +++ b/regression/goto-analyzer/precise-array-literal-const-fp/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*f3\(\);$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/main.c b/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/main.c new file mode 100644 index 00000000000..c2465dcb695 --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/main.c @@ -0,0 +1,33 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +const void_fp fp_tbl[] = {f2, f3 ,f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const int x = 1; + const void_fp fp = fp_tbl[x]; + fp(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/test.desc new file mode 100644 index 00000000000..fad0e6c7a1d --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-array-const-variable-const-fp/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*f3\(\);$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/main.c b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/main.c new file mode 100644 index 00000000000..59d51313fde --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/main.c @@ -0,0 +1,32 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp_tbl[] = {f2, f3}; + // Illegal: + //fp_tbl[1] = f4; + const void_fp fp = fp_tbl[1]; + fp(); +} + +int main() +{ + func(); + return 0; +} diff --git a/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/test.desc b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/test.desc new file mode 100644 index 00000000000..ab2a0acefba --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp-run-time/test.desc @@ -0,0 +1,7 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*f3\(\);$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/main.c b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/main.c new file mode 100644 index 00000000000..2e9cb8cc4df --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/main.c @@ -0,0 +1,32 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +const void_fp fp_tbl[] = {f2, f3 ,f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = fp_tbl[1]; + fp(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/test.desc new file mode 100644 index 00000000000..fad0e6c7a1d --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-array-literal-const-fp/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*f3\(\);$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/main.c b/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/main.c new file mode 100644 index 00000000000..26f13fc4c28 --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/main.c @@ -0,0 +1,52 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +struct stable +{ + int x; + void (*fp)(void); +}; + +const struct stable stable_table [3] = +{ + { 1, f2 }, + { 2, f3 }, + { 3, f4 } +}; + +const struct stable another_table = { 4, f5 }; + + +void func(int i) +{ + const void_fp fp = stable_table[1].fp; + + // Illegal + // stable_table[1] = another_table; + // stable_table[1].fp = f5; + fp(); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + return 0; +} diff --git a/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/test.desc new file mode 100644 index 00000000000..fad0e6c7a1d --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-array-literal-const-struct-non-const-fp/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*f3\(\);$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/main.c b/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/main.c new file mode 100644 index 00000000000..c61a7a32499 --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/main.c @@ -0,0 +1,49 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +struct action +{ + int x; + void_fp fun; +}; + +const struct action rec = { .x = 4, .fun = f2 }; + +const struct action * const action_list[4] = +{ + &rec, + &rec, + &rec, + &rec +}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i) +{ + const void_fp fp = action_list[i]->fun; + fp(); +} + +int main() +{ + for(int i=0;i<4;i++) +{ + func(i); + } + + return 0; +} diff --git a/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc new file mode 100644 index 00000000000..90cd2485ce1 --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-array-variable-const-pointer-const-struct-non-const-fp/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*f2\(\); +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp-const-fp/main.c b/regression/goto-analyzer/precise-const-fp-const-fp/main.c new file mode 100644 index 00000000000..a1efb8e0934 --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-const-fp/main.c @@ -0,0 +1,31 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = f2; + const void_fp fp2 = fp; + fp2(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/precise-const-fp-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-const-fp/test.desc new file mode 100644 index 00000000000..40361f6ccc2 --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-const-fp/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*f2\(\);$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/main.c b/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/main.c new file mode 100644 index 00000000000..8a05a9b7d4c --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/main.c @@ -0,0 +1,39 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +typedef struct fp_container +{ + const void_fp fp_tbl[3]; +} fp_container; + + + +void func() +{ + const fp_container container = { .fp_tbl = {f2 ,f3, f4} }; + const fp_container container2 = { .fp_tbl = {f5 ,f6, f7} }; + // Illegal: + //container = container2; + const void_fp fp = container.fp_tbl[1]; + fp(); +} + +int main() +{ + func(); +} diff --git a/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/test.desc b/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/test.desc new file mode 100644 index 00000000000..fad0e6c7a1d --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-const-struct-const-array-literal-fp/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*f3\(\);$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/main.c b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/main.c new file mode 100644 index 00000000000..bc4ffead00e --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/main.c @@ -0,0 +1,45 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +typedef struct fp_container +{ + int x; + void_fp fp_tbl[3]; +} fp_container; + + + +void func() +{ + const fp_container container = { .x = 4, .fp_tbl = {f2 ,f3, f4} }; + fp_container container2 = { .x = 5, .fp_tbl = {f5 ,f6, f7} }; + const void_fp alternatate_fp_tbl[] = {f5 ,f6, f7}; + // Illegal: + // container = container2; + // container.fp_tbl = alternatate_fp_tbl; + // container.fp_tbl[1] = f4; + const void_fp fp = container.fp_tbl[1]; + fp(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/test.desc b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/test.desc new file mode 100644 index 00000000000..fad0e6c7a1d --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-array-literal-fp/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*f3\(\);$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/main.c b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/main.c new file mode 100644 index 00000000000..7c3bed93919 --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/main.c @@ -0,0 +1,44 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +struct action +{ + int x; + void_fp fun; +}; + +const struct action rec = { .x = 4, .fun = f2 }; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i) +{ + + // Illegal: + //rec.fun = &f5; + const void_fp fp = rec.fun; + fp(); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} diff --git a/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/test.desc new file mode 100644 index 00000000000..90cd2485ce1 --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-const-struct-non-const-fp/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*f2\(\); +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/main.c b/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/main.c new file mode 100644 index 00000000000..efeb3b35d80 --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/main.c @@ -0,0 +1,36 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = f3; + const void_fp fp2 = f4; + const void_fp* const p2fp = &fp; + // Illegal: + //p2fp = &fp2; + //fp = f5; + const void_fp final_fp=*p2fp; + final_fp(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/test.desc new file mode 100644 index 00000000000..fad0e6c7a1d --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp-dereference-const-pointer-const-fp/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*f3\(\);$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-fp/main.c b/regression/goto-analyzer/precise-const-fp/main.c new file mode 100644 index 00000000000..b4002c94e5e --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp/main.c @@ -0,0 +1,30 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = f2; + fp(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/precise-const-fp/test.desc b/regression/goto-analyzer/precise-const-fp/test.desc new file mode 100644 index 00000000000..4dd6e7fd098 --- /dev/null +++ b/regression/goto-analyzer/precise-const-fp/test.desc @@ -0,0 +1,7 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*f2\(\); +-- +^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-pointer-const-struct-fp/main.c b/regression/goto-analyzer/precise-const-pointer-const-struct-fp/main.c new file mode 100644 index 00000000000..e1671666b2b --- /dev/null +++ b/regression/goto-analyzer/precise-const-pointer-const-struct-fp/main.c @@ -0,0 +1,43 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +typedef struct fp_cc +{ + int x; + void_fp fp; +} fp_cc; + + + +void func() +{ + const fp_cc container_container = { .fp = f2, .x = 4 }; + + const fp_cc * const container_pointer = &container_container; + + // Illegal: + //meta_fp = &f4; + //container_container.container = &f4; + + container_pointer->fp(); +} + +int main() +{ + func(); +} diff --git a/regression/goto-analyzer/precise-const-pointer-const-struct-fp/test.desc b/regression/goto-analyzer/precise-const-pointer-const-struct-fp/test.desc new file mode 100644 index 00000000000..40361f6ccc2 --- /dev/null +++ b/regression/goto-analyzer/precise-const-pointer-const-struct-fp/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*f2\(\);$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/precise-const-struct-non-const-fp/main.c b/regression/goto-analyzer/precise-const-struct-non-const-fp/main.c new file mode 100644 index 00000000000..150ea314914 --- /dev/null +++ b/regression/goto-analyzer/precise-const-struct-non-const-fp/main.c @@ -0,0 +1,40 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +struct action +{ + int x; + void_fp fun; +}; + +const struct action rec = { .x = 4, .fun = f2 }; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i) +{ + rec.fun(); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} diff --git a/regression/goto-analyzer/precise-const-struct-non-const-fp/test.desc b/regression/goto-analyzer/precise-const-struct-non-const-fp/test.desc new file mode 100644 index 00000000000..90cd2485ce1 --- /dev/null +++ b/regression/goto-analyzer/precise-const-struct-non-const-fp/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*f2\(\); +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/main.c b/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/main.c new file mode 100644 index 00000000000..78901cc6405 --- /dev/null +++ b/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/main.c @@ -0,0 +1,35 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = f3; + const void_fp fp2 = f4; + const void_fp* const p2fp = &fp; + // Illegal: + //p2fp = &fp2; + //fp = f5; + (*p2fp)(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/test.desc new file mode 100644 index 00000000000..fad0e6c7a1d --- /dev/null +++ b/regression/goto-analyzer/precise-derefence-const-pointer-const-fp/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*f3\(\);$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/precise-derefence/main.c b/regression/goto-analyzer/precise-derefence/main.c new file mode 100644 index 00000000000..d3bc8a2bc35 --- /dev/null +++ b/regression/goto-analyzer/precise-derefence/main.c @@ -0,0 +1,31 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + // There isn't an obvious reason to write this code, but perhaps some + // code can get transformed into this so we should still handle it. + (*(&f2))(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/precise-derefence/test.desc b/regression/goto-analyzer/precise-derefence/test.desc new file mode 100644 index 00000000000..4dd6e7fd098 --- /dev/null +++ b/regression/goto-analyzer/precise-derefence/test.desc @@ -0,0 +1,7 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*f2\(\); +-- +^warning: ignoring diff --git a/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/main.c b/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/main.c new file mode 100644 index 00000000000..e0246369f7b --- /dev/null +++ b/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/main.c @@ -0,0 +1,30 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = f3; + (*(&fp))(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/test.desc new file mode 100644 index 00000000000..fad0e6c7a1d --- /dev/null +++ b/regression/goto-analyzer/precise-dereference-address-pointer-const-fp/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*f3\(\);$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/main.c b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/main.c new file mode 100644 index 00000000000..c8694d74a08 --- /dev/null +++ b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/main.c @@ -0,0 +1,42 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +typedef struct fp_cc +{ + int x; + const void_fp * const container; +} fp_cc; + + + +void func() +{ + const void_fp meta_fp = &f3; + const fp_cc container_container = { .container = &meta_fp, .x = 4 }; + + // Illegal: + //meta_fp = &f4; + //container_container.container = &f4; + + (*container_container.container)(); +} + +int main() +{ + func(); +} diff --git a/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/test.desc new file mode 100644 index 00000000000..fad0e6c7a1d --- /dev/null +++ b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-fp/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*f3\(\);$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/main.c b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/main.c new file mode 100644 index 00000000000..4f00ca80765 --- /dev/null +++ b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/main.c @@ -0,0 +1,49 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +typedef struct fp_container +{ + int y; + const void_fp pointer; +} fp_container; + +typedef struct fp_cc +{ + int x; + const fp_container * const container; +} fp_cc; + + + +void func() +{ + const fp_container container = {.y = 10, .pointer = f3}; + const fp_container container2 = {.y = 10, .pointer = f4}; + const fp_cc container_container = { .container = &container, .x = 4 }; + + // Illegal: + //container_container.container = &container2; + //container.pointer = f4; + + (*container_container.container).pointer(); +} + +int main() +{ + func(); +} diff --git a/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/test.desc b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/test.desc new file mode 100644 index 00000000000..fad0e6c7a1d --- /dev/null +++ b/regression/goto-analyzer/precise-dereference-const-struct-const-pointer-const-struct-const-fp/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*f3\(\);$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/main.c b/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/main.c new file mode 100644 index 00000000000..1d562a42dc8 --- /dev/null +++ b/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/main.c @@ -0,0 +1,42 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +typedef struct fp_cc +{ + int x; + const void_fp * container; +} fp_cc; + + + +void func() +{ + const void_fp meta_fp = &f3; + const fp_cc container_container = { .container = &meta_fp, .x = 4 }; + + // Illegal: + //meta_fp = &f4; + //container_container.container = &f4; + + (*container_container.container)(); +} + +int main() +{ + func(); +} diff --git a/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/test.desc b/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/test.desc new file mode 100644 index 00000000000..fad0e6c7a1d --- /dev/null +++ b/regression/goto-analyzer/precise-dereference-const-struct-pointer-const-fp/test.desc @@ -0,0 +1,8 @@ +CORE +main.c +--show-goto-functions --verbosity 10 --pointer-check +^Removing function pointers and virtual functions$ +^\s*f3\(\);$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-common-files/array_of_array_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/array_of_array_sensitivity_tests.c new file mode 100644 index 00000000000..63af187ade2 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/array_of_array_sensitivity_tests.c @@ -0,0 +1,150 @@ +#include + +int main(int argc, char *argv[]) +{ + // A uniform constant array + int a[3][3]={{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; + // A non-uniform constant array + int b[3][3]={{0, 1, 2}, {3, 4, 5}, {6, 7, 8}}; + + // Test if we can represent uniform constant arrays + assert(a[1][2]==0); + assert(a[1][2]==1); + + // Test if we can represent constant arrays which aren't uniform + assert(b[1][2]==5); + assert(b[1][2]==0); + + // Test alternative syntax for accessing an array value + assert(*(b[1]+2)==5); + assert(*(b[1]+2)==0); + assert((*(b+1))[2]==5); + assert((*(b+1))[2]==0); + assert(*(*(b+1)+2)==5); + assert(*(*(b+1)+2)==0); + assert(1[b][2]==5); + assert(1[b][2]==0); + assert(*(1[b]+2)==5); + assert(*(1[b]+2)==0); + assert((*(1+b))[2]==5); + assert((*(1+b))[2]==0); + assert(*(*(1+b)+2)==5); + assert(*(*(1+b)+2)==0); + assert(2[1[b]]==5); + assert(2[1[b]]==0); + assert(*(2+1[b])==5); + assert(*(2+1[b])==0); + assert(*(2+*(1+b))==5); + assert(*(2+*(1+b))==0); + + // Test how well we can deal with merging for an array value when there is one + // possible value + if(argc>2) + { + a[0][1]=0; + } + assert(a[0][1]==0); + assert(a[0][1]==1); + assert(a[0][2]==0); + + // Test how well we can deal with merging for an array value when there are + // two possible values + if(argc>2) + { + b[0][1]=2; + } + assert(b[0][1]==2); + assert(b[0][1]==3); + assert(b[0][2]==2); + + // Reset this change to ensure tests later work as expected + b[0][1]=1; + + // The variables i, j and k will be used as indexes into arrays of size 3. + // They all require merging paths in the CFG. For i there is only one value on + // both paths, which is a valid index. The rest can each take two different + // values. For j both of these values are valid indexes. For k one is and one + // isn't. + int i=0; + int j=0; + int k=0; + if(argc>3) + { + i=0; + j=1; + k=100; + } + + // Test how well we can deal with merging for an index on a uniform array when + // the index has one possible value + assert(a[i][1]==0); + assert(a[i][1]==1); + assert(a[1][i]==0); + assert(a[1][i]==1); + assert(a[i][i]==0); + assert(a[i][i]==1); + + // Test how well we can deal with merging for an index on a uniform array when + // the index has two possible values + assert(a[j][1]==0); + assert(a[j][1]==1); + assert(a[1][j]==0); + assert(a[1][j]==1); + assert(a[j][j]==0); + assert(a[j][j]==1); + + // Test how well we can deal with merging for an index on a non-uniform array + + assert(b[i][1]==1); + assert(b[i][1]==11); + assert(b[1][i]==3); + assert(b[1][i]==11); + assert(b[i][i]==0); + assert(b[i][i]==11); + + // Test how well we can deal with merging for an index on a non-uniform array + assert(b[j][1]==1); + assert(b[j][1]==11); + assert(b[1][j]==3); + assert(b[1][j]==11); + assert(b[j][j]==0); + assert(b[j][j]==11); + + // Test how we deal with reading off the end of an array + assert(a[100][0]==0); + assert(a[0][100]==0); + + // Test how we deal with writing off the end of an array + int c=0; + a[100][0]=1; + assert(c==0); + c=0; + a[0][100]=1; + assert(c==0); + + // Test how we deal with merging for an index with one possible value when + // writing to an array + int ei[3][3]={{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; + ei[i][1]=1; + assert(ei[0][1]==1); + assert(ei[0][1]==0); + assert(ei[2][1]==0); + assert(ei[2][1]==1); + + // Test how we deal with merging for an index with two possible values when + // writing to an array + int ej[3][3]={{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; + ej[j][1]=1; + assert(ej[0][1]==0); + assert(ej[2][1]==0); + + // Test how we deal with merging for an index with two possible values when + // it means writing to an array element that may be out of bounds + int ek[3][3]={{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; + c=0; + ek[k][1]=1; + assert(ek[0][1]==0); + assert(c==0); + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/array_of_pointer_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/array_of_pointer_sensitivity_tests.c new file mode 100644 index 00000000000..907fc4180ad --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/array_of_pointer_sensitivity_tests.c @@ -0,0 +1,156 @@ +#include + +int main(int argc, char *argv[]) +{ + // Test how well we can represent arrays of pointers + int a0=0; + int a1=1; + int a2=2; + int a3=3; + int b0=10; + int b1=11; + int b2=12; + int b3=13; + int c0=20; + int c1=21; + int c2=22; + int c3=23; + int d0=30; + int d1=31; + int d2=32; + int d3=33; + // A uniform constant array + int *a[3]={&a0, &a0, &a0}; + // A non-uniform constant array + int *b[3]={&b0, &b1, &b2}; + + // Test if we can represent uniform constant arrays + assert(a[1]==&a0); + assert(a[1]==&a3); + assert(*a[1]==0); + assert(*a[1]==3); + + // Test if we can represent constant arrays which aren't uniform + assert(b[1]==&b1); + assert(b[1]==&b3); + assert(*b[1]==11); + assert(*b[1]==13); + + // Test alternative syntax for accessing an array value + assert(*(b+1)==&b1); + assert(*(b+1)==&b3); + assert(*(1+b)==&b1); + assert(*(1+b)==&b3); + assert(1[b]==&b1); + assert(1[b]==&b3); + assert(**(b+1)==11); + assert(**(b+1)==13); + assert(**(1+b)==11); + assert(**(1+b)==13); + assert(*1[b]==11); + assert(*1[b]==13); + + // c and d are arrays whose values requiring merging paths in the CFG. For + // c[0] there is only one possibility after merging and for d[0] there are + // two. + int *c[3]={&c0, &c1, &c2}; + int *d[3]={&d0, &d1, &d2}; + if(argc>2) + { + c[0]=&c3; + d[0]=&d3; + } + + // Test how well we can deal with merging for an array value + assert(c[0]==&c0); + assert(c[0]==&c3); + assert(d[0]==&d0); + assert(d[0]==&d3); + assert(*c[0]==20); + assert(*c[0]==23); + assert(*d[0]==30); + assert(*d[0]==33); + + // The variables i, j and k will be used as indexes into arrays of size 3. + // They all require merging paths in the CFG. For i there is only one value on + // both paths, which is a valid index. The rest can each take two different + // values. For j both of these values are valid indexes. For k one is and one + // isn't. + int i=0; + int j=0; + int k=0; + if(argc>3) + { + i=0; + j=1; + k=100; + } + + // Test how well we can deal with merging for an index on a uniform array + assert(a[i]==&a0); + assert(a[i]==&a3); + assert(a[j]==&a0); + assert(a[j]==&a3); + assert(*a[i]==0); + assert(*a[i]==3); + assert(*a[j]==0); + assert(*a[j]==3); + + // Test how well we can deal with merging for an index on a non-uniform array + assert(b[i]==&b0); + assert(b[i]==&b1); + assert(b[j]==&b0); + assert(b[j]==&b3); + assert(*b[i]==10); + assert(*b[i]==11); + assert(*b[j]==10); + assert(*b[j]==13); + + // Test how we deal with reading off the end of an array + assert(a[100]==&a2); + assert(*a[100]==2); + + // Test how we deal with writing off the end of an array + a[100]=&a2; + assert(b[1]==&b1); + assert(*b[1]==11); + + // Test how we deal with merging for an index with one possible value when + // writing to an array + int ei0=40; + int ei1=41; + int *ei[3]={&ei0, &ei0, &ei0}; + ei[i]=&ei1; + assert(ei[0]==&ei1); + assert(ei[0]==&ei0); + assert(ei[2]==&ei0); + assert(ei[2]==&ei1); + assert(*ei[0]==41); + assert(*ei[0]==40); + assert(*ei[2]==40); + assert(*ei[2]==41); + + // Test how we deal with merging for an index with two possible values when + // writing to an array + int ej0=50; + int ej1=51; + int *ej[3]={&ej0, &ej0, &ej0}; + ej[j]=&ej1; + assert(ej[0]==&ej0); + assert(ej[2]==&ej0); + assert(ej[2]==&ej1); + assert(*ej[0]==50); + assert(*ej[2]==50); + assert(*ej[2]==51); + + // Test how we deal with merging for an index with two possible values when + // it means writing to an array element that may be out of bounds + int ek0=60; + int ek1=61; + int *ek[3]={&ek0, &ek0, &ek0}; + ek[k]=&ek1; + assert(ek[0]==&ek0); + assert(*ek[0]==60); + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/array_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/array_sensitivity_tests.c new file mode 100644 index 00000000000..68bace194c8 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/array_sensitivity_tests.c @@ -0,0 +1,101 @@ +#include + +int main(int argc, char *argv[]) +{ + // A uniform constant array + int a[3]={0, 0, 0}; + // A non-uniform constant array + int b[3]={1, 0, 0}; + + // Test if we can represent uniform constant arrays + assert(a[1]==0); + assert(a[1]==1); + + // Test if we can represent constant arrays which aren't uniform + assert(b[1]==0); + assert(b[1]==1); + + // Test alternative syntax for accessing an array value + assert(*(b+1)==0); + assert(*(b+1)==1); + assert(*(1+b)==0); + assert(*(1+b)==1); + assert(1[b]==0); + assert(1[b]==1); + + // c and d are arrays whose values requiring merging paths in the CFG. For + // c[0] there is only one possibility after merging and for d[0] there are + // two. + int c[3]={0, 0, 0}; + int d[3]={0, 0, 0}; + if(argc>2) + { + c[0]=0; + d[0]=1; + } + + // Test how well we can deal with merging for an array value + assert(c[0]==0); + assert(c[0]==1); + assert(d[0]==0); + assert(d[0]==2); + assert(d[1]==0); + + // The variables i, j and k will be used as indexes into arrays of size 3. + // They all require merging paths in the CFG. For i there is only one value on + // both paths, which is a valid index. The rest can each take two different + // values. For j both of these values are valid indexes. For k one is and one + // isn't. + int i=0; + int j=0; + int k=0; + if(argc>3) + { + i=0; + j=1; + k=100; + } + + // Test how well we can deal with merging for an index on a uniform array + assert(a[i]==0); + assert(a[i]==1); + assert(a[j]==0); + assert(a[j]==1); + + // Test how well we can deal with merging for an index on a non-uniform array + assert(b[i]==1); + assert(b[i]==0); + assert(b[j]==0); + assert(b[j]==1); + + // Test how we deal with reading off the end of an array + assert(a[100]==0); + + // Test how we deal with writing off the end of an array + a[100]=1; + assert(b[1]==0); + + // Test how we deal with merging for an index with one possible value when + // writing to an array + int ei[3]={0, 0, 0}; + ei[i]=1; + assert(ei[0]==1); + assert(ei[0]==0); + assert(ei[2]==0); + assert(ei[2]==1); + + // Test how we deal with merging for an index with two possible values when + // writing to an array + int ej[3]={0, 0, 0}; + ej[j]=1; + assert(ej[0]==0); + assert(ej[2]==0); + + // Test how we deal with merging for an index with two possible values when + // it means writing to an array element that may be out of bounds + int ek[3]={0, 0, 0}; + ek[k]=1; + assert(ek[0]==0); + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/char_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/char_sensitivity_tests.c new file mode 100644 index 00000000000..9e87454b68e --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/char_sensitivity_tests.c @@ -0,0 +1,10 @@ +#include + +int main(int argc, char *argv[]) +{ + // Test if we can represent constant chars + char x='a'; + assert(x=='a'); + assert(x=='b'); + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/float_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/float_sensitivity_tests.c new file mode 100644 index 00000000000..1f73fae4a6c --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/float_sensitivity_tests.c @@ -0,0 +1,10 @@ +#include + +int main(int argc, char *argv[]) +{ + // Test if we can represent constant floats + float x=0.0; + assert(x==0.0); + assert(x==1.0); + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/int_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/int_sensitivity_tests.c new file mode 100644 index 00000000000..ab4265a051f --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/int_sensitivity_tests.c @@ -0,0 +1,55 @@ +#include + +int main(int argc, char *argv[]) +{ + // Test how well we can represent ints, and also that the transformers are + // working correctly. + int x=0; + int y=0; + if(argc>2) + { + y=1; + } + assert(x==0); + assert(x==1); + assert(x==y); + + assert(x<1); + assert(x<-1); + assert(x-1); + assert(x>1); + assert(x>y); + + assert(x!=1); + assert(x!=0); + assert(x!=y); + + assert(!(x==1)); + assert(!(x==0)); + assert(!(x==y)); + + // Test how well we can represent an int when it has more than one possible + // value + assert(y<2); + assert(y>2); + assert(y==1); + + // Try copying a variable and then modifying the original + int z=x; + x=10; + assert(z==0); + assert(z==10); + + // Test how we treat assertions in unreachable code + x=0; + if(0) + { + assert(x==0); + assert(x==1); + assert(y==0); + } + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/pointer_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/pointer_sensitivity_tests.c new file mode 100644 index 00000000000..be328fa4a5d --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/pointer_sensitivity_tests.c @@ -0,0 +1,53 @@ +#include + +int main(int argc, char *argv[]) +{ + // Test how well we can represent pointers + // Basic use of addresses + int a=0; + int b=0; + int c=0; + int *x=&a; + int *x2=&a; + int *y=&b; + assert(x==&a); + assert(x==&b); + assert(x==x2); + assert(x==y); + + // Reading from a dereferenced pointer + assert(*x==0); + assert(*x==1); + + // Modify the referenced value and access it through the pointer again + a=1; + assert(*x==1); + assert(*x==0); + + // Writing to a dereferenced pointer + *x=2; + assert(a==2); + assert(a==0); + + // Conditionally reassign the pointer, but to the same value + if(argc>2) + { + x=&a; + } + assert(x==&a); + + // Conditionally reassign the pointer, to a different value this time + if(argc>3) + { + x=&b; + } + else + { + x=&c; + } + assert(*x==0); + assert(x==&a); + assert(x==&b); + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/pointer_to_array_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/pointer_to_array_sensitivity_tests.c new file mode 100644 index 00000000000..db9fe720e15 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/pointer_to_array_sensitivity_tests.c @@ -0,0 +1,59 @@ +#include +#include + +int main(int argc, char *argv[]) +{ + // Test reading from an array using a pointer + int a[3]={1, 2, 3}; + int *p=a; + assert(p==&a[0]); + assert(*p==1); + + // Test pointer arithmetic + int *q=&a[1]; + assert(q==p+1); + assert(*q==2); + + // Test pointer diffs + ptrdiff_t x=1; + assert(q-p==x); + + // Test writing into an array using a pointer + *q=4; + assert(a[1]==4); + a[1]=2; + + // We now explore pointers and indexes each with more than one possible value + int *r=&a[1]; + int b[3]={0, 0, 0}; + int *s=&b[1]; + int i=1; + if (argc>2) + { + r=&a[2]; + s=&b[2]; + i=2; + } + + // Test reading from an array using a pointer with more than one possible + // value + assert(*r==2); + assert(*r==1); + assert(*s==0); + assert(*s==1); + + // Test pointer arithmetic with an unknown index + int *t=&a[i]; + assert(t==p+i); + + // Test pointer diffs with an unknown index + ptrdiff_t y=i; + assert(t-p==y); + + // Test writing into an array using a pointer with an unknown index + *r=5; + assert(a[i]==5); + assert(a[1]==5); + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/pointer_to_pointer_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/pointer_to_pointer_sensitivity_tests.c new file mode 100644 index 00000000000..ee29a7059db --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/pointer_to_pointer_sensitivity_tests.c @@ -0,0 +1,24 @@ +#include + +int main(int argc, char *argv[]) +{ + // Test how well we can represent pointers to pointers + // Basic use of addresses + int a=0; + int *p=&a; + int **x=&p; + + // Reading from a pointer to a pointer that's been dereferenced twice + assert(**x==0); + assert(**x==1); + a=1; + assert(**x==1); + assert(**x==0); + + // Writing to a pointer to a pointer that's been dereferenced twice + **x=2; + assert(a==2); + assert(a==1); + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/pointer_to_struct_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/pointer_to_struct_sensitivity_tests.c new file mode 100644 index 00000000000..e0092afae4a --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/pointer_to_struct_sensitivity_tests.c @@ -0,0 +1,28 @@ +#include + +int main(int argc, char *argv[]) +{ + // Test how well we can represent pointers to structs + struct int_float + { + int a; + float b; + }; + struct int_float x={0, 1.0}; + x.a=0; + x.b=1.0; + struct int_float *p=&x; + assert((*p).a==0); + assert((*p).a==1); + + // Test alternative syntax + assert(p->a==0); + assert(p->a==1); + + // Test writing to the struct through the pointer + p->b=2.0; + assert(p->b==2.0); + assert(p->b==1.0); + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/struct_of_array_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/struct_of_array_sensitivity_tests.c new file mode 100644 index 00000000000..d5924b71ed7 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/struct_of_array_sensitivity_tests.c @@ -0,0 +1,58 @@ +#include + +int main(int argc, char *argv[]) +{ + // Test how well we can represent structs + struct int_array_float_array + { + int a[3]; + float b[3]; + }; + struct int_array_float_array x={{0, 1, 2}, {3.0f, 4.0f, 5.0f}}; + x.a[0]=0; + x.a[1]=1; + x.a[2]=2; + x.b[0]=3.0f; + x.b[1]=4.0f; + x.b[2]=5.0f; + assert(x.a[0]==0); + assert(*(x.a+0)==0); + assert(*(0+x.a)==0); + assert(0[x.a]==0); + + // Test merging when there is only one value on both paths + if(argc>2) + { + x.a[0]=0; + } + assert(x.a[0]==0); + assert(x.a[1]==1); + assert(x.b[0]==3.0f); + + // Test merging when there is one value for a and two values for b, to test if + // we are representing them separately + if(argc>3) + { + x.a[0]=0; + x.b[2]=15.0f; + } + assert(x.a[0]==0); + assert(x.a[1]==1); + assert(x.b[2]>0.0f); + assert(x.b[2]==15.0f); + assert(x.b[2]==1.0f); + assert(x.b[0]==3.0f); + + // Test merging when there are two values for a and b + if(argc>4) + { + x.a[0]=11; + x.b[2]=25.0f; + } + assert(x.a[0]<12); + assert(x.a[0]>2); + assert(x.a[0]==0); + assert(x.a[1]==1); + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/struct_of_pointer_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/struct_of_pointer_sensitivity_tests.c new file mode 100644 index 00000000000..3cde8011c2b --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/struct_of_pointer_sensitivity_tests.c @@ -0,0 +1,71 @@ +#include + +int main(int argc, char *argv[]) +{ + // Test how well we can represent structs of pointers + int a1=0; + int a2=1; + int a3=2; + float b1=10.0f; + float b2=11.0f; + float b3=12.0f; + float b4=13.0f; + struct int_float + { + int *a; + float *b; + }; + struct int_float x; + x.a=&a1; + x.b=&b1; + assert(x.a==&a1); + assert(x.a==&a2); + assert(x.b==&b1); + assert(x.b==&b2); + assert(*x.a==0); + assert(*x.a==100); + assert(*x.b==10.0f); + assert(*x.b==110.0f); + + // Test merging when there is only one value on both paths + if(argc>2) + { + x.a=&a1; + x.b=&b1; + } + assert(x.a==&a1); + assert(x.a==&a2); + assert(*x.a==0); + assert(*x.a==100); + + // Test merging when there is one value for a and two values for b, to test if + // we are representing them separately + if(argc>3) + { + x.a=&a1; + x.b=&b2; + } + assert(x.a==&a1); + assert(x.b==&b2); + assert(x.b==&b3); + assert(*x.a==0); + assert(*x.b==11.0f); + assert(*x.b==12.0f); + + // Test merging when there are two values for a and b + if(argc>4) + { + x.a=&a2; + x.b=&b3; + } + assert(x.a==&a2); + assert(x.a==&a3); + assert(x.b==&b3); + assert(x.b==&b4); + assert(*x.a==1); + assert(*x.a==2); + assert(*x.b==12.0f); + assert(*x.b==13.0f); + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/struct_of_struct_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/struct_of_struct_sensitivity_tests.c new file mode 100644 index 00000000000..ac6a32a0086 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/struct_of_struct_sensitivity_tests.c @@ -0,0 +1,55 @@ +#include + +int main(int argc, char *argv[]) +{ + // Test how well we can represent structs of structs + struct int_float + { + int a; + float b; + }; + struct two_int_floats + { + struct int_float s1; + struct int_float s2; + }; + struct two_int_floats x; + x.s1.a=0; + x.s1.b=1.0; + x.s2.a=2; + x.s2.b=3.0f; + assert(x.s1.a==0); + assert(x.s2.b==3.0f); + + // Test merging when there is only one value on both paths + if(argc>2) + { + x.s1.a=0; + } + assert(x.s1.a==0); + assert(x.s1.a==10); + + // Test merging when there is one value for s1 and two values for s2, to test + // if we are representing them separately + if(argc>3) + { + x.s1.b=1.0f; + x.s2.b=13.0f; + } + assert(x.s1.b==1.0f); + assert(x.s2.b==3.0f); + assert(x.s2.b==0.0f); + + // Test merging when there are two values for s1 and s2 + if(argc>4) + { + x.s1.a=20; + x.s2.a=22; + } + assert(x.s1.a==20); + assert(x.s1.a<30); + assert(x.s2.a==22); + assert(x.s2.a<30); + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-common-files/struct_sensitivity_tests.c b/regression/goto-analyzer/sensitivity-test-common-files/struct_sensitivity_tests.c new file mode 100644 index 00000000000..a4ad229e34c --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-common-files/struct_sensitivity_tests.c @@ -0,0 +1,47 @@ +#include + +int main(int argc, char *argv[]) +{ + // Test how well we can represent structs + struct int_float + { + int a; + float b; + }; + struct int_float x={0, 1.0f}; + x.a=0; + x.b=1.0f; + assert(x.a==0); + assert(x.a==1); + + // Test merging when there is only one value on both paths + if(argc>2) + { + x.a=0; + x.b=1.0f; + } + assert(x.a==0); + + // Test merging when there is one value for a and two values for b, to test if + // we are representing them separately + if(argc>3) + { + x.a=0; + x.b=2.0f; + } + assert(x.a==0); + assert(x.b>0.0f); + assert(x.b==1.0f); + + // Test merging when there are two values for a and b + if(argc>4) + { + x.a=1; + x.b=2.0f; + } + assert(x.a<2); + assert(x.a>2); + assert(x.a==1); + + return 0; +} diff --git a/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-array/sensitivity_test_constants_array_of_constants_array.c b/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-array/sensitivity_test_constants_array_of_constants_array.c new file mode 100644 index 00000000000..103849f7a32 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-array/sensitivity_test_constants_array_of_constants_array.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/array_of_array_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-array/test.desc b/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-array/test.desc new file mode 100644 index 00000000000..c8db44a2c09 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-array/test.desc @@ -0,0 +1,73 @@ +FUTURE +sensitivity_test_constants_array_of_constants_array.c +--variable --arrays --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion a\[1\]\[2\]==0: Success$ +^\[main.assertion.2\] .* assertion a\[1\]\[2\]==1: Failure \(if reachable\)$ +^\[main.assertion.3\] .* assertion b\[1\]\[2\]==5: Success$ +^\[main.assertion.4\] .* assertion b\[1\]\[2\]==0: Failure \(if reachable\)$ +^\[main.assertion.5\] .* assertion \*\(b\[1\]\+2\)==5: Success$ +^\[main.assertion.6\] .* assertion \*\(b\[1\]\+2\)==0: Failure \(if reachable\)$ +^\[main.assertion.7\] .* assertion \(\*\(b\+1\)\)\[2\]==5: Success$ +^\[main.assertion.8\] .* assertion \(\*\(b\+1\)\)\[2\]==0: Failure \(if reachable\)$ +^\[main.assertion.9\] .* assertion \*\(\*\(b\+1\)\+2\)==5: Success$ +^\[main.assertion.10\] .* assertion \*\(\*\(b\+1\)\+2\)==0: Failure \(if reachable\)$ +^\[main.assertion.11\] .* assertion 1\[b\]\[2\]==5: Success$ +^\[main.assertion.12\] .* assertion 1\[b\]\[2\]==0: Failure \(if reachable\)$ +^\[main.assertion.13\] .* assertion \*\(1\[b\]\+2\)==5: Success$ +^\[main.assertion.14\] .* assertion \*\(1\[b\]\+2\)==0: Failure \(if reachable\)$ +^\[main.assertion.15\] .* assertion \(\*\(1\+b\)\)\[2\]==5: Unknown$ +^\[main.assertion.16\] .* assertion \(\*\(1\+b\)\)\[2\]==0: Unknown$ +^\[main.assertion.17\] .* assertion \*\(\*\(1\+b\)\+2\)==5: Unknown$ +^\[main.assertion.18\] .* assertion \*\(\*\(1\+b\)\+2\)==0: Unknown$ +^\[main.assertion.19\] .* assertion 2\[1\[b\]\]==5: Success$ +^\[main.assertion.20\] .* assertion 2\[1\[b\]\]==0: Failure \(if reachable\)$ +^\[main.assertion.21\] .* assertion \*\(2\+1\[b\]\)==5: Unknown$ +^\[main.assertion.22\] .* assertion \*\(2\+1\[b\]\)==0: Unknown$ +^\[main.assertion.23\] .* assertion \*\(2\+\*\(1\+b\)\)==5: Unknown$ +^\[main.assertion.24\] .* assertion \*\(2\+\*\(1\+b\)\)==0: Unknown$ +^\[main.assertion.25\] .* assertion a\[0\]\[1\]==0: Success$ +^\[main.assertion.26\] .* assertion a\[0\]\[1\]==1: Failure \(if reachable\)$ +^\[main.assertion.27\] .* assertion a\[0\]\[2\]==0: Success$ +^\[main.assertion.28\] .* assertion b\[0\]\[1\]==2: Unknown$ +^\[main.assertion.29\] .* assertion b\[0\]\[1\]==3: Unknown$ +^\[main.assertion.30\] .* assertion b\[0\]\[2\]==2: Success$ +^\[main.assertion.31\] .* assertion a\[i\]\[1\]==0: Success$ +^\[main.assertion.32\] .* assertion a\[i\]\[1\]==1: Failure \(if reachable\)$ +^\[main.assertion.33\] .* assertion a\[1\]\[i\]==0: Success$ +^\[main.assertion.34\] .* assertion a\[1\]\[i\]==1: Failure \(if reachable\)$ +^\[main.assertion.35\] .* assertion a\[i\]\[i\]==0: Success$ +^\[main.assertion.36\] .* assertion a\[i\]\[i\]==1: Failure \(if reachable\)$ +^\[main.assertion.37\] .* assertion a\[j\]\[1\]==0: Unknown$ +^\[main.assertion.38\] .* assertion a\[j\]\[1\]==1: Unknown$ +^\[main.assertion.39\] .* assertion a\[1\]\[j\]==0: Unknown$ +^\[main.assertion.40\] .* assertion a\[1\]\[j\]==1: Unknown$ +^\[main.assertion.41\] .* assertion a\[j\]\[j\]==0: Unknown$ +^\[main.assertion.42\] .* assertion a\[j\]\[j\]==1: Unknown$ +^\[main.assertion.43\] .* assertion b\[i\]\[1\]==1: Success$ +^\[main.assertion.44\] .* assertion b\[i\]\[1\]==11: Failure \(if reachable\)$ +^\[main.assertion.45\] .* assertion b\[1\]\[i\]==3: Success$ +^\[main.assertion.46\] .* assertion b\[1\]\[i\]==11: Failure \(if reachable\)$ +^\[main.assertion.47\] .* assertion b\[i\]\[i\]==0: Success$ +^\[main.assertion.48\] .* assertion b\[i\]\[i\]==11: Failure \(if reachable\)$ +^\[main.assertion.49\] .* assertion b\[j\]\[1\]==1: Unknown$ +^\[main.assertion.50\] .* assertion b\[j\]\[1\]==11: Unknown$ +^\[main.assertion.51\] .* assertion b\[1\]\[j\]==3: Unknown$ +^\[main.assertion.52\] .* assertion b\[1\]\[j\]==11: Unknown$ +^\[main.assertion.53\] .* assertion b\[j\]\[j\]==0: Unknown$ +^\[main.assertion.54\] .* assertion b\[j\]\[j\]==11: Unknown$ +^\[main.assertion.55\] .* assertion a\[100\]\[0\]==0: Unknown$ +^\[main.assertion.56\] .* assertion a\[0\]\[100\]==0: Unknown$ +^\[main.assertion.57\] .* assertion c==0: Success$ +^\[main.assertion.58\] .* assertion c==0: Success$ +^\[main.assertion.59\] .* assertion ei\[0\]\[1\]==1: Success$ +^\[main.assertion.60\] .* assertion ei\[0\]\[1\]==0: Failure \(if reachable\)$ +^\[main.assertion.61\] .* assertion ei\[2\]\[1\]==0: Success$ +^\[main.assertion.62\] .* assertion ei\[2\]\[1\]==1: Failure \(if reachable\)$ +^\[main.assertion.63\] .* assertion ej\[0\]\[1\]==0: Unknown$ +^\[main.assertion.64\] .* assertion ej\[2\]\[1\]==0: Unknown$ +^\[main.assertion.65\] .* assertion ek\[0\]\[1\]==0: Unknown$ +^\[main.assertion.66\] .* assertion c==0: Success$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-pointer/sensitivity_test_constants_array_of_constants_pointer.c b/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-pointer/sensitivity_test_constants_array_of_constants_pointer.c new file mode 100644 index 00000000000..66edcccfbfb --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-pointer/sensitivity_test_constants_array_of_constants_pointer.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/array_of_pointer_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-pointer/test.desc b/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-pointer/test.desc new file mode 100644 index 00000000000..9242552c707 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-array-of-constants-pointer/test.desc @@ -0,0 +1,71 @@ +FUTURE +sensitivity_test_constants_array_of_constants_pointer.c +--variable --arrays --pointers --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion a\[1\]==&a0: Success$ +^\[main.assertion.2\] .* assertion a\[1\]==&a3: Failure \(if reachable\)$ +^\[main.assertion.3\] .* assertion \*a\[1\]==0: Success$ +^\[main.assertion.4\] .* assertion \*a\[1\]==3: Failure \(if reachable\)$ +^\[main.assertion.5\] .* assertion b\[1\]==&b1: Success$ +^\[main.assertion.6\] .* assertion b\[1\]==&b3: Failure \(if reachable\)$ +^\[main.assertion.7\] .* assertion \*b\[1\]==11: Success$ +^\[main.assertion.8\] .* assertion \*b\[1\]==13: Failure \(if reachable\)$ +^\[main.assertion.9\] .* assertion \*\(b\+1\)==&b1: Success$ +^\[main.assertion.10\] .* assertion \*\(b\+1\)==&b3: Failure \(if reachable\)$ +^\[main.assertion.11\] .* assertion \*\(1\+b\)==&b1: Unknown$ +^\[main.assertion.12\] .* assertion \*\(1\+b\)==&b3: Unknown$ +^\[main.assertion.13\] .* assertion 1\[b\]==&b1: Success$ +^\[main.assertion.14\] .* assertion 1\[b\]==&b3: Failure \(if reachable\)$ +^\[main.assertion.15\] .* assertion \*\*\(b\+1\)==11: Success$ +^\[main.assertion.16\] .* assertion \*\*\(b\+1\)==13: Failure \(if reachable\)$ +^\[main.assertion.17\] .* assertion \*\*\(1\+b\)==11: Unknown$ +^\[main.assertion.18\] .* assertion \*\*\(1\+b\)==13: Unknown$ +^\[main.assertion.19\] .* assertion \*1\[b\]==11: Success$ +^\[main.assertion.20\] .* assertion \*1\[b\]==13: Failure \(if reachable\)$ +^\[main.assertion.21\] .* assertion c\[0\]==&c0: Unknown$ +^\[main.assertion.22\] .* assertion c\[0\]==&c3: Unknown$ +^\[main.assertion.23\] .* assertion d\[0\]==&d0: Unknown$ +^\[main.assertion.24\] .* assertion d\[0\]==&d3: Unknown$ +^\[main.assertion.25\] .* assertion \*c\[0\]==20: Unknown$ +^\[main.assertion.26\] .* assertion \*c\[0\]==23: Unknown$ +^\[main.assertion.27\] .* assertion \*d\[0\]==30: Unknown$ +^\[main.assertion.28\] .* assertion \*d\[0\]==33: Unknown$ +^\[main.assertion.29\] .* assertion a\[i\]==&a0: Success$ +^\[main.assertion.30\] .* assertion a\[i\]==&a3: Failure \(if reachable\)$ +^\[main.assertion.31\] .* assertion a\[j\]==&a0: Unknown$ +^\[main.assertion.32\] .* assertion a\[j\]==&a3: Unknown$ +^\[main.assertion.33\] .* assertion \*a\[i\]==0: Success$ +^\[main.assertion.34\] .* assertion \*a\[i\]==3: Failure \(if reachable\)$ +^\[main.assertion.35\] .* assertion \*a\[j\]==0: Unknown$ +^\[main.assertion.36\] .* assertion \*a\[j\]==3: Unknown$ +^\[main.assertion.37\] .* assertion b\[i\]==&b0: Success$ +^\[main.assertion.38\] .* assertion b\[i\]==&b1: Failure \(if reachable\)$ +^\[main.assertion.39\] .* assertion b\[j\]==&b0: Unknown$ +^\[main.assertion.40\] .* assertion b\[j\]==&b3: Unknown$ +^\[main.assertion.41\] .* assertion \*b\[i\]==10: Success$ +^\[main.assertion.42\] .* assertion \*b\[i\]==11: Failure \(if reachable\)$ +^\[main.assertion.43\] .* assertion \*b\[j\]==10: Unknown$ +^\[main.assertion.44\] .* assertion \*b\[j\]==13: Unknown$ +^\[main.assertion.45\] .* assertion a\[100\]==&a2: Unknown$ +^\[main.assertion.46\] .* assertion \*a\[100\]==2: Unknown$ +^\[main.assertion.47\] .* assertion b\[1\]==&b1: Success$ +^\[main.assertion.48\] .* assertion \*b\[1\]==11: Success$ +^\[main.assertion.49\] .* assertion ei\[0\]==&ei1: Success$ +^\[main.assertion.50\] .* assertion ei\[0\]==&ei0: Failure \(if reachable\)$ +^\[main.assertion.51\] .* assertion ei\[2\]==&ei0: Success$ +^\[main.assertion.52\] .* assertion ei\[2\]==&ei1: Failure \(if reachable\)$ +^\[main.assertion.53\] .* assertion \*ei\[0\]==41: Success$ +^\[main.assertion.54\] .* assertion \*ei\[0\]==40: Failure \(if reachable\)$ +^\[main.assertion.55\] .* assertion \*ei\[2\]==40: Success$ +^\[main.assertion.56\] .* assertion \*ei\[2\]==41: Failure \(if reachable\)$ +^\[main.assertion.57\] .* assertion ej\[0\]==&ej0: Unknown$ +^\[main.assertion.58\] .* assertion ej\[2\]==&ej0: Unknown$ +^\[main.assertion.59\] .* assertion ej\[2\]==&ej1: Unknown$ +^\[main.assertion.60\] .* assertion \*ej\[0\]==50: Unknown$ +^\[main.assertion.61\] .* assertion \*ej\[2\]==50: Unknown$ +^\[main.assertion.62\] .* assertion \*ej\[2\]==51: Unknown$ +^\[main.assertion.63\] .* assertion ek\[0\]==&ek0: Unknown$ +^\[main.assertion.64\] .* assertion \*ek\[0\]==60: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-array-of-two-value-pointer/sensitivity_test_constants_array_of_two_value_pointer.c b/regression/goto-analyzer/sensitivity-test-constants-array-of-two-value-pointer/sensitivity_test_constants_array_of_two_value_pointer.c new file mode 100644 index 00000000000..66edcccfbfb --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-array-of-two-value-pointer/sensitivity_test_constants_array_of_two_value_pointer.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/array_of_pointer_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-array-of-two-value-pointer/test.desc b/regression/goto-analyzer/sensitivity-test-constants-array-of-two-value-pointer/test.desc new file mode 100644 index 00000000000..74f5f128ed6 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-array-of-two-value-pointer/test.desc @@ -0,0 +1,71 @@ +FUTURE +sensitivity_test_constants_array_of_two_value_pointer.c +--variable --arrays --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion a\[1\]==&a0: Unknown$ +^\[main.assertion.2\] .* assertion a\[1\]==&a3: Unknown$ +^\[main.assertion.3\] .* assertion \*a\[1\]==0: Unknown$ +^\[main.assertion.4\] .* assertion \*a\[1\]==3: Unknown$ +^\[main.assertion.5\] .* assertion b\[1\]==&b1: Unknown$ +^\[main.assertion.6\] .* assertion b\[1\]==&b3: Unknown$ +^\[main.assertion.7\] .* assertion \*b\[1\]==11: Unknown$ +^\[main.assertion.8\] .* assertion \*b\[1\]==13: Unknown$ +^\[main.assertion.9\] .* assertion \*\(b\+1\)==&b1: Unknown$ +^\[main.assertion.10\] .* assertion \*\(b\+1\)==&b3: Unknown$ +^\[main.assertion.11\] .* assertion \*\(1\+b\)==&b1: Unknown$ +^\[main.assertion.12\] .* assertion \*\(1\+b\)==&b3: Unknown$ +^\[main.assertion.13\] .* assertion 1\[b\]==&b1: Unknown$ +^\[main.assertion.14\] .* assertion 1\[b\]==&b3: Unknown$ +^\[main.assertion.15\] .* assertion \*\*\(b\+1\)==11: Unknown$ +^\[main.assertion.16\] .* assertion \*\*\(b\+1\)==13: Unknown$ +^\[main.assertion.17\] .* assertion \*\*\(1\+b\)==11: Unknown$ +^\[main.assertion.18\] .* assertion \*\*\(1\+b\)==13: Unknown$ +^\[main.assertion.19\] .* assertion \*1\[b\]==11: Unknown$ +^\[main.assertion.20\] .* assertion \*1\[b\]==13: Unknown$ +^\[main.assertion.21\] .* assertion c\[0\]==&c0: Unknown$ +^\[main.assertion.22\] .* assertion c\[0\]==&c3: Unknown$ +^\[main.assertion.23\] .* assertion d\[0\]==&d0: Unknown$ +^\[main.assertion.24\] .* assertion d\[0\]==&d3: Unknown$ +^\[main.assertion.25\] .* assertion \*c\[0\]==20: Unknown$ +^\[main.assertion.26\] .* assertion \*c\[0\]==23: Unknown$ +^\[main.assertion.27\] .* assertion \*d\[0\]==30: Unknown$ +^\[main.assertion.28\] .* assertion \*d\[0\]==33: Unknown$ +^\[main.assertion.29\] .* assertion a\[i\]==&a0: Unknown$ +^\[main.assertion.30\] .* assertion a\[i\]==&a3: Unknown$ +^\[main.assertion.31\] .* assertion a\[j\]==&a0: Unknown$ +^\[main.assertion.32\] .* assertion a\[j\]==&a3: Unknown$ +^\[main.assertion.33\] .* assertion \*a\[i\]==0: Unknown$ +^\[main.assertion.34\] .* assertion \*a\[i\]==3: Unknown$ +^\[main.assertion.35\] .* assertion \*a\[j\]==0: Unknown$ +^\[main.assertion.36\] .* assertion \*a\[j\]==3: Unknown$ +^\[main.assertion.37\] .* assertion b\[i\]==&b0: Unknown$ +^\[main.assertion.38\] .* assertion b\[i\]==&b1: Unknown$ +^\[main.assertion.39\] .* assertion b\[j\]==&b0: Unknown$ +^\[main.assertion.40\] .* assertion b\[j\]==&b3: Unknown$ +^\[main.assertion.41\] .* assertion \*b\[i\]==10: Unknown$ +^\[main.assertion.42\] .* assertion \*b\[i\]==11: Unknown$ +^\[main.assertion.43\] .* assertion \*b\[j\]==10: Unknown$ +^\[main.assertion.44\] .* assertion \*b\[j\]==13: Unknown$ +^\[main.assertion.45\] .* assertion a\[100\]==&a2: Unknown$ +^\[main.assertion.46\] .* assertion \*a\[100\]==2: Unknown$ +^\[main.assertion.47\] .* assertion b\[1\]==&b1: Unknown$ +^\[main.assertion.48\] .* assertion \*b\[1\]==11: Unknown$ +^\[main.assertion.49\] .* assertion ei\[0\]==&ei1: Unknown$ +^\[main.assertion.50\] .* assertion ei\[0\]==&ei0: Unknown$ +^\[main.assertion.51\] .* assertion ei\[2\]==&ei0: Unknown$ +^\[main.assertion.52\] .* assertion ei\[2\]==&ei1: Unknown$ +^\[main.assertion.53\] .* assertion \*ei\[0\]==41: Unknown$ +^\[main.assertion.54\] .* assertion \*ei\[0\]==40: Unknown$ +^\[main.assertion.55\] .* assertion \*ei\[2\]==40: Unknown$ +^\[main.assertion.56\] .* assertion \*ei\[2\]==41: Unknown$ +^\[main.assertion.57\] .* assertion ej\[0\]==&ej0: Unknown$ +^\[main.assertion.58\] .* assertion ej\[2\]==&ej0: Unknown$ +^\[main.assertion.59\] .* assertion ej\[2\]==&ej1: Unknown$ +^\[main.assertion.60\] .* assertion \*ej\[0\]==50: Unknown$ +^\[main.assertion.61\] .* assertion \*ej\[2\]==50: Unknown$ +^\[main.assertion.62\] .* assertion \*ej\[2\]==51: Unknown$ +^\[main.assertion.63\] .* assertion ek\[0\]==&ek0: Unknown$ +^\[main.assertion.64\] .* assertion \*ek\[0\]==60: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-array/sensitivity_test_constants_array.c b/regression/goto-analyzer/sensitivity-test-constants-array/sensitivity_test_constants_array.c new file mode 100644 index 00000000000..e0a5a37a2a2 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-array/sensitivity_test_constants_array.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/array_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-array/test.desc b/regression/goto-analyzer/sensitivity-test-constants-array/test.desc new file mode 100644 index 00000000000..b48a2c823ca --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-array/test.desc @@ -0,0 +1,39 @@ +FUTURE +sensitivity_test_constants_array.c +--variable --arrays --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion a\[1\]==0: Success$ +^\[main.assertion.2\] .* assertion a\[1\]==1: Failure \(if reachable\)$ +^\[main.assertion.3\] .* assertion b\[1\]==0: Success$ +^\[main.assertion.4\] .* assertion b\[1\]==1: Failure \(if reachable\)$ +^\[main.assertion.5\] .* assertion \*\(b\+1\)==0: Success$ +^\[main.assertion.6\] .* assertion \*\(b\+1\)==1: Failure \(if reachable\)$ +^\[main.assertion.7\] .* assertion \*\(1\+b\)==0: Unknown$ +^\[main.assertion.8\] .* assertion \*\(1\+b\)==1: Unknown$ +^\[main.assertion.9\] .* assertion 1\[b\]==0: Success$ +^\[main.assertion.10\] .* assertion 1\[b\]==1: Failure \(if reachable\)$ +^\[main.assertion.11\] .* assertion c\[0\]==0: Success$ +^\[main.assertion.12\] .* assertion c\[0\]==1: Failure \(if reachable\)$ +^\[main.assertion.13\] .* assertion d\[0\]==0: Unknown$ +^\[main.assertion.14\] .* assertion d\[0\]==2: Unknown$ +^\[main.assertion.15\] .* assertion d\[1\]==0: Success$ +^\[main.assertion.16\] .* assertion a\[i\]==0: Success$ +^\[main.assertion.17\] .* assertion a\[i\]==1: Failure \(if reachable\)$ +^\[main.assertion.18\] .* assertion a\[j\]==0: Unknown$ +^\[main.assertion.19\] .* assertion a\[j\]==1: Unknown$ +^\[main.assertion.20\] .* assertion b\[i\]==1: Success$ +^\[main.assertion.21\] .* assertion b\[i\]==0: Failure \(if reachable\)$ +^\[main.assertion.22\] .* assertion b\[j\]==0: Unknown$ +^\[main.assertion.23\] .* assertion b\[j\]==1: Unknown$ +^\[main.assertion.24\] .* assertion a\[100\]==0: Unknown$ +^\[main.assertion.25\] .* assertion b\[1\]==0: Success$ +^\[main.assertion.26\] .* assertion ei\[0\]==1: Success$ +^\[main.assertion.27\] .* assertion ei\[0\]==0: Failure \(if reachable\)$ +^\[main.assertion.28\] .* assertion ei\[2\]==0: Success$ +^\[main.assertion.29\] .* assertion ei\[2\]==1: Failure \(if reachable\)$ +^\[main.assertion.30\] .* assertion ej\[0\]==0: Unknown$ +^\[main.assertion.31\] .* assertion ej\[2\]==0: Unknown$ +^\[main.assertion.32\] .* assertion ek\[0\]==0: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-char/sensitivity_test_constants_char.c b/regression/goto-analyzer/sensitivity-test-constants-char/sensitivity_test_constants_char.c new file mode 100644 index 00000000000..b97be63e211 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-char/sensitivity_test_constants_char.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/char_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-char/test.desc b/regression/goto-analyzer/sensitivity-test-constants-char/test.desc new file mode 100644 index 00000000000..4ae7832010b --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-char/test.desc @@ -0,0 +1,9 @@ +FUTURE +sensitivity_test_constants_char.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x=='a': Success$ +^\[main.assertion.2\] .* assertion x=='b': Failure \(if reachable\)$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-float/sensitivity_test_constants_float.c b/regression/goto-analyzer/sensitivity-test-constants-float/sensitivity_test_constants_float.c new file mode 100644 index 00000000000..4e801235552 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-float/sensitivity_test_constants_float.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/float_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-float/test.desc b/regression/goto-analyzer/sensitivity-test-constants-float/test.desc new file mode 100644 index 00000000000..634ea862f56 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-float/test.desc @@ -0,0 +1,9 @@ +FUTURE +sensitivity_test_constants_float.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x==0.0: Success$ +^\[main.assertion.2\] .* assertion x==1.0: Failure \(if reachable\)$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-int/sensitivity_test_constants_int.c b/regression/goto-analyzer/sensitivity-test-constants-int/sensitivity_test_constants_int.c new file mode 100644 index 00000000000..8a0f75feb97 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-int/sensitivity_test_constants_int.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/int_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-int/test.desc b/regression/goto-analyzer/sensitivity-test-constants-int/test.desc new file mode 100644 index 00000000000..d3c274a9447 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-int/test.desc @@ -0,0 +1,30 @@ +FUTURE +sensitivity_test_constants_int.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x==0: Success$ +^\[main.assertion.2\] .* assertion x==1: Failure \(if reachable\)$ +^\[main.assertion.3\] .* assertion x==y: Unknown$ +^\[main.assertion.4\] .* assertion x<1: Success$ +^\[main.assertion.5\] .* assertion x<-1: Failure \(if reachable\)$ +^\[main.assertion.6\] .* assertion x-1: Success$ +^\[main.assertion.8\] .* assertion x>1: Failure \(if reachable\)$ +^\[main.assertion.9\] .* assertion x>y: Unknown$ +^\[main.assertion.10\] .* assertion x!=1: Success$ +^\[main.assertion.11\] .* assertion x!=0: Failure \(if reachable\)$ +^\[main.assertion.12\] .* assertion x!=y: Unknown$ +^\[main.assertion.13\] .* assertion !\(x==1\): Success$ +^\[main.assertion.14\] .* assertion !\(x==0\): Failure \(if reachable\)$ +^\[main.assertion.15\] .* assertion !\(x==y\): Unknown$ +^\[main.assertion.16\] .* assertion y<2: Unknown$ +^\[main.assertion.17\] .* assertion y>2: Unknown$ +^\[main.assertion.18\] .* assertion y==1: Unknown$ +^\[main.assertion.19\] .* assertion z==0: Success$ +^\[main.assertion.20\] .* assertion z==10: Failure \(if reachable\)$ +^\[main.assertion.21\] .* assertion x==0: Success \(unreachable\)$ +^\[main.assertion.22\] .* assertion x==1: Success \(unreachable\)$ +^\[main.assertion.23\] .* assertion y==0: Success \(unreachable\)$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-array/sensitivity_test_constants_pointer_to_constants_array.c b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-array/sensitivity_test_constants_pointer_to_constants_array.c new file mode 100644 index 00000000000..082fe2e62c8 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-array/sensitivity_test_constants_pointer_to_constants_array.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/pointer_to_array_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-array/test.desc b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-array/test.desc new file mode 100644 index 00000000000..7ccb164ab0f --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-array/test.desc @@ -0,0 +1,21 @@ +FUTURE +sensitivity_test_constants_pointer_to_constants_array.c +--variable --pointers --arrays --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion p==&a\[0\]: Success$ +^\[main.assertion.2\] .* assertion \*p==1: Success$ +^\[main.assertion.3\] .* assertion q==p\+1: Unknown$ +^\[main.assertion.4\] .* assertion \*q==2: Unknown$ +^\[main.assertion.5\] .* assertion q-p==x: Unknown$ +^\[main.assertion.6\] .* assertion a\[1\]==4: Unknown$ +^\[main.assertion.7\] .* assertion \*r==2: Unknown$ +^\[main.assertion.8\] .* assertion \*r==1: Unknown$ +^\[main.assertion.9\] .* assertion \*s==0: Unknown$ +^\[main.assertion.10\] .* assertion \*s==1: Unknown$ +^\[main.assertion.11\] .* assertion t==p\+i: Unknown$ +^\[main.assertion.12\] .* assertion t-p==y: Unknown$ +^\[main.assertion.13\] .* assertion a\[i\]==5: Unknown$ +^\[main.assertion.14\] .* assertion a\[1\]==5: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-pointer/sensitivity_test_constants_pointer_to_constants_pointer.c b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-pointer/sensitivity_test_constants_pointer_to_constants_pointer.c new file mode 100644 index 00000000000..56e6edc1093 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-pointer/sensitivity_test_constants_pointer_to_constants_pointer.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/pointer_to_pointer_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-pointer/test.desc b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-pointer/test.desc new file mode 100644 index 00000000000..f7fa1706d6a --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-pointer/test.desc @@ -0,0 +1,13 @@ +FUTURE +sensitivity_test_constants_pointer_to_constants_pointer.c +--variable --pointers --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion \*\*x==0: Success$ +^\[main.assertion.2\] .* assertion \*\*x==1: Failure \(if reachable\)$ +^\[main.assertion.3\] .* assertion \*\*x==1: Success$ +^\[main.assertion.4\] .* assertion \*\*x==0: Failure \(if reachable\)$ +^\[main.assertion.5\] .* assertion a==2: Success$ +^\[main.assertion.6\] .* assertion a==1: Failure \(if reachable\)$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-struct/sensitivity_test_constants_pointer_to_constants_struct.c b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-struct/sensitivity_test_constants_pointer_to_constants_struct.c new file mode 100644 index 00000000000..8f86047a407 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-struct/sensitivity_test_constants_pointer_to_constants_struct.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/pointer_to_struct_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-struct/test.desc b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-struct/test.desc new file mode 100644 index 00000000000..c7abd5e6821 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-constants-struct/test.desc @@ -0,0 +1,16 @@ +KNOWNBUG +sensitivity_test_constants_pointer_to_constants_struct.c +--variable --pointers --structs --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion \(\*p\).a==0: Success$ +^\[main.assertion.2\] .* assertion \(\*p\).a==1: Failure \(if reachable\)$ +^\[main.assertion.3\] .* assertion p->a==0: Success$ +^\[main.assertion.4\] .* assertion p->a==1: Failure \(if reachable\)$ +^\[main.assertion.5\] .* assertion p->b==2.0: Success$ +^\[main.assertion.6\] .* assertion p->b==1.0: Failure \(if reachable\)$ +-- +^warning: ignoring +-- +The final two assertions are the wrong way round as modifying the pointer +does not seem to be propogating through. See #96 diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-array/sensitivity_test_constants_pointer_to_two_value_array.c b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-array/sensitivity_test_constants_pointer_to_two_value_array.c new file mode 100644 index 00000000000..082fe2e62c8 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-array/sensitivity_test_constants_pointer_to_two_value_array.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/pointer_to_array_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-array/test.desc b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-array/test.desc new file mode 100644 index 00000000000..7121e17040d --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-array/test.desc @@ -0,0 +1,21 @@ +FUTURE +sensitivity_test_constants_pointer_to_two_value_array.c +--variable --pointers --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion p==&a\[0\]: Success$ +^\[main.assertion.2\] .* assertion \*p==1: Unknown$ +^\[main.assertion.3\] .* assertion q==p\+1: Unknown$ +^\[main.assertion.4\] .* assertion \*q==2: Unknown$ +^\[main.assertion.5\] .* assertion q-p==x: Unknown$ +^\[main.assertion.6\] .* assertion a\[1\]==4: Unknown$ +^\[main.assertion.7\] .* assertion \*r==2: Unknown$ +^\[main.assertion.8\] .* assertion \*r==1: Unknown$ +^\[main.assertion.9\] .* assertion \*s==0: Unknown$ +^\[main.assertion.10\] .* assertion \*s==1: Unknown$ +^\[main.assertion.11\] .* assertion t==p\+i: Unknown$ +^\[main.assertion.12\] .* assertion t-p==y: Unknown$ +^\[main.assertion.13\] .* assertion a\[i\]==5: Unknown$ +^\[main.assertion.14\] .* assertion a\[1\]==5: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-struct/sensitivity_test_constants_pointer_to_two_value_struct.c b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-struct/sensitivity_test_constants_pointer_to_two_value_struct.c new file mode 100644 index 00000000000..8f86047a407 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-struct/sensitivity_test_constants_pointer_to_two_value_struct.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/pointer_to_struct_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-struct/test.desc b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-struct/test.desc new file mode 100644 index 00000000000..a214499b34b --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer-to-two-value-struct/test.desc @@ -0,0 +1,13 @@ +FUTURE +sensitivity_test_constants_pointer_to_two_value_struct.c +--variable --pointers --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion \(\*p\).a==0: Unknown$ +^\[main.assertion.2\] .* assertion \(\*p\).a==1: Unknown$ +^\[main.assertion.3\] .* assertion p->a==0: Unknown$ +^\[main.assertion.4\] .* assertion p->a==1: Unknown$ +^\[main.assertion.5\] .* assertion p->b==2.0: Unknown$ +^\[main.assertion.6\] .* assertion p->b==1.0: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer/sensitivity_test_constants_pointer.c b/regression/goto-analyzer/sensitivity-test-constants-pointer/sensitivity_test_constants_pointer.c new file mode 100644 index 00000000000..a2167bc68f4 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer/sensitivity_test_constants_pointer.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/pointer_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-pointer/test.desc b/regression/goto-analyzer/sensitivity-test-constants-pointer/test.desc new file mode 100644 index 00000000000..22c179f2233 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-pointer/test.desc @@ -0,0 +1,21 @@ +FUTURE +sensitivity_test_constants_pointer.c +--variable --pointers --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x==&a: Success$ +^\[main.assertion.2\] .* assertion x==&b: Failure \(if reachable\)$ +^\[main.assertion.3\] .* assertion x==x2: Success$ +^\[main.assertion.4\] .* assertion x==y: Failure \(if reachable\)$ +^\[main.assertion.5\] .* assertion \*x==0: Success$ +^\[main.assertion.6\] .* assertion \*x==1: Failure \(if reachable\)$ +^\[main.assertion.7\] .* assertion \*x==1: Success$ +^\[main.assertion.8\] .* assertion \*x==0: Failure \(if reachable\)$ +^\[main.assertion.9\] .* assertion a==2: Success$ +^\[main.assertion.10\] .* assertion a==0: Failure \(if reachable\)$ +^\[main.assertion.11\] .* assertion x==&a: Success$ +^\[main.assertion.12\] .* assertion \*x==0: Unknown$ +^\[main.assertion.13\] .* assertion x==&a: Unknown$ +^\[main.assertion.14\] .* assertion x==&b: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-array/sensitivity_test_constants_struct_of_constants_array.c b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-array/sensitivity_test_constants_struct_of_constants_array.c new file mode 100644 index 00000000000..d50aea1ea24 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-array/sensitivity_test_constants_struct_of_constants_array.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/struct_of_array_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-array/test.desc b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-array/test.desc new file mode 100644 index 00000000000..7b6ae24bf61 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-array/test.desc @@ -0,0 +1,24 @@ +FUTURE +sensitivity_test_constants_struct_of_constants_array.c +--variable --structs --arrays --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x.a\[0\]==0: Success$ +^\[main.assertion.2\] .* assertion \*\(x.a\+0\)==0: Success$ +^\[main.assertion.3\] .* assertion \*\(0\+x.a\)==0: Success$ +^\[main.assertion.4\] .* assertion 0\[x.a\]==0: Success$ +^\[main.assertion.5\] .* assertion x.a\[0\]==0: Success$ +^\[main.assertion.6\] .* assertion x.a\[1\]==1: Success$ +^\[main.assertion.7\] .* assertion x.b\[0\]==3.0f: Success$ +^\[main.assertion.8\] .* assertion x.a\[0\]==0: Success$ +^\[main.assertion.9\] .* assertion x.a\[1\]==1: Success$ +^\[main.assertion.10\] .* assertion x.b\[2\]>0.0f: Unknown$ +^\[main.assertion.11\] .* assertion x.b\[2\]==15.0f: Unknown$ +^\[main.assertion.12\] .* assertion x.b\[2\]==1.0f: Unknown$ +^\[main.assertion.13\] .* assertion x.b\[0\]==3.0f: Success$ +^\[main.assertion.14\] .* assertion x.a\[0\]<12: Unknown$ +^\[main.assertion.15\] .* assertion x.a\[0\]>2: Unknown$ +^\[main.assertion.16\] .* assertion x.a\[0\]==0: Unknown$ +^\[main.assertion.17\] .* assertion x.a\[1\]==1: Success$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-pointer/sensitivity_test_constants_struct_of_constants_pointer.c b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-pointer/sensitivity_test_constants_struct_of_constants_pointer.c new file mode 100644 index 00000000000..ab7d896ae5d --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-pointer/sensitivity_test_constants_struct_of_constants_pointer.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/struct_of_pointer_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-pointer/test.desc b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-pointer/test.desc new file mode 100644 index 00000000000..b278a7ed47c --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-pointer/test.desc @@ -0,0 +1,33 @@ +FUTURE +sensitivity_test_constants_struct_of_constants_pointer.c +--variable --structs --pointers --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x.a==&a1: Success$ +^\[main.assertion.2\] .* assertion x.a==&a2: Failure \(if reachable\)$ +^\[main.assertion.3\] .* assertion x.b==&b1: Success$ +^\[main.assertion.4\] .* assertion x.b==&b2: Failure \(if reachable\)$ +^\[main.assertion.5\] .* assertion \*x.a==0: Success$ +^\[main.assertion.6\] .* assertion \*x.a==100: Failure \(if reachable\)$ +^\[main.assertion.7\] .* assertion \*x.b==10.0f: Success$ +^\[main.assertion.8\] .* assertion \*x.b==110.0f: Failure \(if reachable\)$ +^\[main.assertion.9\] .* assertion x.a==&a1: Success$ +^\[main.assertion.10\] .* assertion x.a==&a2: Failure \(if reachable\)$ +^\[main.assertion.11\] .* assertion \*x.a==0: Success$ +^\[main.assertion.12\] .* assertion \*x.a==100: Failure \(if reachable\)$ +^\[main.assertion.13\] .* assertion x.a==&a1: Success$ +^\[main.assertion.14\] .* assertion x.b==&b2: Unknown$ +^\[main.assertion.15\] .* assertion x.b==&b3: Unknown$ +^\[main.assertion.16\] .* assertion \*x.a==0: Success$ +^\[main.assertion.17\] .* assertion \*x.b==11.0f: Unknown$ +^\[main.assertion.18\] .* assertion \*x.b==12.0f: Unknown$ +^\[main.assertion.19\] .* assertion x.a==&a2: Unknown$ +^\[main.assertion.20\] .* assertion x.a==&a3: Unknown$ +^\[main.assertion.21\] .* assertion x.b==&b3: Unknown$ +^\[main.assertion.22\] .* assertion x.b==&b4: Unknown$ +^\[main.assertion.23\] .* assertion \*x.a==1: Unknown$ +^\[main.assertion.24\] .* assertion \*x.a==2: Unknown$ +^\[main.assertion.25\] .* assertion \*x.b==12.0f: Unknown$ +^\[main.assertion.26\] .* assertion \*x.b==13.0f: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-struct/sensitivity_test_constants_struct_of_constants_struct.c b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-struct/sensitivity_test_constants_struct_of_constants_struct.c new file mode 100644 index 00000000000..ae2ab34d038 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-struct/sensitivity_test_constants_struct_of_constants_struct.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/struct_of_struct_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-struct/test.desc b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-struct/test.desc new file mode 100644 index 00000000000..28f2e09614a --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct-of-constants-struct/test.desc @@ -0,0 +1,18 @@ +FUTURE +sensitivity_test_constants_struct_of_constants_struct.c +--variable --structs --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x.s1.a==0: Success$ +^\[main.assertion.2\] .* assertion x.s2.b==3.0f: Success$ +^\[main.assertion.3\] .* assertion x.s1.a==0: Success$ +^\[main.assertion.4\] .* assertion x.s1.a==10: Failure \(if reachable\)$ +^\[main.assertion.5\] .* assertion x.s1.b==1.0f: Success$ +^\[main.assertion.6\] .* assertion x.s2.b==3.0f: Unknown$ +^\[main.assertion.7\] .* assertion x.s2.b==0.0f: Unknown$ +^\[main.assertion.8\] .* assertion x.s1.a==20: Unknown$ +^\[main.assertion.9\] .* assertion x.s1.a<30: Unknown$ +^\[main.assertion.10\] .* assertion x.s2.a==22: Unknown$ +^\[main.assertion.11\] .* assertion x.s2.a<30: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-array/sensitivity_test_constants_struct_of_two_value_array.c b/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-array/sensitivity_test_constants_struct_of_two_value_array.c new file mode 100644 index 00000000000..d50aea1ea24 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-array/sensitivity_test_constants_struct_of_two_value_array.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/struct_of_array_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-array/test.desc b/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-array/test.desc new file mode 100644 index 00000000000..30edb4b598c --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-array/test.desc @@ -0,0 +1,24 @@ +FUTURE +sensitivity_test_constants_struct_of_two_value_array.c +--variable --structs --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x.a\[0\]==0: Unknown$ +^\[main.assertion.2\] .* assertion \*\(x.a\+0\)==0: Unknown$ +^\[main.assertion.3\] .* assertion \*\(0\+x.a\)==0: Unknown$ +^\[main.assertion.4\] .* assertion 0\[x.a\]==0: Unknown$ +^\[main.assertion.5\] .* assertion x.a\[0\]==0: Unknown$ +^\[main.assertion.6\] .* assertion x.a\[1\]==1: Unknown$ +^\[main.assertion.7\] .* assertion x.b\[0\]==3.0f: Unknown$ +^\[main.assertion.8\] .* assertion x.a\[0\]==0: Unknown$ +^\[main.assertion.9\] .* assertion x.a\[1\]==1: Unknown$ +^\[main.assertion.10\] .* assertion x.b\[2\]>0.0f: Unknown$ +^\[main.assertion.11\] .* assertion x.b\[2\]==15.0f: Unknown$ +^\[main.assertion.12\] .* assertion x.b\[2\]==1.0f: Unknown$ +^\[main.assertion.13\] .* assertion x.b\[0\]==3.0f: Unknown$ +^\[main.assertion.14\] .* assertion x.a\[0\]<12: Unknown$ +^\[main.assertion.15\] .* assertion x.a\[0\]>2: Unknown$ +^\[main.assertion.16\] .* assertion x.a\[0\]==0: Unknown$ +^\[main.assertion.17\] .* assertion x.a\[1\]==1: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-pointer/sensitivity_test_constants_struct_of_two_value_pointer.c b/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-pointer/sensitivity_test_constants_struct_of_two_value_pointer.c new file mode 100644 index 00000000000..ab7d896ae5d --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-pointer/sensitivity_test_constants_struct_of_two_value_pointer.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/struct_of_pointer_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-pointer/test.desc b/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-pointer/test.desc new file mode 100644 index 00000000000..ea3a9cadb69 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct-of-two-value-pointer/test.desc @@ -0,0 +1,33 @@ +FUTURE +sensitivity_test_constants_struct_of_two_value_pointer.c +--variable --structs --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x.a==&a1: Unknown$ +^\[main.assertion.2\] .* assertion x.a==&a2: Unknown$ +^\[main.assertion.3\] .* assertion x.b==&b1: Unknown$ +^\[main.assertion.4\] .* assertion x.b==&b2: Unknown$ +^\[main.assertion.5\] .* assertion \*x.a==0: Unknown$ +^\[main.assertion.6\] .* assertion \*x.a==100: Unknown$ +^\[main.assertion.7\] .* assertion \*x.b==10.0f: Unknown$ +^\[main.assertion.8\] .* assertion \*x.b==110.0f: Unknown$ +^\[main.assertion.9\] .* assertion x.a==&a1: Unknown$ +^\[main.assertion.10\] .* assertion x.a==&a2: Unknown$ +^\[main.assertion.11\] .* assertion \*x.a==0: Unknown$ +^\[main.assertion.12\] .* assertion \*x.a==100: Unknown$ +^\[main.assertion.13\] .* assertion x.a==&a1: Unknown$ +^\[main.assertion.14\] .* assertion x.b==&b2: Unknown$ +^\[main.assertion.15\] .* assertion x.b==&b3: Unknown$ +^\[main.assertion.16\] .* assertion \*x.a==0: Unknown$ +^\[main.assertion.17\] .* assertion \*x.b==11.0f: Unknown$ +^\[main.assertion.18\] .* assertion \*x.b==12.0f: Unknown$ +^\[main.assertion.19\] .* assertion x.a==&a2: Unknown$ +^\[main.assertion.20\] .* assertion x.a==&a3: Unknown$ +^\[main.assertion.21\] .* assertion x.b==&b3: Unknown$ +^\[main.assertion.22\] .* assertion x.b==&b4: Unknown$ +^\[main.assertion.23\] .* assertion \*x.a==1: Unknown$ +^\[main.assertion.24\] .* assertion \*x.a==2: Unknown$ +^\[main.assertion.25\] .* assertion \*x.b==12.0f: Unknown$ +^\[main.assertion.26\] .* assertion \*x.b==13.0f: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct/sensitivity_test_constants_struct.c b/regression/goto-analyzer/sensitivity-test-constants-struct/sensitivity_test_constants_struct.c new file mode 100644 index 00000000000..946ec769d9e --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct/sensitivity_test_constants_struct.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/struct_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-constants-struct/test.desc b/regression/goto-analyzer/sensitivity-test-constants-struct/test.desc new file mode 100644 index 00000000000..64a15fcae85 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-constants-struct/test.desc @@ -0,0 +1,16 @@ +FUTURE +sensitivity_test_constants_struct.c +--variable --structs --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x.a==0: Success$ +^\[main.assertion.2\] .* assertion x.a==1: Failure \(if reachable\)$ +^\[main.assertion.3\] .* assertion x.a==0: Success$ +^\[main.assertion.4\] .* assertion x.a==0: Success$ +^\[main.assertion.5\] .* assertion x.b>0.0f: Unknown$ +^\[main.assertion.6\] .* assertion x.b==1.0f: Unknown$ +^\[main.assertion.7\] .* assertion x.a<2: Unknown$ +^\[main.assertion.8\] .* assertion x.a>2: Unknown$ +^\[main.assertion.9\] .* assertion x.a==1: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-array/sensitivity_test_two_value_array_of_two_value_array.c b/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-array/sensitivity_test_two_value_array_of_two_value_array.c new file mode 100644 index 00000000000..103849f7a32 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-array/sensitivity_test_two_value_array_of_two_value_array.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/array_of_array_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-array/test.desc b/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-array/test.desc new file mode 100644 index 00000000000..2c2c3ed15a8 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-array/test.desc @@ -0,0 +1,73 @@ +FUTURE +sensitivity_test_two_value_array_of_two_value_array.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion a\[1\]\[2\]==0: Unknown$ +^\[main.assertion.2\] .* assertion a\[1\]\[2\]==1: Unknown$ +^\[main.assertion.3\] .* assertion b\[1\]\[2\]==5: Unknown$ +^\[main.assertion.4\] .* assertion b\[1\]\[2\]==0: Unknown$ +^\[main.assertion.5\] .* assertion \*\(b\[1\]\+2\)==5: Unknown$ +^\[main.assertion.6\] .* assertion \*\(b\[1\]\+2\)==0: Unknown$ +^\[main.assertion.7\] .* assertion \(\*\(b\+1\)\)\[2\]==5: Unknown$ +^\[main.assertion.8\] .* assertion \(\*\(b\+1\)\)\[2\]==0: Unknown$ +^\[main.assertion.9\] .* assertion \*\(\*\(b\+1\)\+2\)==5: Unknown$ +^\[main.assertion.10\] .* assertion \*\(\*\(b\+1\)\+2\)==0: Unknown$ +^\[main.assertion.11\] .* assertion 1\[b\]\[2\]==5: Unknown$ +^\[main.assertion.12\] .* assertion 1\[b\]\[2\]==0: Unknown$ +^\[main.assertion.13\] .* assertion \*\(1\[b\]\+2\)==5: Unknown$ +^\[main.assertion.14\] .* assertion \*\(1\[b\]\+2\)==0: Unknown$ +^\[main.assertion.15\] .* assertion \(\*\(1\+b\)\)\[2\]==5: Unknown$ +^\[main.assertion.16\] .* assertion \(\*\(1\+b\)\)\[2\]==0: Unknown$ +^\[main.assertion.17\] .* assertion \*\(\*\(1\+b\)\+2\)==5: Unknown$ +^\[main.assertion.18\] .* assertion \*\(\*\(1\+b\)\+2\)==0: Unknown$ +^\[main.assertion.19\] .* assertion 2\[1\[b\]\]==5: Unknown$ +^\[main.assertion.20\] .* assertion 2\[1\[b\]\]==0: Unknown$ +^\[main.assertion.21\] .* assertion \*\(2\+1\[b\]\)==5: Unknown$ +^\[main.assertion.22\] .* assertion \*\(2\+1\[b\]\)==0: Unknown$ +^\[main.assertion.23\] .* assertion \*\(2\+\*\(1\+b\)\)==5: Unknown$ +^\[main.assertion.24\] .* assertion \*\(2\+\*\(1\+b\)\)==0: Unknown$ +^\[main.assertion.25\] .* assertion a\[0\]\[1\]==0: Unknown$ +^\[main.assertion.26\] .* assertion a\[0\]\[1\]==1: Unknown$ +^\[main.assertion.27\] .* assertion a\[0\]\[2\]==0: Unknown$ +^\[main.assertion.28\] .* assertion b\[0\]\[1\]==2: Unknown$ +^\[main.assertion.29\] .* assertion b\[0\]\[1\]==3: Unknown$ +^\[main.assertion.30\] .* assertion b\[0\]\[2\]==2: Unknown$ +^\[main.assertion.31\] .* assertion a\[i\]\[1\]==0: Unknown$ +^\[main.assertion.32\] .* assertion a\[i\]\[1\]==1: Unknown$ +^\[main.assertion.33\] .* assertion a\[1\]\[i\]==0: Unknown$ +^\[main.assertion.34\] .* assertion a\[1\]\[i\]==1: Unknown$ +^\[main.assertion.35\] .* assertion a\[i\]\[i\]==0: Unknown$ +^\[main.assertion.36\] .* assertion a\[i\]\[i\]==1: Unknown$ +^\[main.assertion.37\] .* assertion a\[j\]\[1\]==0: Unknown$ +^\[main.assertion.38\] .* assertion a\[j\]\[1\]==1: Unknown$ +^\[main.assertion.39\] .* assertion a\[1\]\[j\]==0: Unknown$ +^\[main.assertion.40\] .* assertion a\[1\]\[j\]==1: Unknown$ +^\[main.assertion.41\] .* assertion a\[j\]\[j\]==0: Unknown$ +^\[main.assertion.42\] .* assertion a\[j\]\[j\]==1: Unknown$ +^\[main.assertion.43\] .* assertion b\[i\]\[1\]==1: Unknown$ +^\[main.assertion.44\] .* assertion b\[i\]\[1\]==11: Unknown$ +^\[main.assertion.45\] .* assertion b\[1\]\[i\]==3: Unknown$ +^\[main.assertion.46\] .* assertion b\[1\]\[i\]==11: Unknown$ +^\[main.assertion.47\] .* assertion b\[i\]\[i\]==0: Unknown$ +^\[main.assertion.48\] .* assertion b\[i\]\[i\]==11: Unknown$ +^\[main.assertion.49\] .* assertion b\[j\]\[1\]==1: Unknown$ +^\[main.assertion.50\] .* assertion b\[j\]\[1\]==11: Unknown$ +^\[main.assertion.51\] .* assertion b\[1\]\[j\]==3: Unknown$ +^\[main.assertion.52\] .* assertion b\[1\]\[j\]==11: Unknown$ +^\[main.assertion.53\] .* assertion b\[j\]\[j\]==0: Unknown$ +^\[main.assertion.54\] .* assertion b\[j\]\[j\]==11: Unknown$ +^\[main.assertion.55\] .* assertion a\[100\]\[0\]==0: Unknown$ +^\[main.assertion.56\] .* assertion a\[0\]\[100\]==0: Unknown$ +^\[main.assertion.57\] .* assertion c==0: Success$ +^\[main.assertion.58\] .* assertion c==0: Success$ +^\[main.assertion.59\] .* assertion ei\[0\]\[1\]==1: Unknown$ +^\[main.assertion.60\] .* assertion ei\[0\]\[1\]==0: Unknown$ +^\[main.assertion.61\] .* assertion ei\[2\]\[1\]==0: Unknown$ +^\[main.assertion.62\] .* assertion ei\[2\]\[1\]==1: Unknown$ +^\[main.assertion.63\] .* assertion ej\[0\]\[1\]==0: Unknown$ +^\[main.assertion.64\] .* assertion ej\[2\]\[1\]==0: Unknown$ +^\[main.assertion.65\] .* assertion ek\[0\]\[1\]==0: Unknown$ +^\[main.assertion.66\] .* assertion c==0: Success$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-pointer/sensitivity_test_two_value_array_of_two_value_pointer.c b/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-pointer/sensitivity_test_two_value_array_of_two_value_pointer.c new file mode 100644 index 00000000000..66edcccfbfb --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-pointer/sensitivity_test_two_value_array_of_two_value_pointer.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/array_of_pointer_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-pointer/test.desc b/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-pointer/test.desc new file mode 100644 index 00000000000..f9de8e20a03 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-array-of-two-value-pointer/test.desc @@ -0,0 +1,71 @@ +FUTURE +sensitivity_test_two_value_array_of_two_value_pointer.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion a\[1\]==&a0: Unknown$ +^\[main.assertion.2\] .* assertion a\[1\]==&a3: Unknown$ +^\[main.assertion.3\] .* assertion \*a\[1\]==0: Unknown$ +^\[main.assertion.4\] .* assertion \*a\[1\]==3: Unknown$ +^\[main.assertion.5\] .* assertion b\[1\]==&b1: Unknown$ +^\[main.assertion.6\] .* assertion b\[1\]==&b3: Unknown$ +^\[main.assertion.7\] .* assertion \*b\[1\]==11: Unknown$ +^\[main.assertion.8\] .* assertion \*b\[1\]==13: Unknown$ +^\[main.assertion.9\] .* assertion \*\(b\+1\)==&b1: Unknown$ +^\[main.assertion.10\] .* assertion \*\(b\+1\)==&b3: Unknown$ +^\[main.assertion.11\] .* assertion \*\(1\+b\)==&b1: Unknown$ +^\[main.assertion.12\] .* assertion \*\(1\+b\)==&b3: Unknown$ +^\[main.assertion.13\] .* assertion 1\[b\]==&b1: Unknown$ +^\[main.assertion.14\] .* assertion 1\[b\]==&b3: Unknown$ +^\[main.assertion.15\] .* assertion \*\*\(b\+1\)==11: Unknown$ +^\[main.assertion.16\] .* assertion \*\*\(b\+1\)==13: Unknown$ +^\[main.assertion.17\] .* assertion \*\*\(1\+b\)==11: Unknown$ +^\[main.assertion.18\] .* assertion \*\*\(1\+b\)==13: Unknown$ +^\[main.assertion.19\] .* assertion \*1\[b\]==11: Unknown$ +^\[main.assertion.20\] .* assertion \*1\[b\]==13: Unknown$ +^\[main.assertion.21\] .* assertion c\[0\]==&c0: Unknown$ +^\[main.assertion.22\] .* assertion c\[0\]==&c3: Unknown$ +^\[main.assertion.23\] .* assertion d\[0\]==&d0: Unknown$ +^\[main.assertion.24\] .* assertion d\[0\]==&d3: Unknown$ +^\[main.assertion.25\] .* assertion \*c\[0\]==20: Unknown$ +^\[main.assertion.26\] .* assertion \*c\[0\]==23: Unknown$ +^\[main.assertion.27\] .* assertion \*d\[0\]==30: Unknown$ +^\[main.assertion.28\] .* assertion \*d\[0\]==33: Unknown$ +^\[main.assertion.29\] .* assertion a\[i\]==&a0: Unknown$ +^\[main.assertion.30\] .* assertion a\[i\]==&a3: Unknown$ +^\[main.assertion.31\] .* assertion a\[j\]==&a0: Unknown$ +^\[main.assertion.32\] .* assertion a\[j\]==&a3: Unknown$ +^\[main.assertion.33\] .* assertion \*a\[i\]==0: Unknown$ +^\[main.assertion.34\] .* assertion \*a\[i\]==3: Unknown$ +^\[main.assertion.35\] .* assertion \*a\[j\]==0: Unknown$ +^\[main.assertion.36\] .* assertion \*a\[j\]==3: Unknown$ +^\[main.assertion.37\] .* assertion b\[i\]==&b0: Unknown$ +^\[main.assertion.38\] .* assertion b\[i\]==&b1: Unknown$ +^\[main.assertion.39\] .* assertion b\[j\]==&b0: Unknown$ +^\[main.assertion.40\] .* assertion b\[j\]==&b3: Unknown$ +^\[main.assertion.41\] .* assertion \*b\[i\]==10: Unknown$ +^\[main.assertion.42\] .* assertion \*b\[i\]==11: Unknown$ +^\[main.assertion.43\] .* assertion \*b\[j\]==10: Unknown$ +^\[main.assertion.44\] .* assertion \*b\[j\]==13: Unknown$ +^\[main.assertion.45\] .* assertion a\[100\]==&a2: Unknown$ +^\[main.assertion.46\] .* assertion \*a\[100\]==2: Unknown$ +^\[main.assertion.47\] .* assertion b\[1\]==&b1: Unknown$ +^\[main.assertion.48\] .* assertion \*b\[1\]==11: Unknown$ +^\[main.assertion.49\] .* assertion ei\[0\]==&ei1: Unknown$ +^\[main.assertion.50\] .* assertion ei\[0\]==&ei0: Unknown$ +^\[main.assertion.51\] .* assertion ei\[2\]==&ei0: Unknown$ +^\[main.assertion.52\] .* assertion ei\[2\]==&ei1: Unknown$ +^\[main.assertion.53\] .* assertion \*ei\[0\]==41: Unknown$ +^\[main.assertion.54\] .* assertion \*ei\[0\]==40: Unknown$ +^\[main.assertion.55\] .* assertion \*ei\[2\]==40: Unknown$ +^\[main.assertion.56\] .* assertion \*ei\[2\]==41: Unknown$ +^\[main.assertion.57\] .* assertion ej\[0\]==&ej0: Unknown$ +^\[main.assertion.58\] .* assertion ej\[2\]==&ej0: Unknown$ +^\[main.assertion.59\] .* assertion ej\[2\]==&ej1: Unknown$ +^\[main.assertion.60\] .* assertion \*ej\[0\]==50: Unknown$ +^\[main.assertion.61\] .* assertion \*ej\[2\]==50: Unknown$ +^\[main.assertion.62\] .* assertion \*ej\[2\]==51: Unknown$ +^\[main.assertion.63\] .* assertion ek\[0\]==&ek0: Unknown$ +^\[main.assertion.64\] .* assertion \*ek\[0\]==60: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-two-value-array/sensitivity_test_two_value_array.c b/regression/goto-analyzer/sensitivity-test-two-value-array/sensitivity_test_two_value_array.c new file mode 100644 index 00000000000..e0a5a37a2a2 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-array/sensitivity_test_two_value_array.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/array_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-two-value-array/test.desc b/regression/goto-analyzer/sensitivity-test-two-value-array/test.desc new file mode 100644 index 00000000000..23ee78bd74f --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-array/test.desc @@ -0,0 +1,39 @@ +FUTURE +sensitivity_test_two_value_array.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion a\[1\]==0: Unknown$ +^\[main.assertion.2\] .* assertion a\[1\]==1: Unknown$ +^\[main.assertion.3\] .* assertion b\[1\]==0: Unknown$ +^\[main.assertion.4\] .* assertion b\[1\]==1: Unknown$ +^\[main.assertion.5\] .* assertion \*\(b\+1\)==0: Unknown$ +^\[main.assertion.6\] .* assertion \*\(b\+1\)==1: Unknown$ +^\[main.assertion.7\] .* assertion \*\(1\+b\)==0: Unknown$ +^\[main.assertion.8\] .* assertion \*\(1\+b\)==1: Unknown$ +^\[main.assertion.9\] .* assertion 1\[b\]==0: Unknown$ +^\[main.assertion.10\] .* assertion 1\[b\]==1: Unknown$ +^\[main.assertion.11\] .* assertion c\[0\]==0: Unknown$ +^\[main.assertion.12\] .* assertion c\[0\]==1: Unknown$ +^\[main.assertion.13\] .* assertion d\[0\]==0: Unknown$ +^\[main.assertion.14\] .* assertion d\[0\]==2: Unknown$ +^\[main.assertion.15\] .* assertion d\[1\]==0: Unknown$ +^\[main.assertion.16\] .* assertion a\[i\]==0: Unknown$ +^\[main.assertion.17\] .* assertion a\[i\]==1: Unknown$ +^\[main.assertion.18\] .* assertion a\[j\]==0: Unknown$ +^\[main.assertion.19\] .* assertion a\[j\]==1: Unknown$ +^\[main.assertion.20\] .* assertion b\[i\]==1: Unknown$ +^\[main.assertion.21\] .* assertion b\[i\]==0: Unknown$ +^\[main.assertion.22\] .* assertion b\[j\]==0: Unknown$ +^\[main.assertion.23\] .* assertion b\[j\]==1: Unknown$ +^\[main.assertion.24\] .* assertion a\[100\]==0: Unknown$ +^\[main.assertion.25\] .* assertion b\[1\]==0: Unknown$ +^\[main.assertion.26\] .* assertion ei\[0\]==1: Unknown$ +^\[main.assertion.27\] .* assertion ei\[0\]==0: Unknown$ +^\[main.assertion.28\] .* assertion ei\[2\]==0: Unknown$ +^\[main.assertion.29\] .* assertion ei\[2\]==1: Unknown$ +^\[main.assertion.30\] .* assertion ej\[0\]==0: Unknown$ +^\[main.assertion.31\] .* assertion ej\[2\]==0: Unknown$ +^\[main.assertion.32\] .* assertion ek\[0\]==0: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-array/sensitivity_test_two_value_pointer_to_two_value_array.c b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-array/sensitivity_test_two_value_pointer_to_two_value_array.c new file mode 100644 index 00000000000..082fe2e62c8 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-array/sensitivity_test_two_value_pointer_to_two_value_array.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/pointer_to_array_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-array/test.desc b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-array/test.desc new file mode 100644 index 00000000000..974705f9fc1 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-array/test.desc @@ -0,0 +1,21 @@ +FUTURE +sensitivity_test_two_value_pointer_to_two_value_array.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion p==&a\[0\]: Unknown$ +^\[main.assertion.2\] .* assertion \*p==1: Unknown$ +^\[main.assertion.3\] .* assertion q==p\+1: Unknown$ +^\[main.assertion.4\] .* assertion \*q==2: Unknown$ +^\[main.assertion.5\] .* assertion q-p==x: Unknown$ +^\[main.assertion.6\] .* assertion a\[1\]==4: Unknown$ +^\[main.assertion.7\] .* assertion \*r==2: Unknown$ +^\[main.assertion.8\] .* assertion \*r==1: Unknown$ +^\[main.assertion.9\] .* assertion \*s==0: Unknown$ +^\[main.assertion.10\] .* assertion \*s==1: Unknown$ +^\[main.assertion.11\] .* assertion t==p\+i: Unknown$ +^\[main.assertion.12\] .* assertion t-p==y: Unknown$ +^\[main.assertion.13\] .* assertion a\[i\]==5: Unknown$ +^\[main.assertion.14\] .* assertion a\[1\]==5: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-pointer/sensitivity_test_two_value_pointer_to_two_value_pointer.c b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-pointer/sensitivity_test_two_value_pointer_to_two_value_pointer.c new file mode 100644 index 00000000000..56e6edc1093 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-pointer/sensitivity_test_two_value_pointer_to_two_value_pointer.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/pointer_to_pointer_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-pointer/test.desc b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-pointer/test.desc new file mode 100644 index 00000000000..e3582834688 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-pointer/test.desc @@ -0,0 +1,13 @@ +FUTURE +sensitivity_test_two_value_pointer_to_two_value_pointer.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion \*\*x==0: Unknown$ +^\[main.assertion.2\] .* assertion \*\*x==1: Unknown$ +^\[main.assertion.3\] .* assertion \*\*x==1: Unknown$ +^\[main.assertion.4\] .* assertion \*\*x==0: Unknown$ +^\[main.assertion.5\] .* assertion a==2: Unknown$ +^\[main.assertion.6\] .* assertion a==1: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-struct/sensitivity_test_two_value_pointer_to_two_value_struct.c b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-struct/sensitivity_test_two_value_pointer_to_two_value_struct.c new file mode 100644 index 00000000000..8f86047a407 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-struct/sensitivity_test_two_value_pointer_to_two_value_struct.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/pointer_to_struct_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-struct/test.desc b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-struct/test.desc new file mode 100644 index 00000000000..56a0be48407 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-pointer-to-two-value-struct/test.desc @@ -0,0 +1,13 @@ +FUTURE +sensitivity_test_two_value_pointer_to_two_value_struct.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion \(\*p\).a==0: Unknown$ +^\[main.assertion.2\] .* assertion \(\*p\).a==1: Unknown$ +^\[main.assertion.3\] .* assertion p->a==0: Unknown$ +^\[main.assertion.4\] .* assertion p->a==1: Unknown$ +^\[main.assertion.5\] .* assertion p->b==2.0: Unknown$ +^\[main.assertion.6\] .* assertion p->b==1.0: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-two-value-pointer/sensitivity_test_two_value_pointer.c b/regression/goto-analyzer/sensitivity-test-two-value-pointer/sensitivity_test_two_value_pointer.c new file mode 100644 index 00000000000..a2167bc68f4 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-pointer/sensitivity_test_two_value_pointer.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/pointer_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-two-value-pointer/test.desc b/regression/goto-analyzer/sensitivity-test-two-value-pointer/test.desc new file mode 100644 index 00000000000..da9abe2464f --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-pointer/test.desc @@ -0,0 +1,21 @@ +FUTURE +sensitivity_test_two_value_pointer.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x==&a: Unknown$ +^\[main.assertion.2\] .* assertion x==&b: Unknown$ +^\[main.assertion.3\] .* assertion x==x2: Unknown$ +^\[main.assertion.4\] .* assertion x==y: Unknown$ +^\[main.assertion.5\] .* assertion \*x==0: Unknown$ +^\[main.assertion.6\] .* assertion \*x==1: Unknown$ +^\[main.assertion.7\] .* assertion \*x==1: Unknown$ +^\[main.assertion.8\] .* assertion \*x==0: Unknown$ +^\[main.assertion.9\] .* assertion a==2: Unknown$ +^\[main.assertion.10\] .* assertion a==0: Unknown$ +^\[main.assertion.11\] .* assertion x==&a: Unknown$ +^\[main.assertion.12\] .* assertion \*x==0: Unknown$ +^\[main.assertion.13\] .* assertion x==&a: Unknown$ +^\[main.assertion.14\] .* assertion x==&b: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-array/sensitivity_test_two_value_struct_of_two_value_array.c b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-array/sensitivity_test_two_value_struct_of_two_value_array.c new file mode 100644 index 00000000000..d50aea1ea24 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-array/sensitivity_test_two_value_struct_of_two_value_array.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/struct_of_array_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-array/test.desc b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-array/test.desc new file mode 100644 index 00000000000..e8773cf68fc --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-array/test.desc @@ -0,0 +1,24 @@ +FUTURE +sensitivity_test_two_value_struct_of_two_value_array.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x.a\[0\]==0: Unknown$ +^\[main.assertion.2\] .* assertion \*\(x.a\+0\)==0: Unknown$ +^\[main.assertion.3\] .* assertion \*\(0\+x.a\)==0: Unknown$ +^\[main.assertion.4\] .* assertion 0\[x.a\]==0: Unknown$ +^\[main.assertion.5\] .* assertion x.a\[0\]==0: Unknown$ +^\[main.assertion.6\] .* assertion x.a\[1\]==1: Unknown$ +^\[main.assertion.7\] .* assertion x.b\[0\]==3.0f: Unknown$ +^\[main.assertion.8\] .* assertion x.a\[0\]==0: Unknown$ +^\[main.assertion.9\] .* assertion x.a\[1\]==1: Unknown$ +^\[main.assertion.10\] .* assertion x.b\[2\]>0.0f: Unknown$ +^\[main.assertion.11\] .* assertion x.b\[2\]==15.0f: Unknown$ +^\[main.assertion.12\] .* assertion x.b\[2\]==1.0f: Unknown$ +^\[main.assertion.13\] .* assertion x.b\[0\]==3.0f: Unknown$ +^\[main.assertion.14\] .* assertion x.a\[0\]<12: Unknown$ +^\[main.assertion.15\] .* assertion x.a\[0\]>2: Unknown$ +^\[main.assertion.16\] .* assertion x.a\[0\]==0: Unknown$ +^\[main.assertion.17\] .* assertion x.a\[1\]==1: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-pointer/sensitivity_test_two_value_struct_of_two_value_pointer.c b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-pointer/sensitivity_test_two_value_struct_of_two_value_pointer.c new file mode 100644 index 00000000000..ab7d896ae5d --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-pointer/sensitivity_test_two_value_struct_of_two_value_pointer.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/struct_of_pointer_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-pointer/test.desc b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-pointer/test.desc new file mode 100644 index 00000000000..06ebb29d047 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-pointer/test.desc @@ -0,0 +1,33 @@ +FUTURE +sensitivity_test_two_value_struct_of_two_value_pointer.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x.a==&a1: Unknown$ +^\[main.assertion.2\] .* assertion x.a==&a2: Unknown$ +^\[main.assertion.3\] .* assertion x.b==&b1: Unknown$ +^\[main.assertion.4\] .* assertion x.b==&b2: Unknown$ +^\[main.assertion.5\] .* assertion \*x.a==0: Unknown$ +^\[main.assertion.6\] .* assertion \*x.a==100: Unknown$ +^\[main.assertion.7\] .* assertion \*x.b==10.0f: Unknown$ +^\[main.assertion.8\] .* assertion \*x.b==110.0f: Unknown$ +^\[main.assertion.9\] .* assertion x.a==&a1: Unknown$ +^\[main.assertion.10\] .* assertion x.a==&a2: Unknown$ +^\[main.assertion.11\] .* assertion \*x.a==0: Unknown$ +^\[main.assertion.12\] .* assertion \*x.a==100: Unknown$ +^\[main.assertion.13\] .* assertion x.a==&a1: Unknown$ +^\[main.assertion.14\] .* assertion x.b==&b2: Unknown$ +^\[main.assertion.15\] .* assertion x.b==&b3: Unknown$ +^\[main.assertion.16\] .* assertion \*x.a==0: Unknown$ +^\[main.assertion.17\] .* assertion \*x.b==11.0f: Unknown$ +^\[main.assertion.18\] .* assertion \*x.b==12.0f: Unknown$ +^\[main.assertion.19\] .* assertion x.a==&a2: Unknown$ +^\[main.assertion.20\] .* assertion x.a==&a3: Unknown$ +^\[main.assertion.21\] .* assertion x.b==&b3: Unknown$ +^\[main.assertion.22\] .* assertion x.b==&b4: Unknown$ +^\[main.assertion.23\] .* assertion \*x.a==1: Unknown$ +^\[main.assertion.24\] .* assertion \*x.a==2: Unknown$ +^\[main.assertion.25\] .* assertion \*x.b==12.0f: Unknown$ +^\[main.assertion.26\] .* assertion \*x.b==13.0f: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-struct/sensitivity_test_two_value_struct_of_two_value_struct.c b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-struct/sensitivity_test_two_value_struct_of_two_value_struct.c new file mode 100644 index 00000000000..ae2ab34d038 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-struct/sensitivity_test_two_value_struct_of_two_value_struct.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/struct_of_struct_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-struct/test.desc b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-struct/test.desc new file mode 100644 index 00000000000..450055d2be6 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-struct-of-two-value-struct/test.desc @@ -0,0 +1,18 @@ +FUTURE +sensitivity_test_two_value_struct_of_two_value_struct.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x.s1.a==0: Unknown$ +^\[main.assertion.2\] .* assertion x.s2.b==3.0f: Unknown$ +^\[main.assertion.3\] .* assertion x.s1.a==0: Unknown$ +^\[main.assertion.4\] .* assertion x.s1.a==10: Unknown$ +^\[main.assertion.5\] .* assertion x.s1.b==1.0f: Unknown$ +^\[main.assertion.6\] .* assertion x.s2.b==3.0f: Unknown$ +^\[main.assertion.7\] .* assertion x.s2.b==0.0f: Unknown$ +^\[main.assertion.8\] .* assertion x.s1.a==20: Unknown$ +^\[main.assertion.9\] .* assertion x.s1.a<30: Unknown$ +^\[main.assertion.10\] .* assertion x.s2.a==22: Unknown$ +^\[main.assertion.11\] .* assertion x.s2.a<30: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-analyzer/sensitivity-test-two-value-struct/sensitivity_test_two_value_struct.c b/regression/goto-analyzer/sensitivity-test-two-value-struct/sensitivity_test_two_value_struct.c new file mode 100644 index 00000000000..946ec769d9e --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-struct/sensitivity_test_two_value_struct.c @@ -0,0 +1 @@ +#include "../sensitivity-test-common-files/struct_sensitivity_tests.c" diff --git a/regression/goto-analyzer/sensitivity-test-two-value-struct/test.desc b/regression/goto-analyzer/sensitivity-test-two-value-struct/test.desc new file mode 100644 index 00000000000..157a3b25968 --- /dev/null +++ b/regression/goto-analyzer/sensitivity-test-two-value-struct/test.desc @@ -0,0 +1,16 @@ +FUTURE +sensitivity_test_two_value_struct.c +--variable --verify +^EXIT=0$ +^SIGNAL=0$ +^\[main.assertion.1\] .* assertion x.a==0: Unknown$ +^\[main.assertion.2\] .* assertion x.a==1: Unknown$ +^\[main.assertion.3\] .* assertion x.a==0: Unknown$ +^\[main.assertion.4\] .* assertion x.a==0: Unknown$ +^\[main.assertion.5\] .* assertion x.b>0.0f: Unknown$ +^\[main.assertion.6\] .* assertion x.b==1.0f: Unknown$ +^\[main.assertion.7\] .* assertion x.a<2: Unknown$ +^\[main.assertion.8\] .* assertion x.a>2: Unknown$ +^\[main.assertion.9\] .* assertion x.a==1: Unknown$ +-- +^warning: ignoring diff --git a/regression/goto-instrument-typedef/Makefile b/regression/goto-instrument-typedef/Makefile new file mode 100644 index 00000000000..08fe97ae88c --- /dev/null +++ b/regression/goto-instrument-typedef/Makefile @@ -0,0 +1,31 @@ + +default: tests.log + +test: + @if ! ../test.pl -c ../chain.sh ; then \ + ../failed-tests-printer.pl ; \ + exit 1; \ + fi + +tests.log: + @if ! ../test.pl -c ../chain.sh ; then \ + ../failed-tests-printer.pl ; \ + exit 1; \ + fi + +show: + @for dir in *; do \ + if [ -d "$$dir" ]; then \ + vim -o "$$dir/*.c" "$$dir/*.out"; \ + fi; \ + done; + +clean: + @for dir in *; do \ + rm -f tests.log; \ + if [ -d "$$dir" ]; then \ + cd "$$dir"; \ + rm -f *.out *.gb; \ + cd ..; \ + fi \ + done diff --git a/regression/goto-instrument-typedef/chain.sh b/regression/goto-instrument-typedef/chain.sh new file mode 100755 index 00000000000..9cef4ffdfa4 --- /dev/null +++ b/regression/goto-instrument-typedef/chain.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +SRC=../../../src + +GC=$SRC/goto-cc/goto-cc +GI=$SRC/goto-instrument/goto-instrument + +OPTS=$1 +NAME=${2%.c} + +rm $NAME.gb +$GC $NAME.c --function fun -o $NAME.gb +echo $GI $OPTS $NAME.gb +$GI $OPTS $NAME.gb diff --git a/regression/goto-instrument-typedef/typedef-anon-struct1/main.c b/regression/goto-instrument-typedef/typedef-anon-struct1/main.c new file mode 100644 index 00000000000..d1e7196a3b1 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-anon-struct1/main.c @@ -0,0 +1,11 @@ + +typedef struct +{ + int x; + float y; +} MYSTRUCT; + +void fun() +{ + MYSTRUCT mystruct_var = {.x = 3, .y = 2.1f}; +} diff --git a/regression/goto-instrument-typedef/typedef-anon-struct1/test.desc b/regression/goto-instrument-typedef/typedef-anon-struct1/test.desc new file mode 100644 index 00000000000..59aba0e01a6 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-anon-struct1/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-anon-struct2/main.c b/regression/goto-instrument-typedef/typedef-anon-struct2/main.c new file mode 100644 index 00000000000..35475513f7d --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-anon-struct2/main.c @@ -0,0 +1,11 @@ + +typedef struct +{ + int x; + float y; +} MYSTRUCT; + +void fun() +{ + MYSTRUCT mystruct_var = {.x = 10, .y = 3.1f}, another_mystruct_var = {.x = 3, .y = 2.1f}; +} diff --git a/regression/goto-instrument-typedef/typedef-anon-struct2/test.desc b/regression/goto-instrument-typedef/typedef-anon-struct2/test.desc new file mode 100644 index 00000000000..490b6cc2623 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-anon-struct2/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT +Base name\.+: another_mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-anon-union1/main.c b/regression/goto-instrument-typedef/typedef-anon-union1/main.c new file mode 100644 index 00000000000..9322c77cb6e --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-anon-union1/main.c @@ -0,0 +1,11 @@ + +typedef union +{ + int x; + float y; +} MYUNION; + +void fun() +{ + MYUNION myunion_var = {.y = 2.1f}; +} diff --git a/regression/goto-instrument-typedef/typedef-anon-union1/test.desc b/regression/goto-instrument-typedef/typedef-anon-union1/test.desc new file mode 100644 index 00000000000..86caf078d6a --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-anon-union1/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: myunion_var\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-anon-union2/main.c b/regression/goto-instrument-typedef/typedef-anon-union2/main.c new file mode 100644 index 00000000000..b2dd6594432 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-anon-union2/main.c @@ -0,0 +1,11 @@ + +typedef union +{ + int x; + float y; +} MYUNION; + +void fun() +{ + MYUNION myunion_var = {.y = 2.1f}, another_myunion_var = {.y = 2.1f}; +} diff --git a/regression/goto-instrument-typedef/typedef-anon-union2/test.desc b/regression/goto-instrument-typedef/typedef-anon-union2/test.desc new file mode 100644 index 00000000000..8d8ca64aa93 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-anon-union2/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: myunion_var\nMode\.+: C\nType\.+: MYUNION +Base name\.+: another_myunion_var\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-const-struct1/main.c b/regression/goto-instrument-typedef/typedef-const-struct1/main.c new file mode 100644 index 00000000000..ab8137e82e4 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-const-struct1/main.c @@ -0,0 +1,12 @@ + +typedef struct tag_struct_name +{ + int x; + float y; +} MYSTRUCT; + +void fun() +{ + const struct tag_struct_name tag_struct_var = {.x = 1, .y = 3.14f}; + const MYSTRUCT mystruct_var = {.x = 3, .y = 2.1f}; +} diff --git a/regression/goto-instrument-typedef/typedef-const-struct1/test.desc b/regression/goto-instrument-typedef/typedef-const-struct1/test.desc new file mode 100644 index 00000000000..a6aad1f799a --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-const-struct1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_struct_var\nMode\.+: C\nType\.+: const struct tag_struct_name +Base name\.+: mystruct_var\nMode\.+: C\nType\.+: const MYSTRUCT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-const-type1/main.c b/regression/goto-instrument-typedef/typedef-const-type1/main.c new file mode 100644 index 00000000000..8cd4a4346eb --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-const-type1/main.c @@ -0,0 +1,8 @@ + +typedef int MYINT; + +void fun() +{ + const int int_var = 3; + const MYINT myint_var = 5; +} diff --git a/regression/goto-instrument-typedef/typedef-const-type1/test.desc b/regression/goto-instrument-typedef/typedef-const-type1/test.desc new file mode 100644 index 00000000000..481b097653f --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-const-type1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_var\nMode\.+: C\nType\.+: const signed int +Base name\.+: myint_var\nMode\.+: C\nType\.+: const MYINT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-const-union1/main.c b/regression/goto-instrument-typedef/typedef-const-union1/main.c new file mode 100644 index 00000000000..b8defe635a6 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-const-union1/main.c @@ -0,0 +1,12 @@ + +typedef union tag_union_name +{ + int x; + float y; +} MYUNION; + +void fun() +{ + const union tag_union_name tag_union_var = {1}; + const MYUNION myunion_var = {.y = 2.1f}; +} diff --git a/regression/goto-instrument-typedef/typedef-const-union1/test.desc b/regression/goto-instrument-typedef/typedef-const-union1/test.desc new file mode 100644 index 00000000000..cd303b85195 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-const-union1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_union_var\nMode\.+: C\nType\.+: const union tag_union_name +Base name\.+: myunion_var\nMode\.+: C\nType\.+: const MYUNION +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-param-anon-struct1/main.c b/regression/goto-instrument-typedef/typedef-param-anon-struct1/main.c new file mode 100644 index 00000000000..e8f3fb8fd7c --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-anon-struct1/main.c @@ -0,0 +1,11 @@ + +typedef struct +{ + int x; + float y; +} MYSTRUCT; + +void fun(MYSTRUCT mystruct_param) +{ + +} diff --git a/regression/goto-instrument-typedef/typedef-param-anon-struct1/test.desc b/regression/goto-instrument-typedef/typedef-param-anon-struct1/test.desc new file mode 100644 index 00000000000..537526b4422 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-anon-struct1/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: mystruct_param\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-param-anon-union1/main.c b/regression/goto-instrument-typedef/typedef-param-anon-union1/main.c new file mode 100644 index 00000000000..71791d9adfc --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-anon-union1/main.c @@ -0,0 +1,10 @@ + +typedef union +{ + int x; + float y; +} MYUNION; + +void fun(MYUNION myunion_param) +{ +} diff --git a/regression/goto-instrument-typedef/typedef-param-anon-union1/test.desc b/regression/goto-instrument-typedef/typedef-param-anon-union1/test.desc new file mode 100644 index 00000000000..270316982a3 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-anon-union1/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: myunion_param\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-param-struct1/main.c b/regression/goto-instrument-typedef/typedef-param-struct1/main.c new file mode 100644 index 00000000000..a358c15a030 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-struct1/main.c @@ -0,0 +1,10 @@ + +typedef struct tag_struct_name +{ + int x; + float y; +} MYSTRUCT; + +void fun(struct tag_struct_name tag_struct_param, MYSTRUCT mystruct_param) +{ +} diff --git a/regression/goto-instrument-typedef/typedef-param-struct1/test.desc b/regression/goto-instrument-typedef/typedef-param-struct1/test.desc new file mode 100644 index 00000000000..c26ee458459 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-struct1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_struct_param\nMode\.+: C\nType\.+: struct tag_struct_name +Base name\.+: mystruct_param\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-param-type1/main.c b/regression/goto-instrument-typedef/typedef-param-type1/main.c new file mode 100644 index 00000000000..b4c915066b6 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-type1/main.c @@ -0,0 +1,7 @@ + +typedef int MYINT; + +void fun(int int_param, MYINT myint_param) +{ + +} diff --git a/regression/goto-instrument-typedef/typedef-param-type1/test.desc b/regression/goto-instrument-typedef/typedef-param-type1/test.desc new file mode 100644 index 00000000000..050ac22b315 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-type1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_param\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_param\nMode\.+: C\nType\.+: MYINT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-param-type2/main.c b/regression/goto-instrument-typedef/typedef-param-type2/main.c new file mode 100644 index 00000000000..b5974fb6bbb --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-type2/main.c @@ -0,0 +1,8 @@ + +typedef int MYINT; +typedef int ALTINT; + +void fun(int int_param, MYINT myint_param, ALTINT altint_param) +{ + +} diff --git a/regression/goto-instrument-typedef/typedef-param-type2/test.desc b/regression/goto-instrument-typedef/typedef-param-type2/test.desc new file mode 100644 index 00000000000..53cdc42193e --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-type2/test.desc @@ -0,0 +1,12 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_param\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_param\nMode\.+: C\nType\.+: MYINT +Base name\.+: altint_param\nMode\.+: C\nType\.+: ALTINT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-param-type3/main.c b/regression/goto-instrument-typedef/typedef-param-type3/main.c new file mode 100644 index 00000000000..4d542e10c13 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-type3/main.c @@ -0,0 +1,7 @@ + +typedef int MYINT; +typedef MYINT CHAINEDINT; + +void fun(int int_param, MYINT myint_param, CHAINEDINT chainedint_param) +{ +} diff --git a/regression/goto-instrument-typedef/typedef-param-type3/test.desc b/regression/goto-instrument-typedef/typedef-param-type3/test.desc new file mode 100644 index 00000000000..6ba9d61f8ca --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-type3/test.desc @@ -0,0 +1,12 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_param\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_param\nMode\.+: C\nType\.+: MYINT +Base name\.+: chainedint_param\nMode\.+: C\nType\.+: CHAINEDINT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-param-union1/main.c b/regression/goto-instrument-typedef/typedef-param-union1/main.c new file mode 100644 index 00000000000..8f961614e5d --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-union1/main.c @@ -0,0 +1,10 @@ + +typedef union tag_union_name +{ + int x; + float y; +} MYUNION; + +void fun(union tag_union_name tag_union_param, MYUNION myunion_param) +{ +} diff --git a/regression/goto-instrument-typedef/typedef-param-union1/test.desc b/regression/goto-instrument-typedef/typedef-param-union1/test.desc new file mode 100644 index 00000000000..466dd76ed52 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-param-union1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_union_param\nMode\.+: C\nType\.+: union tag_union_name +Base name\.+: myunion_param\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-return-anon-struct1/main.c b/regression/goto-instrument-typedef/typedef-return-anon-struct1/main.c new file mode 100644 index 00000000000..0195b955cdd --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-anon-struct1/main.c @@ -0,0 +1,12 @@ + +typedef struct +{ + int x; + float y; +} MYSTRUCT; + +MYSTRUCT fun() +{ + MYSTRUCT return_variable = {.x = 1, .y = 3.14f}; + return return_variable; +} diff --git a/regression/goto-instrument-typedef/typedef-return-anon-struct1/test.desc b/regression/goto-instrument-typedef/typedef-return-anon-struct1/test.desc new file mode 100644 index 00000000000..47964f71f66 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-anon-struct1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: return\nMode\.+: C\nType\.+: MYSTRUCT +Base name\.+: fun\nMode\.+: C\nType\.+: MYSTRUCT \(\) +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-return-anon-union1/main.c b/regression/goto-instrument-typedef/typedef-return-anon-union1/main.c new file mode 100644 index 00000000000..3bc7d19d5b7 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-anon-union1/main.c @@ -0,0 +1,15 @@ + +typedef union +{ + int x; + float y; +} MYUNION; + + +MYUNION fun() +{ + MYUNION return_variable = {1}; + return return_variable; +} + + diff --git a/regression/goto-instrument-typedef/typedef-return-anon-union1/test.desc b/regression/goto-instrument-typedef/typedef-return-anon-union1/test.desc new file mode 100644 index 00000000000..5a8d1b2062d --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-anon-union1/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: fun\nMode\.+: C\nType\.+: MYUNION \(\) +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-return-struct1/main.c b/regression/goto-instrument-typedef/typedef-return-struct1/main.c new file mode 100644 index 00000000000..30c1323555c --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-struct1/main.c @@ -0,0 +1,20 @@ + +typedef struct tag_struct_name +{ + int x; + float y; +} MYSTRUCT; + +struct tag_struct_name fun() +{ + struct tag_struct_name return_variable = { .x = 1, .y = 3.14f}; + return return_variable; +} + +MYSTRUCT fun2() +{ + MYSTRUCT return_variable = { .x = 1, .y = 3.14f}; + return return_variable; +} + + diff --git a/regression/goto-instrument-typedef/typedef-return-struct1/test.desc b/regression/goto-instrument-typedef/typedef-return-struct1/test.desc new file mode 100644 index 00000000000..eade5942ac8 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-struct1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: fun\nMode\.+: C\nType\.+: struct tag_struct_name \(\) +Base name\.+: fun2\nMode\.+: C\nType\.+: MYSTRUCT \(\) +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-return-type1/main.c b/regression/goto-instrument-typedef/typedef-return-type1/main.c new file mode 100644 index 00000000000..1ba7f426f89 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-type1/main.c @@ -0,0 +1,12 @@ + +typedef int MYINT; + +int fun() +{ + return 4; +} + +MYINT fun2() +{ + return 5; +} diff --git a/regression/goto-instrument-typedef/typedef-return-type1/test.desc b/regression/goto-instrument-typedef/typedef-return-type1/test.desc new file mode 100644 index 00000000000..ba1b96ce6b6 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-type1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: fun\nMode\.+: C\nType\.+: signed int \(\) +Base name\.+: fun2\nMode\.+: C\nType\.+: MYINT \(\) +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-return-type2/main.c b/regression/goto-instrument-typedef/typedef-return-type2/main.c new file mode 100644 index 00000000000..0d94ab54da3 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-type2/main.c @@ -0,0 +1,13 @@ + +typedef int MYINT; +typedef int ALTINT; + +MYINT fun() +{ + +} + +ALTINT fun2() +{ + +} diff --git a/regression/goto-instrument-typedef/typedef-return-type2/test.desc b/regression/goto-instrument-typedef/typedef-return-type2/test.desc new file mode 100644 index 00000000000..1ecc9ea8e90 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-type2/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: fun\nMode\.+: C\nType\.+: MYINT \(\) +Base name\.+: fun2\nMode\.+: C\nType\.+: ALTINT \(\) +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-return-type3/main.c b/regression/goto-instrument-typedef/typedef-return-type3/main.c new file mode 100644 index 00000000000..e246757c692 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-type3/main.c @@ -0,0 +1,12 @@ + +typedef int MYINT; +typedef MYINT CHAINEDINT; + +MYINT fun() +{ +} + +CHAINEDINT fun2() +{ + +} \ No newline at end of file diff --git a/regression/goto-instrument-typedef/typedef-return-type3/test.desc b/regression/goto-instrument-typedef/typedef-return-type3/test.desc new file mode 100644 index 00000000000..2401af3ce8d --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-type3/test.desc @@ -0,0 +1,10 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +Base name\.+: fun\nMode\.+: C\nType\.+: MYINT \(\) +Base name\.+: fun2\nMode\.+: C\nType\.+: CHAINEDINT \(\) +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-return-union1/main.c b/regression/goto-instrument-typedef/typedef-return-union1/main.c new file mode 100644 index 00000000000..ad69cb04545 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-union1/main.c @@ -0,0 +1,20 @@ + +typedef union tag_union_name +{ + int x; + float y; +} MYUNION; + +union tag_union_name fun() +{ + union tag_union_name return_variable = {1}; + return return_variable; +} + +MYUNION fun2() +{ + MYUNION return_variable = {1}; + return return_variable; +} + + diff --git a/regression/goto-instrument-typedef/typedef-return-union1/test.desc b/regression/goto-instrument-typedef/typedef-return-union1/test.desc new file mode 100644 index 00000000000..0855b28f479 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-return-union1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: fun\nMode\.+: C\nType\.+: union tag_union_name \(\) +Base name\.+: fun2\nMode\.+: C\nType\.+: MYUNION \(\) +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-struct1/main.c b/regression/goto-instrument-typedef/typedef-struct1/main.c new file mode 100644 index 00000000000..dac5abf77b8 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-struct1/main.c @@ -0,0 +1,12 @@ + +typedef struct tag_struct_name +{ + int x; + float y; +} MYSTRUCT; + +void fun() +{ + struct tag_struct_name tag_struct_var = {.x = 1, .y = 3.14f}; + MYSTRUCT mystruct_var = {.x = 3, .y = 2.1f}; +} diff --git a/regression/goto-instrument-typedef/typedef-struct1/test.desc b/regression/goto-instrument-typedef/typedef-struct1/test.desc new file mode 100644 index 00000000000..6a02f2d2174 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-struct1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_struct_var\nMode\.+: C\nType\.+: struct tag_struct_name +Base name\.+: mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-struct2/main.c b/regression/goto-instrument-typedef/typedef-struct2/main.c new file mode 100644 index 00000000000..dac5abf77b8 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-struct2/main.c @@ -0,0 +1,12 @@ + +typedef struct tag_struct_name +{ + int x; + float y; +} MYSTRUCT; + +void fun() +{ + struct tag_struct_name tag_struct_var = {.x = 1, .y = 3.14f}; + MYSTRUCT mystruct_var = {.x = 3, .y = 2.1f}; +} diff --git a/regression/goto-instrument-typedef/typedef-struct2/test.desc b/regression/goto-instrument-typedef/typedef-struct2/test.desc new file mode 100644 index 00000000000..6a02f2d2174 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-struct2/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_struct_var\nMode\.+: C\nType\.+: struct tag_struct_name +Base name\.+: mystruct_var\nMode\.+: C\nType\.+: MYSTRUCT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-type1/main.c b/regression/goto-instrument-typedef/typedef-type1/main.c new file mode 100644 index 00000000000..43f028c7772 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-type1/main.c @@ -0,0 +1,8 @@ + +typedef int MYINT; + +void fun() +{ + int int_var = 3; + MYINT myint_var = 5; +} diff --git a/regression/goto-instrument-typedef/typedef-type1/test.desc b/regression/goto-instrument-typedef/typedef-type1/test.desc new file mode 100644 index 00000000000..7599f1759c0 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-type1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_var\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_var\nMode\.+: C\nType\.+: MYINT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-type2/main.c b/regression/goto-instrument-typedef/typedef-type2/main.c new file mode 100644 index 00000000000..acb1cce2da4 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-type2/main.c @@ -0,0 +1,10 @@ + +typedef int MYINT; +typedef int ALTINT; + +void fun() +{ + int int_var = 3; + MYINT myint_var = 5; + ALTINT altint_var = 7; +} diff --git a/regression/goto-instrument-typedef/typedef-type2/test.desc b/regression/goto-instrument-typedef/typedef-type2/test.desc new file mode 100644 index 00000000000..3cf1e50a5a5 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-type2/test.desc @@ -0,0 +1,12 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_var\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_var\nMode\.+: C\nType\.+: MYINT +Base name\.+: altint_var\nMode\.+: C\nType\.+: ALTINT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-type3/main.c b/regression/goto-instrument-typedef/typedef-type3/main.c new file mode 100644 index 00000000000..5855e0c24cb --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-type3/main.c @@ -0,0 +1,10 @@ + +typedef int MYINT; +typedef MYINT CHAINEDINT; + +void fun() +{ + int int_var = 3; + MYINT myint_var = 5; + CHAINEDINT chainedint_var = 5; +} diff --git a/regression/goto-instrument-typedef/typedef-type3/test.desc b/regression/goto-instrument-typedef/typedef-type3/test.desc new file mode 100644 index 00000000000..aca9069695c --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-type3/test.desc @@ -0,0 +1,12 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_var\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_var\nMode\.+: C\nType\.+: MYINT +Base name\.+: chainedint_var\nMode\.+: C\nType\.+: CHAINEDINT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-type4/main.c b/regression/goto-instrument-typedef/typedef-type4/main.c new file mode 100644 index 00000000000..aa2ec9ad7fb --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-type4/main.c @@ -0,0 +1,8 @@ + +typedef int MYINT; + +void fun() +{ + int int_var = 3; + MYINT myint_var = 5, another_myint_var = 10; +} diff --git a/regression/goto-instrument-typedef/typedef-type4/test.desc b/regression/goto-instrument-typedef/typedef-type4/test.desc new file mode 100644 index 00000000000..28163714070 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-type4/test.desc @@ -0,0 +1,12 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: int_var\nMode\.+: C\nType\.+: signed int +Base name\.+: myint_var\nMode\.+: C\nType\.+: MYINT +Base name\.+: another_myint_var\nMode\.+: C\nType\.+: MYINT +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-union1/main.c b/regression/goto-instrument-typedef/typedef-union1/main.c new file mode 100644 index 00000000000..6f56f3c731b --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-union1/main.c @@ -0,0 +1,12 @@ + +typedef union tag_union_name +{ + int x; + float y; +} MYUNION; + +void fun() +{ + union tag_union_name tag_union_var = {1}; + MYUNION myunion_var = {.y = 2.1f}; +} diff --git a/regression/goto-instrument-typedef/typedef-union1/test.desc b/regression/goto-instrument-typedef/typedef-union1/test.desc new file mode 100644 index 00000000000..8502d149cb1 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-union1/test.desc @@ -0,0 +1,11 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_union_var\nMode\.+: C\nType\.+: union tag_union_name +Base name\.+: myunion_var\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring diff --git a/regression/goto-instrument-typedef/typedef-union2/main.c b/regression/goto-instrument-typedef/typedef-union2/main.c new file mode 100644 index 00000000000..9ca707cf767 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-union2/main.c @@ -0,0 +1,12 @@ + +typedef union tag_union_name +{ + int x; + float y; +} MYUNION; + +void fun() +{ + union tag_union_name tag_union_var = {1}, another_tag_union_var = {1}; + MYUNION myunion_var = {.y = 2.1f}, another_myunion_var = {.y = 3.1f}; +} diff --git a/regression/goto-instrument-typedef/typedef-union2/test.desc b/regression/goto-instrument-typedef/typedef-union2/test.desc new file mode 100644 index 00000000000..0fc908a6ab5 --- /dev/null +++ b/regression/goto-instrument-typedef/typedef-union2/test.desc @@ -0,0 +1,13 @@ +CORE +main.c +"--show-symbol-table" +// Enable multi-line checking +activate-multi-line-match +EXIT=0 +SIGNAL=0 +Base name\.+: tag_union_var\nMode\.+: C\nType\.+: union tag_union_name +Base name\.+: another_tag_union_var\nMode\.+: C\nType\.+: union tag_union_name +Base name\.+: myunion_var\nMode\.+: C\nType\.+: MYUNION +Base name\.+: another_myunion_var\nMode\.+: C\nType\.+: MYUNION +-- +warning: ignoring diff --git a/regression/goto-instrument-wmm-core/Makefile b/regression/goto-instrument-wmm-core/Makefile index c1f99d1da81..85c17bf622b 100644 --- a/regression/goto-instrument-wmm-core/Makefile +++ b/regression/goto-instrument-wmm-core/Makefile @@ -21,7 +21,7 @@ tests.log: ../test.pl clean: @for dir in *; do \ if [ -d "$$dir" ]; then \ - rm $$dir/*.txt $$dir/*.dot $$dir/*.gb $$dir/*.out; \ + $(RM) $$dir/*.txt $$dir/*.dot $$dir/*.gb $$dir/*.out; \ fi; \ done; diff --git a/regression/goto-instrument/Makefile b/regression/goto-instrument/Makefile index 08fe97ae88c..94605814b4a 100644 --- a/regression/goto-instrument/Makefile +++ b/regression/goto-instrument/Makefile @@ -22,10 +22,10 @@ show: clean: @for dir in *; do \ - rm -f tests.log; \ + $(RM) tests.log; \ if [ -d "$$dir" ]; then \ cd "$$dir"; \ - rm -f *.out *.gb; \ + $(RM) *.out *.gb; \ cd ..; \ fi \ done diff --git a/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/main.c b/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/main.c new file mode 100644 index 00000000000..3fb230c83fd --- /dev/null +++ b/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/main.c @@ -0,0 +1,34 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +const void_fp fp_tbl[] = {f2, f3 ,f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i) +{ + fp_tbl[i](); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} \ No newline at end of file diff --git a/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/test.desc b/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/test.desc new file mode 100644 index 00000000000..bc553fa5a0f --- /dev/null +++ b/regression/goto-instrument/approx-array-variable-const-fp-only-remove-const/test.desc @@ -0,0 +1,15 @@ +CORE +main.c +--verbosity 10 --pointer-check --remove-const-function-pointers +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f2 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f3 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f4 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f9 THEN GOTO [0-9]$ +^warning: ignoring diff --git a/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/main.c b/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/main.c new file mode 100644 index 00000000000..7896e3402c0 --- /dev/null +++ b/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/main.c @@ -0,0 +1,34 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +const void_fp fp_tbl[] = {f2, f3 ,f4}; + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func(int i) +{ + fp_tbl[i](); +} + +int main() +{ + for(int i=0;i<3;i++) + { + func(i); + } + + return 0; +} diff --git a/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/test.desc b/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/test.desc new file mode 100644 index 00000000000..e9ede02a296 --- /dev/null +++ b/regression/goto-instrument/approx-array-variable-const-fp-remove-all-fp/test.desc @@ -0,0 +1,15 @@ +CORE +main.c +--verbosity 10 --pointer-check --remove-function-pointers +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f2 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f3 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f4 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f1 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f5 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f6 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f7 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f8 THEN GOTO [0-9]$ +^\s*IF fp_tbl\[\(signed (long )*long int\)i\] == f9 THEN GOTO [0-9]$ +^warning: ignoring diff --git a/regression/goto-instrument/no-match-non-const-fp-only-remove-const/main.c b/regression/goto-instrument/no-match-non-const-fp-only-remove-const/main.c new file mode 100644 index 00000000000..80c8c863ff5 --- /dev/null +++ b/regression/goto-instrument/no-match-non-const-fp-only-remove-const/main.c @@ -0,0 +1,31 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + void_fp fp = f2; + fp = f3; + fp(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-instrument/no-match-non-const-fp-only-remove-const/test.desc b/regression/goto-instrument/no-match-non-const-fp-only-remove-const/test.desc new file mode 100644 index 00000000000..9c23726e83c --- /dev/null +++ b/regression/goto-instrument/no-match-non-const-fp-only-remove-const/test.desc @@ -0,0 +1,7 @@ +CORE +main.c +--verbosity 10 --pointer-check --remove-const-function-pointers +^\s*fp\(\);$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-instrument/no-match-non-const-fp-remove-all-fp/main.c b/regression/goto-instrument/no-match-non-const-fp-remove-all-fp/main.c new file mode 100644 index 00000000000..80c8c863ff5 --- /dev/null +++ b/regression/goto-instrument/no-match-non-const-fp-remove-all-fp/main.c @@ -0,0 +1,31 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + void_fp fp = f2; + fp = f3; + fp(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-instrument/no-match-non-const-fp-remove-all-fp/test.desc b/regression/goto-instrument/no-match-non-const-fp-remove-all-fp/test.desc new file mode 100644 index 00000000000..46c2f8cd2d4 --- /dev/null +++ b/regression/goto-instrument/no-match-non-const-fp-remove-all-fp/test.desc @@ -0,0 +1,15 @@ +CORE +main.c +--verbosity 10 --pointer-check --remove-function-pointers +^\s*IF fp == f1 THEN GOTO [0-9]$ +^\s*IF fp == f2 THEN GOTO [0-9]$ +^\s*IF fp == f3 THEN GOTO [0-9]$ +^\s*IF fp == f4 THEN GOTO [0-9]$ +^\s*IF fp == f5 THEN GOTO [0-9]$ +^\s*IF fp == f6 THEN GOTO [0-9]$ +^\s*IF fp == f7 THEN GOTO [0-9]$ +^\s*IF fp == f8 THEN GOTO [0-9]$ +^\s*IF fp == f9 THEN GOTO [0-9]$ +^SIGNAL=0$ +-- +^warning: ignoring diff --git a/regression/goto-instrument/precise-const-fp-only-remove-const/main.c b/regression/goto-instrument/precise-const-fp-only-remove-const/main.c new file mode 100644 index 00000000000..b4002c94e5e --- /dev/null +++ b/regression/goto-instrument/precise-const-fp-only-remove-const/main.c @@ -0,0 +1,30 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = f2; + fp(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-instrument/precise-const-fp-only-remove-const/test.desc b/regression/goto-instrument/precise-const-fp-only-remove-const/test.desc new file mode 100644 index 00000000000..cdf49005c0b --- /dev/null +++ b/regression/goto-instrument/precise-const-fp-only-remove-const/test.desc @@ -0,0 +1,6 @@ +CORE +main.c +--verbosity 10 --pointer-check --remove-const-function-pointers +^\s*f2\(\); +-- +^warning: ignoring diff --git a/regression/goto-instrument/precise-const-fp-remove-all-fp/main.c b/regression/goto-instrument/precise-const-fp-remove-all-fp/main.c new file mode 100644 index 00000000000..b4002c94e5e --- /dev/null +++ b/regression/goto-instrument/precise-const-fp-remove-all-fp/main.c @@ -0,0 +1,30 @@ +#include + +void f1 (void) { printf("%i\n", 1); } +void f2 (void) { printf("%i\n", 2); } +void f3 (void) { printf("%i\n", 3); } +void f4 (void) { printf("%i\n", 4); } +void f5 (void) { printf("%i\n", 5); } +void f6 (void) { printf("%i\n", 6); } +void f7 (void) { printf("%i\n", 7); } +void f8 (void) { printf("%i\n", 8); } +void f9 (void) { printf("%i\n", 9); } + +typedef void(*void_fp)(void); + +// There is a basic check that excludes all functions that aren't used anywhere +// This ensures that check can't work in this example +const void_fp fp_all[] = {f1, f2 ,f3, f4, f5 ,f6, f7, f8, f9}; + +void func() +{ + const void_fp fp = f2; + fp(); +} + +int main() +{ + func(); + + return 0; +} diff --git a/regression/goto-instrument/precise-const-fp-remove-all-fp/test.desc b/regression/goto-instrument/precise-const-fp-remove-all-fp/test.desc new file mode 100644 index 00000000000..a559b2b1747 --- /dev/null +++ b/regression/goto-instrument/precise-const-fp-remove-all-fp/test.desc @@ -0,0 +1,6 @@ +CORE +main.c +--verbosity 10 --pointer-check --remove-function-pointers +^\s*f2\(\); +-- +^warning: ignoring diff --git a/regression/k-induction/Makefile b/regression/k-induction/Makefile index 009b420f259..bfd7ece4734 100644 --- a/regression/k-induction/Makefile +++ b/regression/k-induction/Makefile @@ -12,3 +12,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/symex-infeasibility/Makefile b/regression/symex-infeasibility/Makefile index d8a99eec731..120e9a347c0 100644 --- a/regression/symex-infeasibility/Makefile +++ b/regression/symex-infeasibility/Makefile @@ -12,3 +12,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/symex/Makefile b/regression/symex/Makefile index d8a99eec731..120e9a347c0 100644 --- a/regression/symex/Makefile +++ b/regression/symex/Makefile @@ -12,3 +12,8 @@ show: vim -o "$$dir/*.c" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/taint/Makefile b/regression/taint/Makefile index 5701431a37e..40dbe9c53be 100644 --- a/regression/taint/Makefile +++ b/regression/taint/Makefile @@ -12,3 +12,8 @@ show: vim -o "$$dir/*.java" "$$dir/*.out"; \ fi; \ done; + +clean: + find -name '*.out' -execdir $(RM) '{}' \; + find -name '*.gb' -execdir $(RM) '{}' \; + $(RM) tests.log diff --git a/regression/test-script/Makefile b/regression/test-script/Makefile index ba7db5e6250..ee6eaf02884 100644 --- a/regression/test-script/Makefile +++ b/regression/test-script/Makefile @@ -37,10 +37,10 @@ show: clean: @for dir in *; do \ - rm -f tests.log; \ + $(RM) tests.log; \ if [ -d "$$dir" ]; then \ cd "$$dir"; \ - rm -f *.out *.gb; \ + $(RM) *.out *.gb; \ cd ..; \ fi \ done diff --git a/src/analyses/Makefile b/src/analyses/Makefile index 89f14e4f768..e05d5be0c42 100644 --- a/src/analyses/Makefile +++ b/src/analyses/Makefile @@ -6,7 +6,9 @@ SRC = natural_loops.cpp is_threaded.cpp dirty.cpp interval_analysis.cpp \ local_bitvector_analysis.cpp dependence_graph.cpp \ constant_propagator.cpp replace_symbol_ext.cpp \ flow_insensitive_analysis.cpp \ - custom_bitvector_analysis.cpp escape_analysis.cpp global_may_alias.cpp + custom_bitvector_analysis.cpp escape_analysis.cpp global_may_alias.cpp \ + does_remove_const.cpp \ + # Empty last line INCLUDES= -I .. diff --git a/src/analyses/ai.cpp b/src/analyses/ai.cpp index 06dd02af83f..2d1f4f6b986 100644 --- a/src/analyses/ai.cpp +++ b/src/analyses/ai.cpp @@ -81,6 +81,158 @@ void ai_baset::output( /*******************************************************************\ +Function: ai_baset::output_json + + Inputs: The namespace and goto_functions + + Outputs: The JSON object + + Purpose: Output the domains for the whole program as JSON + +\*******************************************************************/ + +jsont ai_baset::output_json( + const namespacet &ns, + const goto_functionst &goto_functions) const +{ + json_objectt result; + + forall_goto_functions(f_it, goto_functions) + { + if(f_it->second.body_available()) + { + result[id2string(f_it->first)]= + output_json(ns, f_it->second.body, f_it->first); + } + else + { + result[id2string(f_it->first)]=json_arrayt(); + } + } + + return result; +} + +/*******************************************************************\ + +Function: ai_baset::output_json + + Inputs: The namespace, goto_program and it's identifier + + Outputs: The JSON object + + Purpose: Output the domains for a single function as JSON + +\*******************************************************************/ + +jsont ai_baset::output_json( + const namespacet &ns, + const goto_programt &goto_program, + const irep_idt &identifier) const +{ + json_arrayt contents; + + forall_goto_program_instructions(i_it, goto_program) + { + json_objectt location; + location["locationNumber"]= + json_numbert(std::to_string(i_it->location_number)); + location["sourceLocation"]= + json_stringt(i_it->source_location.as_string()); + location["domain"]=find_state(i_it).output_json(*this, ns); + + // Ideally we need output_instruction_json + std::ostringstream out; + goto_program.output_instruction(ns, identifier, out, i_it); + location["instruction"]=json_stringt(out.str()); + + contents.push_back(location); + } + + return contents; +} + +/*******************************************************************\ + +Function: ai_baset::output_xml + + Inputs: The namespace and goto_functions + + Outputs: The XML object + + Purpose: Output the domains for the whole program as XML + +\*******************************************************************/ + +xmlt ai_baset::output_xml( + const namespacet &ns, + const goto_functionst &goto_functions) const +{ + xmlt program("program"); + + forall_goto_functions(f_it, goto_functions) + { + xmlt function("function"); + function.set_attribute("name", id2string(f_it->first)); + function.set_attribute( + "body_available", + f_it->second.body_available() ? "true" : "false"); + + if(f_it->second.body_available()) + { + function.new_element(output_xml(ns, f_it->second.body, f_it->first)); + } + + program.new_element(function); + } + + return program; +} + +/*******************************************************************\ + +Function: ai_baset::output_xml + + Inputs: The namespace, goto_program and it's identifier + + Outputs: The XML object + + Purpose: Output the domains for a single function as XML + +\*******************************************************************/ + +xmlt ai_baset::output_xml( + const namespacet &ns, + const goto_programt &goto_program, + const irep_idt &identifier) const +{ + xmlt function_body; + + forall_goto_program_instructions(i_it, goto_program) + { + xmlt location; + location.set_attribute( + "location_number", + std::to_string(i_it->location_number)); + location.set_attribute( + "source_location", + i_it->source_location.as_string()); + + location.new_element(find_state(i_it).output_xml(*this, ns)); + + // Ideally we need output_instruction_xml + std::ostringstream out; + goto_program.output_instruction(ns, identifier, out, i_it); + location.set_attribute("instruction", out.str()); + + function_body.new_element(location); + } + + return function_body; +} + +/*******************************************************************\ + Function: ai_baset::entry_state Inputs: diff --git a/src/analyses/ai.h b/src/analyses/ai.h index c506cbbeb08..2894cde3b10 100644 --- a/src/analyses/ai.h +++ b/src/analyses/ai.h @@ -11,6 +11,10 @@ Author: Daniel Kroening, kroening@kroening.com #include #include +#include + +#include +#include #include @@ -53,6 +57,27 @@ class ai_domain_baset { } + virtual jsont output_json( + const ai_baset &ai, + const namespacet &ns) const + { + std::ostringstream out; + output(out, ai, ns); + json_stringt json(out.str()); + return json; + } + + virtual xmlt output_xml( + const ai_baset &ai, + const namespacet &ns) const + { + std::ostringstream out; + output(out, ai, ns); + xmlt xml("domain"); + xml.data=out.str(); + return xml; + } + // no states virtual void make_bottom()=0; @@ -157,6 +182,58 @@ class ai_baset output(ns, goto_function.body, "", out); } + + virtual jsont output_json( + const namespacet &ns, + const goto_functionst &goto_functions) const; + + jsont output_json( + const goto_modelt &goto_model) const + { + const namespacet ns(goto_model.symbol_table); + return output_json(ns, goto_model.goto_functions); + } + + jsont output_json( + const namespacet &ns, + const goto_programt &goto_program) const + { + return output_json(ns, goto_program, ""); + } + + jsont output_json( + const namespacet &ns, + const goto_functionst::goto_functiont &goto_function) const + { + return output_json(ns, goto_function.body, ""); + } + + + virtual xmlt output_xml( + const namespacet &ns, + const goto_functionst &goto_functions) const; + + xmlt output_xml( + const goto_modelt &goto_model) const + { + const namespacet ns(goto_model.symbol_table); + return output_xml(ns, goto_model.goto_functions); + } + + xmlt output_xml( + const namespacet &ns, + const goto_programt &goto_program) const + { + return output_xml(ns, goto_program, ""); + } + + xmlt output_xml( + const namespacet &ns, + const goto_functionst::goto_functiont &goto_function) const + { + return output_xml(ns, goto_function.body, ""); + } + protected: // overload to add a factory virtual void initialize(const goto_programt &); @@ -172,6 +249,17 @@ class ai_baset const irep_idt &identifier, std::ostream &out) const; + virtual jsont output_json( + const namespacet &ns, + const goto_programt &goto_program, + const irep_idt &identifier) const; + + virtual xmlt output_xml( + const namespacet &ns, + const goto_programt &goto_program, + const irep_idt &identifier) const; + + // the work-queue is sorted by location number typedef std::map working_sett; diff --git a/src/analyses/constant_propagator.cpp b/src/analyses/constant_propagator.cpp index 189048994b8..6735d558cc3 100644 --- a/src/analyses/constant_propagator.cpp +++ b/src/analyses/constant_propagator.cpp @@ -18,6 +18,61 @@ Author: Peter Schrammel /*******************************************************************\ +Function: concatenate_array_id + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +exprt concatenate_array_id( + const exprt &array, const exprt &index, + const typet &type) +{ + std::string a, idx, identifier; + a = array.get_string(ID_identifier); + + if (index.id()==ID_typecast) + idx = index.op0().get_string(ID_value); + else + idx = index.get_string(ID_value); + + mp_integer i=string2integer(idx); + identifier=a+"["+integer2string(i)+"]"; + symbol_exprt new_expr(identifier, type); + + return new_expr; +} + +/*******************************************************************\ + +Function: concatenate_array_id + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +exprt concatenate_array_id( + const exprt &array, const mp_integer &index, + const typet &type) +{ + std::string a, identifier; + a = array.get_string(ID_identifier); + identifier=a+"["+integer2string(index)+"]"; + symbol_exprt new_expr(identifier, type); + + return new_expr; +} + +/*******************************************************************\ + Function: constant_propagator_domaint::assign_rec Inputs: @@ -33,14 +88,36 @@ void constant_propagator_domaint::assign_rec( const exprt &lhs, const exprt &rhs, const namespacet &ns) { - const typet &rhs_type = ns.follow(rhs.type()); + const typet & lhs_type = ns.follow(lhs.type()); + const typet & rhs_type = ns.follow(rhs.type()); #ifdef DEBUG std::cout << "assign: " << from_expr(ns, "", lhs) << " := " << from_type(ns, "", rhs_type) << std::endl; #endif - if(lhs.id()==ID_symbol && rhs_type.id()!=ID_array + if(lhs.id()==ID_symbol && rhs.id()==ID_if) + { + exprt cond=rhs.op0(); + assert(cond.operands().size()==2); + if(values.is_constant(cond.op0()) + && values.is_constant(cond.op1())) + { + if(cond.op0().id()==ID_index) + { + exprt index=cond.op0(); + exprt new_expr=concatenate_array_id(index.op0(), index.op1(), index.type()); + values.replace_const(new_expr); + cond.op0()=new_expr; + cond = simplify_expr(cond,ns); + } + else + assert(0); + + assign(values, to_symbol_expr(lhs), cond, ns); + } + } + else if(lhs.id()==ID_symbol && rhs_type.id()!=ID_array && rhs_type.id()!=ID_struct && rhs_type.id()!=ID_union) { @@ -49,6 +126,27 @@ void constant_propagator_domaint::assign_rec( else values.set_to_top(to_symbol_expr(lhs)); } + else if(lhs.id()==ID_symbol && lhs_type.id()==ID_array + && rhs_type.id()==ID_array) + { + exprt new_expr; + mp_integer idx=0; + forall_operands(it, rhs) + { + new_expr=concatenate_array_id(lhs, idx, it->type()); + assign(values, to_symbol_expr(new_expr), *it, ns); + idx = idx +1; + } + } + else if (lhs.id()==ID_index) + { + if (values.is_constant(lhs.op1()) + && values.is_constant(rhs)) + { + exprt new_expr=concatenate_array_id(lhs.op0(), lhs.op1(), rhs.type()); + assign(values, to_symbol_expr(new_expr), rhs, ns); + } + } #if 0 else // TODO: could make field or array element-sensitive { @@ -104,12 +202,22 @@ void constant_propagator_domaint::transform( else if(from->is_goto()) { exprt g; + if(from->get_target()==to) g = simplify_expr(from->guard, ns); else g = simplify_expr(not_exprt(from->guard), ns); - two_way_propagate_rec(g, ns); + if (g.is_false()) + values.set_to_bottom(); + else + { + //TODO: we need to support widening! + if (g.is_constant()) + values.set_to_top(); + else + two_way_propagate_rec(g, ns); + } } else if(from->is_dead()) { @@ -139,6 +247,7 @@ void constant_propagator_domaint::transform( else values.set_to_top(); } + #ifdef DEBUG std::cout << "after:\n"; output(std::cout, ai, ns); @@ -224,6 +333,30 @@ void constant_propagator_domaint::assign( /*******************************************************************\ +Function: constant_propagator_domaint::is_array_constant + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +bool constant_propagator_domaint::valuest::is_array_constant(const exprt &expr) const +{ + exprt new_expr = concatenate_array_id(expr.op0(), + expr.op1(), expr.type()); + + if (replace_const.expr_map.find(to_symbol_expr(new_expr).get_identifier()) == + replace_const.expr_map.end()) + return false; + + return true; +} + +/*******************************************************************\ + Function: constant_propagator_domaint::valuest::is_constant Inputs: @@ -249,6 +382,9 @@ bool constant_propagator_domaint::valuest::is_constant(const exprt &expr) const replace_const.expr_map.end()) return false; + if (expr.id()==ID_index) + return is_array_constant(expr); + if(expr.id()==ID_address_of) return is_constant_address_of(to_address_of_expr(expr).object()); @@ -399,38 +535,25 @@ bool constant_propagator_domaint::valuest::merge(const valuest &src) it!=replace_const.expr_map.end(); ) // no it++ { - if(src.replace_const.expr_map.find(it->first) == - src.replace_const.expr_map.end()) + const replace_symbolt::expr_mapt::const_iterator + b_it=src.replace_const.expr_map.find(it->first); + + if(b_it==src.replace_const.expr_map.end()) { - // cannot use set_to_top here - replace_const.expr_map.erase(it++); + //cannot use set_to_top here + replace_const.expr_map.erase(it); changed = true; + break; } - else ++it; - } - - for(const auto &src_replace_pair : src.replace_const.expr_map) - { - replace_symbolt::expr_mapt::iterator c_it= - replace_const.expr_map.find(src_replace_pair.first); - - if(c_it!=replace_const.expr_map.end()) + else { - // values are different, set to top - if(c_it->second!=src_replace_pair.second) - { - changed=set_to_top(src_replace_pair.first); - assert(changed); - } + const exprt previous=it->second; + replace_const.expr_map[b_it->first]=b_it->second; + if (it->second != previous) changed = true; + + it++; } - // is not in "this", ignore - else { } } - -#ifdef DEBUG - std::cout << "merged: " << changed << '\n'; -#endif - return changed; } @@ -519,6 +642,34 @@ void constant_propagator_ait::replace( /*******************************************************************\ +Function: constant_propagator_ait::replace_array_symbol + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +void constant_propagator_ait::replace_array_symbol(exprt &expr) +{ + if (expr.id()==ID_index) + expr = concatenate_array_id(expr.op0(), + expr.op1(), expr.type()); + + Forall_operands(it, expr) + { + if (it->id()==ID_equal) + replace_array_symbol(it->op0()); + else if (it->id()==ID_index) + replace_array_symbol(expr.op0()); + } + +} + +/*******************************************************************\ + Function: constant_propagator_ait::replace Inputs: @@ -545,6 +696,7 @@ void constant_propagator_ait::replace( if(it->is_goto() || it->is_assume() || it->is_assert()) { + replace_array_symbol(it->guard); s_it->second.values.replace_const(it->guard); it->guard = simplify_expr(it->guard, ns); } @@ -553,6 +705,8 @@ void constant_propagator_ait::replace( exprt &rhs = to_code_assign(it->code).rhs(); s_it->second.values.replace_const(rhs); rhs = simplify_expr(rhs, ns); + if (rhs.id()==ID_constant) + rhs.add_source_location()=it->code.op0().source_location(); } else if(it->is_function_call()) { diff --git a/src/analyses/constant_propagator.h b/src/analyses/constant_propagator.h index 935b74a1421..0766b458f7d 100644 --- a/src/analyses/constant_propagator.h +++ b/src/analyses/constant_propagator.h @@ -62,6 +62,7 @@ class constant_propagator_domaint:public ai_domain_baset } bool is_constant(const exprt &expr) const; + bool is_array_constant(const exprt &expr) const; bool is_constant_address_of(const exprt &expr) const; bool set_to_top(const irep_idt &id); @@ -75,6 +76,7 @@ class constant_propagator_domaint:public ai_domain_baset replace_const.clear(); is_bottom = false; } + }; valuest values; @@ -117,6 +119,11 @@ class constant_propagator_ait:public ait } protected: + friend class constant_propagator_domaint; + + void replace_array_symbol( + exprt &expr); + void replace( goto_functionst::goto_functiont &, const namespacet &); @@ -128,6 +135,7 @@ class constant_propagator_ait:public ait void replace_types_rec( const replace_symbolt &replace_const, exprt &expr); + }; #endif // CPROVER_ANALYSES_CONSTANT_PROPAGATOR_H diff --git a/src/analyses/does_remove_const.cpp b/src/analyses/does_remove_const.cpp new file mode 100644 index 00000000000..fcccd8219c9 --- /dev/null +++ b/src/analyses/does_remove_const.cpp @@ -0,0 +1,167 @@ +/*******************************************************************\ + + Module: Analyses + + Author: DiffBlue Limited. All rights reserved. + +\*******************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include "does_remove_const.h" + +/*******************************************************************\ + +Function: does_remove_constt::does_remove_constt + + Inputs: + goto_program - the goto program to check + ns - the namespace of the goto program (used for checking type equality) + + Outputs: + + Purpose: A naive analysis to look for casts that remove const-ness from + pointers. + +\*******************************************************************/ + +does_remove_constt::does_remove_constt( + const goto_programt &goto_program, + const namespacet &ns): + goto_program(goto_program), + ns(ns) +{} + +/*******************************************************************\ + +Function: does_remove_constt::operator() + + Inputs: + + Outputs: Returns true if the program contains a const-removing cast + + Purpose: A naive analysis to look for casts that remove const-ness from + pointers. + +\*******************************************************************/ + +bool does_remove_constt::operator()() const +{ + for(const goto_programt::instructiont &instruction : + goto_program.instructions) + { + if(!instruction.is_assign()) + { + continue; + } + + const code_assignt &assign=to_code_assign(instruction.code); + const typet &rhs_type=assign.rhs().type(); + const typet &lhs_type=assign.lhs().type(); + + // Compare the types recursively for a point where the rhs is more + // const that the lhs + if(!is_type_at_least_as_const_as(&lhs_type, &rhs_type)) + { + return true; + } + + if(does_expr_lose_const(assign.rhs())) + { + return true; + } + } + + return false; +} + +/*******************************************************************\ + +Function: does_remove_constt::does_expr_lose_const() + + Inputs: + expr - The expression to check + + Outputs: Returns true if somewhere in the passed expression tree the const-ness + is lost. + + Purpose: Search the expression tree to look for any children that have the + same base type, but a less strict const qualification. + If one is found, we return true. + +\*******************************************************************/ + +bool does_remove_constt::does_expr_lose_const(const exprt &expr) const +{ + const typet &root_type=expr.type(); + + // Look in each child that has the same base type as the root + for(const exprt &op : expr.operands()) + { + const typet &op_type=op.type(); + if(base_type_eq(op_type, root_type, ns)) + { + // Is this child more const-qualified than the root + if(!is_type_at_least_as_const_as(&root_type, &op_type)) + { + return true; + } + } + + // Recursively check the children of this child + if(does_expr_lose_const(op)) + { + return true; + } + } + return false; +} + +/*******************************************************************\ + +Function: does_remove_constt::is_type_at_least_as_const_as + + Inputs: + type_more_const - the type we are expecting to be at least as const qualified + type_compare - the type we are comparing against which may be less const + qualified + + Outputs: Returns true if type_more_const is at least as const as type_compare + + Purpose: A recursive check to check the type_more_const is at least as const + as type compare. + + type_more_const | type_compare || result + ---------------------------------------- + const int * | const int * -> true + int * | const int * -> false + const int * | int * -> true + int * | int * const -> false + +\*******************************************************************/ + +bool does_remove_constt::is_type_at_least_as_const_as( + const typet *type_more_const, const typet *type_compare) const +{ + while(type_compare->id()!=ID_nil && type_more_const->id()!=ID_nil) + { + const c_qualifierst rhs_qualifiers(*type_compare); + const c_qualifierst lhs_qualifiers(*type_more_const); + if(rhs_qualifiers.is_constant && !lhs_qualifiers.is_constant) + { + return false; + } + + type_compare=&type_compare->subtype(); + type_more_const=&type_more_const->subtype(); + } + + // Both the types should have the same number of subtypes + assert(type_compare->id()==ID_nil && type_more_const->id()==ID_nil); + return true; +} diff --git a/src/analyses/does_remove_const.h b/src/analyses/does_remove_const.h new file mode 100644 index 00000000000..594682c7d50 --- /dev/null +++ b/src/analyses/does_remove_const.h @@ -0,0 +1,31 @@ +/*******************************************************************\ + + Module: Analyses + + Author: DiffBlue Limited. All rights reserved. + +\*******************************************************************/ +#ifndef CPROVER_ANALYSES_DOES_REMOVE_CONST_H +#define CPROVER_ANALYSES_DOES_REMOVE_CONST_H + +#include + +class goto_programt; + +class does_remove_constt +{ +public: + does_remove_constt(const goto_programt &goto_program, const namespacet &ns); + bool operator()() const; + +private: + bool does_expr_lose_const(const exprt &expr) const; + + bool is_type_at_least_as_const_as( + const typet *type_more_const, const typet *type_compare) const; + + const goto_programt &goto_program; + const namespacet &ns; +}; + +#endif // CPROVER_ANALYSES_DOES_REMOVE_CONST_H diff --git a/src/analyses/goto_check.cpp b/src/analyses/goto_check.cpp index 7bba83bd298..cc418d6aed9 100644 --- a/src/analyses/goto_check.cpp +++ b/src/analyses/goto_check.cpp @@ -62,17 +62,19 @@ class goto_checkt typedef goto_functionst::goto_functiont goto_functiont; - void goto_check(goto_functiont &goto_function); - - irep_idt mode; + void goto_check(goto_functiont &goto_function, const irep_idt &mode); protected: const namespacet &ns; local_bitvector_analysist *local_bitvector_analysis; goto_programt::const_targett t; - void check_rec(const exprt &expr, guardt &guard, bool address); - void check(const exprt &expr); + void check_rec( + const exprt &expr, + guardt &guard, + bool address, + const irep_idt &mode); + void check(const exprt &expr, const irep_idt &mode); void bounds_check(const index_exprt &expr, const guardt &guard); void div_by_zero_check(const div_exprt &expr, const guardt &guard); @@ -84,7 +86,8 @@ class goto_checkt const dereference_exprt &expr, const guardt &guard, const exprt &access_lb, - const exprt &access_ub); + const exprt &access_ub, + const irep_idt &mode); void integer_overflow_check(const exprt &expr, const guardt &guard); void conversion_check(const exprt &expr, const guardt &guard); void float_overflow_check(const exprt &expr, const guardt &guard); @@ -993,9 +996,10 @@ void goto_checkt::pointer_validity_check( const dereference_exprt &expr, const guardt &guard, const exprt &access_lb, - const exprt &access_ub) + const exprt &access_ub, + const irep_idt &mode) { - if(!enable_pointer_check) + if(mode!=ID_java && !enable_pointer_check) return; const exprt &pointer=expr.op0(); @@ -1373,7 +1377,8 @@ Function: goto_checkt::check_rec void goto_checkt::check_rec( const exprt &expr, guardt &guard, - bool address) + bool address, + const irep_idt &mode) { // we don't look into quantifiers if(expr.id()==ID_exists || expr.id()==ID_forall) @@ -1384,18 +1389,18 @@ void goto_checkt::check_rec( if(expr.id()==ID_dereference) { assert(expr.operands().size()==1); - check_rec(expr.op0(), guard, false); + check_rec(expr.op0(), guard, false, mode); } else if(expr.id()==ID_index) { assert(expr.operands().size()==2); - check_rec(expr.op0(), guard, true); - check_rec(expr.op1(), guard, false); + check_rec(expr.op0(), guard, true, mode); + check_rec(expr.op1(), guard, false, mode); } else { forall_operands(it, expr) - check_rec(*it, guard, true); + check_rec(*it, guard, true, mode); } return; } @@ -1403,7 +1408,7 @@ void goto_checkt::check_rec( if(expr.id()==ID_address_of) { assert(expr.operands().size()==1); - check_rec(expr.op0(), guard, true); + check_rec(expr.op0(), guard, true, mode); return; } else if(expr.id()==ID_and || expr.id()==ID_or) @@ -1420,7 +1425,7 @@ void goto_checkt::check_rec( throw "`"+expr.id_string()+"' takes Boolean operands only, but got "+ op.pretty(); - check_rec(op, guard, false); + check_rec(op, guard, false, mode); if(expr.id()==ID_or) guard.add(not_exprt(op)); @@ -1445,19 +1450,19 @@ void goto_checkt::check_rec( throw msg; } - check_rec(expr.op0(), guard, false); + check_rec(expr.op0(), guard, false, mode); { guardt old_guard=guard; guard.add(expr.op0()); - check_rec(expr.op1(), guard, false); + check_rec(expr.op1(), guard, false, mode); guard.swap(old_guard); } { guardt old_guard=guard; guard.add(not_exprt(expr.op0())); - check_rec(expr.op2(), guard, false); + check_rec(expr.op2(), guard, false, mode); guard.swap(old_guard); } @@ -1470,7 +1475,7 @@ void goto_checkt::check_rec( const dereference_exprt &deref= to_dereference_expr(member.struct_op()); - check_rec(deref.op0(), guard, false); + check_rec(deref.op0(), guard, false, mode); exprt access_ub=nil_exprt(); @@ -1480,13 +1485,13 @@ void goto_checkt::check_rec( if(member_offset.is_not_nil() && size.is_not_nil()) access_ub=plus_exprt(member_offset, size); - pointer_validity_check(deref, guard, member_offset, access_ub); + pointer_validity_check(deref, guard, member_offset, access_ub, mode); return; } forall_operands(it, expr) - check_rec(*it, guard, false); + check_rec(*it, guard, false, mode); if(expr.id()==ID_index) { @@ -1545,7 +1550,8 @@ void goto_checkt::check_rec( to_dereference_expr(expr), guard, nil_exprt(), - size_of_expr(expr.type(), ns)); + size_of_expr(expr.type(), ns), + mode); } /*******************************************************************\ @@ -1560,10 +1566,10 @@ Function: goto_checkt::check \*******************************************************************/ -void goto_checkt::check(const exprt &expr) +void goto_checkt::check(const exprt &expr, const irep_idt &mode) { guardt guard; - check_rec(expr, guard, false); + check_rec(expr, guard, false, mode); } /*******************************************************************\ @@ -1574,18 +1580,14 @@ Function: goto_checkt::goto_check Outputs: - Purpose:[B + Purpose: \*******************************************************************/ -void goto_checkt::goto_check(goto_functiont &goto_function) +void goto_checkt::goto_check( + goto_functiont &goto_function, + const irep_idt &mode) { - { - const symbolt *init_symbol; - if(!ns.lookup(CPROVER_PREFIX "initialize", init_symbol)) - mode=init_symbol->mode; - } - assertions.clear(); local_bitvector_analysist local_bitvector_analysis_obj(goto_function); @@ -1607,7 +1609,7 @@ void goto_checkt::goto_check(goto_functiont &goto_function) i.is_target()) assertions.clear(); - check(i.guard); + check(i.guard, mode); // magic ERROR label? for(const auto &label : error_labels) @@ -1633,20 +1635,20 @@ void goto_checkt::goto_check(goto_functiont &goto_function) if(statement==ID_expression) { - check(i.code); + check(i.code, mode); } else if(statement==ID_printf) { forall_operands(it, i.code) - check(*it); + check(*it, mode); } } else if(i.is_assign()) { const code_assignt &code_assign=to_code_assign(i.code); - check(code_assign.lhs()); - check(code_assign.rhs()); + check(code_assign.lhs(), mode); + check(code_assign.rhs(), mode); // the LHS might invalidate any assertion invalidate(code_assign.lhs()); @@ -1686,7 +1688,7 @@ void goto_checkt::goto_check(goto_functiont &goto_function) } forall_operands(it, code_function_call) - check(*it); + check(*it, mode); // the call might invalidate any assertion assertions.clear(); @@ -1695,7 +1697,7 @@ void goto_checkt::goto_check(goto_functiont &goto_function) { if(i.code.operands().size()==1) { - check(i.code.op0()); + check(i.code.op0(), mode); // the return value invalidate any assertion invalidate(i.code.op0()); } @@ -1853,7 +1855,7 @@ void goto_check( goto_functionst::goto_functiont &goto_function) { goto_checkt goto_check(ns, options); - goto_check.goto_check(goto_function); + goto_check.goto_check(goto_function, irep_idt()); } /*******************************************************************\ @@ -1877,7 +1879,8 @@ void goto_check( Forall_goto_functions(it, goto_functions) { - goto_check.goto_check(it->second); + irep_idt mode=ns.lookup(it->first).mode; + goto_check.goto_check(it->second, mode); } } @@ -1898,10 +1901,5 @@ void goto_check( goto_modelt &goto_model) { const namespacet ns(goto_model.symbol_table); - goto_checkt goto_check(ns, options); - - Forall_goto_functions(it, goto_model.goto_functions) - { - goto_check.goto_check(it->second); - } + goto_check(ns, options, goto_model.goto_functions); } diff --git a/src/analyses/goto_check.h b/src/analyses/goto_check.h index 7ad04f99f79..4e1bbbbba60 100644 --- a/src/analyses/goto_check.h +++ b/src/analyses/goto_check.h @@ -37,7 +37,7 @@ void goto_check( #define HELP_GOTO_CHECK \ " --bounds-check enable array bounds checks\n" \ - " --pointer-check enable pointer checks\n" \ + " --pointer-check enable pointer checks (always enabled for Java)\n" /* NOLINT(whitespace/line_length) */ \ " --memory-leak-check enable memory leak checks\n" \ " --div-by-zero-check enable division by zero checks\n" \ " --signed-overflow-check enable signed arithmetic over- and underflow checks\n" /* NOLINT(whitespace/line_length) */ \ diff --git a/src/analyses/interval_domain.cpp b/src/analyses/interval_domain.cpp index cc10fd89b00..1faf8c52364 100644 --- a/src/analyses/interval_domain.cpp +++ b/src/analyses/interval_domain.cpp @@ -157,7 +157,9 @@ bool interval_domaint::merge( for(int_mapt::iterator it=int_map.begin(); it!=int_map.end(); ) // no it++ { - const int_mapt::const_iterator b_it=b.int_map.begin(); + //search for the variable that needs to be merged + //containers have different size and variable order + const int_mapt::const_iterator b_it=b.int_map.find(it->first); if(b_it==b.int_map.end()) { it=int_map.erase(it); diff --git a/src/analyses/is_threaded.h b/src/analyses/is_threaded.h index ceb10494665..738857b8b8a 100644 --- a/src/analyses/is_threaded.h +++ b/src/analyses/is_threaded.h @@ -29,6 +29,11 @@ class is_threadedt return is_threaded_set.find(t)!=is_threaded_set.end(); } + bool operator()(void) const + { + return !is_threaded_set.empty(); + } + protected: typedef std::set is_threaded_sett; is_threaded_sett is_threaded_set; diff --git a/src/ansi-c/ansi_c_declaration.cpp b/src/ansi-c/ansi_c_declaration.cpp index 4c82adc307a..7f9d0980583 100644 --- a/src/ansi-c/ansi_c_declaration.cpp +++ b/src/ansi-c/ansi_c_declaration.cpp @@ -146,6 +146,10 @@ typet ansi_c_declarationt::full_type( *p=type(); + // retain typedef for dump-c + if(get_is_typedef()) + result.set(ID_C_typedef, declarator.get_name()); + return result; } diff --git a/src/ansi-c/c_typecheck_type.cpp b/src/ansi-c/c_typecheck_type.cpp index f875bdec7d4..d82e81c0038 100644 --- a/src/ansi-c/c_typecheck_type.cpp +++ b/src/ansi-c/c_typecheck_type.cpp @@ -52,6 +52,7 @@ void c_typecheck_baset::typecheck_type(typet &type) c_qualifiers+=c_qualifierst(type.subtype()); bool packed=type.get_bool(ID_C_packed); exprt alignment=static_cast(type.find(ID_C_alignment)); + irept _typedef=type.find(ID_C_typedef); type.swap(type.subtype()); @@ -60,6 +61,8 @@ void c_typecheck_baset::typecheck_type(typet &type) type.set(ID_C_packed, true); if(alignment.is_not_nil()) type.add(ID_C_alignment, alignment); + if(_typedef.is_not_nil()) + type.add(ID_C_typedef, _typedef); return; // done } diff --git a/src/ansi-c/expr2c.cpp b/src/ansi-c/expr2c.cpp index 356aeded154..fa7b75698fa 100644 --- a/src/ansi-c/expr2c.cpp +++ b/src/ansi-c/expr2c.cpp @@ -233,6 +233,11 @@ std::string expr2ct::convert_rec( std::string d= declarator==""?declarator:" "+declarator; + if(src.find(ID_C_typedef).is_not_nil()) + { + return q+id2string(src.get(ID_C_typedef))+d; + } + if(src.id()==ID_bool) { return q+"_Bool"+d; diff --git a/src/cbmc/cbmc_parse_options.cpp b/src/cbmc/cbmc_parse_options.cpp index 60c0f706c62..1124e8992b5 100644 --- a/src/cbmc/cbmc_parse_options.cpp +++ b/src/cbmc/cbmc_parse_options.cpp @@ -884,6 +884,7 @@ bool cbmc_parse_optionst::process_goto_program( // remove function pointers status() << "Removal of function pointers and virtual functions" << eom; remove_function_pointers( + get_message_handler(), symbol_table, goto_functions, cmdline.isset("pointer-check")); diff --git a/src/cbmc/symex_bmc.cpp b/src/cbmc/symex_bmc.cpp index 1dd1e8dceb9..5ae65275ef6 100644 --- a/src/cbmc/symex_bmc.cpp +++ b/src/cbmc/symex_bmc.cpp @@ -9,6 +9,7 @@ Author: Daniel Kroening, kroening@kroening.com #include #include +#include #include "symex_bmc.h" @@ -63,11 +64,67 @@ void symex_bmct::symex_step( last_source_location=source_location; } - if(record_coverage && - !state.guard.is_false()) - symex_coverage.covered(state.source.pc); + const goto_programt::const_targett cur_pc=state.source.pc; + + if(!state.guard.is_false() && + state.source.pc->is_assume() && + simplify_expr(state.source.pc->guard, ns).is_false()) + { + statistics() << "aborting path on assume(false) at " + << state.source.pc->source_location + << " thread " << state.source.thread_nr; + + const irep_idt &c=state.source.pc->source_location.get_comment(); + if(!c.empty()) + statistics() << ": " << c; + + statistics() << eom; + } goto_symext::symex_step(goto_functions, state); + + if(record_coverage && + // is the instruction being executed + !state.guard.is_false() && + // avoid an invalid iterator in state.source.pc + (!cur_pc->is_end_function() || + cur_pc->function!=goto_functions.entry_point()) && + // ignore transition to next instruction when goto points elsewhere + (!cur_pc->is_goto() || + cur_pc->get_target()==state.source.pc || + !cur_pc->guard.is_true())) + symex_coverage.covered(cur_pc, state.source.pc); +} + +/*******************************************************************\ + +Function: symex_bmct::merge_goto + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +void symex_bmct::merge_goto( + const statet::goto_statet &goto_state, + statet &state) +{ + const goto_programt::const_targett prev_pc=goto_state.source.pc; + const guardt prev_guard=goto_state.guard; + + goto_symext::merge_goto(goto_state, state); + + assert(prev_pc->is_goto()); + if(record_coverage && + // could the branch possibly be taken? + !prev_guard.is_false() && + !state.guard.is_false() && + // branches only, no single-successor goto + !prev_pc->guard.is_true()) + symex_coverage.covered(prev_pc, state.source.pc); } /*******************************************************************\ diff --git a/src/cbmc/symex_bmc.h b/src/cbmc/symex_bmc.h index 10f4b821e88..8b2df348f3b 100644 --- a/src/cbmc/symex_bmc.h +++ b/src/cbmc/symex_bmc.h @@ -83,6 +83,10 @@ class symex_bmct: const goto_functionst &goto_functions, statet &state); + virtual void merge_goto( + const statet::goto_statet &goto_state, + statet &state); + // for loop unwinding virtual bool get_unwind( const symex_targett::sourcet &source, diff --git a/src/cbmc/symex_coverage.cpp b/src/cbmc/symex_coverage.cpp index 69af02e9e9e..812df4de062 100644 --- a/src/cbmc/symex_coverage.cpp +++ b/src/cbmc/symex_coverage.cpp @@ -19,6 +19,7 @@ Date: March 2016 #include #include +#include #include "symex_coverage.h" @@ -57,26 +58,37 @@ class goto_program_coverage_recordt:public coverage_recordt protected: irep_idt file_name; - struct line_coverage_recordt + struct coverage_conditiont { - line_coverage_recordt(): - hits(0), is_branch(false), branch_covered(false) + coverage_conditiont(): + false_taken(false), true_taken(false) + { + } + + bool false_taken; + bool true_taken; + }; + + struct coverage_linet + { + coverage_linet(): + hits(0) { } unsigned hits; - bool is_branch; - bool branch_covered; + std::map + conditions; }; - typedef std::map - line_coverage_mapt; + typedef std::map + coverage_lines_mapt; - void compute_line_coverage( + void compute_coverage_lines( const goto_programt &goto_program, const irep_idt &file_name, const symex_coveraget::coveraget &coverage, - line_coverage_mapt &dest); + coverage_lines_mapt &dest); }; /*******************************************************************\ @@ -91,17 +103,26 @@ Function: rate \*******************************************************************/ -static std::string rate(std::size_t covered, std::size_t total) +static std::string rate( + std::size_t covered, + std::size_t total, + bool per_cent=false) { + std::ostringstream oss; + #if 1 - if(total==0) - return "1.0"; + float fraction; - std::ostringstream oss; + if(total==0) + fraction=1.0; + else + fraction=static_cast(covered)/static_cast(total); - oss << static_cast(covered)/static_cast(total); + if(per_cent) + oss << fraction*100.0 << '%'; + else + oss << fraction; #else - std::ostringstream oss; oss << covered << " of " << total; #endif @@ -137,12 +158,12 @@ goto_program_coverage_recordt::goto_program_coverage_recordt( assert(!file_name.empty()); // compute the maximum coverage of individual source-code lines - line_coverage_mapt line_coverage_map; - compute_line_coverage( + coverage_lines_mapt coverage_lines_map; + compute_coverage_lines( gf_it->second.body, file_name, coverage, - line_coverage_map); + coverage_lines_map); // // @@ -157,8 +178,14 @@ goto_program_coverage_recordt::goto_program_coverage_recordt( // // xml.set_attribute("name", id2string(gf_it->first)); + + code_typet sig_type= + original_return_type(ns.get_symbol_table(), gf_it->first); + if(sig_type.is_nil()) + sig_type=gf_it->second.type; xml.set_attribute("signature", - from_type(ns, gf_it->first, gf_it->second.type)); + from_type(ns, gf_it->first, sig_type)); + xml.set_attribute("line-rate", rate(lines_covered, lines_total)); xml.set_attribute("branch-rate", @@ -166,28 +193,43 @@ goto_program_coverage_recordt::goto_program_coverage_recordt( xmlt &lines=xml.new_element("lines"); - for(line_coverage_mapt::const_iterator - it=line_coverage_map.begin(); - it!=line_coverage_map.end(); - ++it) + for(const auto &cov_line : coverage_lines_map) { xmlt &line=lines.new_element("line"); - line.set_attribute("number", std::to_string(it->first)); - line.set_attribute("hits", std::to_string(it->second.hits)); - if(!it->second.is_branch) + line.set_attribute("number", std::to_string(cov_line.first)); + line.set_attribute("hits", std::to_string(cov_line.second.hits)); + if(cov_line.second.conditions.empty()) line.set_attribute("branch", "false"); else { - // TODO: conditions line.set_attribute("branch", "true"); + + xmlt &conditions=line.new_element("conditions"); + + std::size_t number=0, total_taken=0; + for(const auto &c : cov_line.second.conditions) + { + // + xmlt &condition=conditions.new_element("condition"); + condition.set_attribute("number", std::to_string(number++)); + condition.set_attribute("type", "jump"); + unsigned taken=c.second.false_taken+c.second.true_taken; + total_taken+=taken; + condition.set_attribute("coverage", rate(taken, 2, true)); + } + + std::ostringstream oss; + oss << rate(total_taken, number*2, true) + << " (" << total_taken << '/' << number*2 << ')'; + line.set_attribute("condition-coverage", oss.str()); } } } /*******************************************************************\ -Function: goto_program_coverage_recordt::compute_line_coverage +Function: goto_program_coverage_recordt::compute_coverage_lines Inputs: @@ -197,58 +239,83 @@ Function: goto_program_coverage_recordt::compute_line_coverage \*******************************************************************/ -void goto_program_coverage_recordt::compute_line_coverage( +void goto_program_coverage_recordt::compute_coverage_lines( const goto_programt &goto_program, const irep_idt &file_name, const symex_coveraget::coveraget &coverage, - line_coverage_mapt &dest) + coverage_lines_mapt &dest) { forall_goto_program_instructions(it, goto_program) { if(it->source_location.is_nil() || - it->source_location.get_file()!=file_name) + it->source_location.get_file()!=file_name || + it->is_dead() || + it->is_end_function()) continue; const bool is_branch=it->is_goto() && !it->guard.is_constant(); unsigned l= safe_string2unsigned(id2string(it->source_location.get_line())); - std::pair entry= - dest.insert(std::make_pair(l, line_coverage_recordt())); + std::pair entry= + dest.insert(std::make_pair(l, coverage_linet())); if(entry.second) - { ++lines_total; - if(is_branch) - ++branches_total; - } // mark as branch if any instruction in this source code line is // a branching instruction - if(is_branch && - !entry.first->second.is_branch) + if(is_branch) { - ++branches_total; - entry.first->second.is_branch=true; + branches_total+=2; + if(!entry.first->second.conditions.insert( + {it, coverage_conditiont()}).second) + assert(false); } symex_coveraget::coveraget::const_iterator c_entry= coverage.find(it); - if(c_entry!=coverage.end() && - c_entry->second.num_executions>0) + if(c_entry!=coverage.end()) { - // maximum over all instructions in this source code line - if(c_entry->second.num_executions>entry.first->second.hits) + if(!(c_entry->second.size()==1 || is_branch)) { - if(entry.first->second.hits==0) - ++lines_covered; - entry.first->second.hits=c_entry->second.num_executions; + std::cerr << it->location_number << std::endl; + for(const auto &cov : c_entry->second) + std::cerr << cov.second.succ->location_number << std::endl; } + assert(c_entry->second.size()==1 || is_branch); - if(is_branch && !entry.first->second.branch_covered) + for(const auto &cov : c_entry->second) { - ++branches_covered; - entry.first->second.branch_covered=true; + assert(cov.second.num_executions>0); + + if(entry.first->second.hits==0) + ++lines_covered; + + entry.first->second.hits+=cov.second.num_executions; + + if(is_branch) + { + auto cond_entry=entry.first->second.conditions.find(it); + assert(cond_entry!=entry.first->second.conditions.end()); + + if(it->get_target()==cov.second.succ) + { + if(!cond_entry->second.false_taken) + { + cond_entry->second.false_taken=true; + ++branches_covered; + } + } + else + { + if(!cond_entry->second.true_taken) + { + cond_entry->second.true_taken=true; + ++branches_covered; + } + } + } } } } @@ -276,7 +343,7 @@ void symex_coveraget::compute_overall_coverage( forall_goto_functions(gf_it, goto_functions) { if(!gf_it->second.body_available() || - gf_it->first==ID__start || + gf_it->first==goto_functions.entry_point() || gf_it->first==CPROVER_PREFIX "initialize") continue; diff --git a/src/cbmc/symex_coverage.h b/src/cbmc/symex_coverage.h index 0e71b430630..c173bc65ad7 100644 --- a/src/cbmc/symex_coverage.h +++ b/src/cbmc/symex_coverage.h @@ -29,11 +29,12 @@ class symex_coveraget { } - void covered(goto_programt::const_targett location) + void covered( + goto_programt::const_targett from, + goto_programt::const_targett to) { - std::pair entry= - coverage.insert(std::make_pair(location, - coverage_infot(location, 1))); + std::pair entry= + coverage[from].insert({to, coverage_infot(from, to, 1)}); if(!entry.second) ++(entry.first->second.num_executions); @@ -49,17 +50,22 @@ class symex_coveraget struct coverage_infot { coverage_infot( - goto_programt::const_targett _location, + goto_programt::const_targett _from, + goto_programt::const_targett _to, unsigned _num_executions): - location(_location), num_executions(_num_executions) + location(_from), num_executions(_num_executions), + succ(_to) { } goto_programt::const_targett location; unsigned num_executions; + goto_programt::const_targett succ; }; typedef std::map + coverage_innert; + typedef std::map coveraget; coveraget coverage; diff --git a/src/cegis/invariant/fitness/concrete_fitness_source_provider.cpp b/src/cegis/invariant/fitness/concrete_fitness_source_provider.cpp index 28e41138cb3..dbfa21257c5 100644 --- a/src/cegis/invariant/fitness/concrete_fitness_source_provider.cpp +++ b/src/cegis/invariant/fitness/concrete_fitness_source_provider.cpp @@ -69,9 +69,15 @@ bool contains(const std::string &haystack, const std::string &needle) return std::string::npos != haystack.find(needle); } -bool handle_start(std::string &source, const std::string &line) +bool handle_start( + const goto_functionst &gf, + std::string &source, + const std::string &line) { - if ("void _start(void)" != line) return false; + std::ostringstream start_sig; + start_sig << "void " << gf.entry_point() << "(void)"; + if(start_sig.str()!=line) + return false; source+="int main(const int argc, const char * const argv[])\n"; return true; } @@ -212,17 +218,24 @@ bool handle_internals(const std::string &line) || "static signed int assert#return_value;" == line; } -void post_process(std::string &source, std::stringstream &ss) +void post_process( + const goto_functionst &gf, + std::string &source, + std::stringstream &ss) { bool deserialise_initialised=false; bool ce_initialised=false; for (std::string line; std::getline(ss, line);) { - if (handle_start(source, line) || handle_return_value(line) - || handle_ce_loop(line, ss) || handle_internals(line) - || handle_programs(source, deserialise_initialised, line) - || handle_x0(source, line) || handle_ce(source, ce_initialised, line) - || handle_second_instr_struct(source, line)) continue; + if(handle_start(gf, source, line) || + handle_return_value(line) || + handle_ce_loop(line, ss) || + handle_internals(line) || + handle_programs(source, deserialise_initialised, line) || + handle_x0(source, line) || + handle_ce(source, ce_initialised, line) || + handle_second_instr_struct(source, line)) + continue; replace_ce_index(line); replace_assume(line); fix_cprover_names(line); @@ -254,7 +267,7 @@ std::string &post_process_fitness_source(std::string &result, add_first_prog_offset(result, num_ce_vars); add_assume_implementation(result); add_danger_execute(result, num_vars, num_consts, max_prog_size, exec); - post_process(result, ss); + post_process(gf, result, ss); transform_program_individual_main_to_lib(result, danger); return result; } diff --git a/src/cegis/jsa/genetic/jsa_source_provider.cpp b/src/cegis/jsa/genetic/jsa_source_provider.cpp index 4984bfe1c9b..1182317f771 100644 --- a/src/cegis/jsa/genetic/jsa_source_provider.cpp +++ b/src/cegis/jsa/genetic/jsa_source_provider.cpp @@ -26,7 +26,6 @@ jsa_source_providert::jsa_source_providert(jsa_symex_learnt &lcfg) : { } -#define START_METHOD_PREFIX "void _start" #define RETURN_VALUE_ASSIGNMENT RETURN_VALUE_SUFFIX" =" #define JUMP_BUFFER "__CPROVER_jsa_jump_buffer" #define TEST_SIGNATURE "int " CEGIS_FITNESS_TEST_FUNC \ @@ -104,7 +103,9 @@ void add_main_body(std::string &result, const jsa_symex_learnt &lcfg) std::ostringstream oss; dump_c(entry_only, false, ns, oss); const std::string main_body(oss.str()); - result+=main_body.substr(main_body.find(START_METHOD_PREFIX)); + result+= + main_body.substr( + main_body.find(std::string("void ")+id2string(gf.entry_point()))); } void fix_return_values(std::string &result) @@ -138,9 +139,11 @@ void fix_return_values(std::string &result) substitute(result, "\n return 0;", ""); } -void add_facade_function(std::string &result) +void add_facade_function(const goto_functionst &gf, std::string &result) { - substitute(result, "void _start(void)", TEST_SIGNATURE); + std::ostringstream start_sig; + start_sig << "void " << gf.entry_point() << "(void)"; + substitute(result, start_sig.str(), TEST_SIGNATURE); const std::string::size_type pos=result.find(" __CPROVER_initialize();"); result.insert(pos, " if (setjmp(" JUMP_BUFFER")) return EXIT_FAILURE;\n"); } @@ -249,7 +252,7 @@ const std::string &jsa_source_providert::operator ()() add_temp_clean(source, lcfg.get_symbol_table()); add_main_body(source, lcfg); fix_return_values(source); - add_facade_function(source); + add_facade_function(lcfg.get_goto_functions(), source); insert_solution(source, lcfg); insert_counterexample(source); cleanup(source); diff --git a/src/goto-analyzer/goto_analyzer_parse_options.cpp b/src/goto-analyzer/goto_analyzer_parse_options.cpp index 305bb2f80dd..5f889ff99d7 100644 --- a/src/goto-analyzer/goto_analyzer_parse_options.cpp +++ b/src/goto-analyzer/goto_analyzer_parse_options.cpp @@ -265,6 +265,54 @@ int goto_analyzer_parse_optionst::doit() return 0; } + if(cmdline.isset("unreachable-functions")) + { + const std::string json_file=cmdline.get_value("json"); + + if(json_file.empty()) + unreachable_functions(goto_model, false, std::cout); + else if(json_file=="-") + unreachable_functions(goto_model, true, std::cout); + else + { + std::ofstream ofs(json_file); + if(!ofs) + { + error() << "Failed to open json output `" + << json_file << "'" << eom; + return 6; + } + + unreachable_functions(goto_model, true, ofs); + } + + return 0; + } + + if(cmdline.isset("reachable-functions")) + { + const std::string json_file=cmdline.get_value("json"); + + if(json_file.empty()) + reachable_functions(goto_model, false, std::cout); + else if(json_file=="-") + reachable_functions(goto_model, true, std::cout); + else + { + std::ofstream ofs(json_file); + if(!ofs) + { + error() << "Failed to open json output `" + << json_file << "'" << eom; + return 6; + } + + reachable_functions(goto_model, true, ofs); + } + + return 0; + } + if(cmdline.isset("show-local-may-alias")) { namespacet ns(goto_model.symbol_table); @@ -383,7 +431,8 @@ bool goto_analyzer_parse_optionst::process_goto_program( // remove function pointers status() << "Removing function pointers and virtual functions" << eom; - remove_function_pointers(goto_model, cmdline.isset("pointer-check")); + remove_function_pointers( + get_message_handler(), goto_model, cmdline.isset("pointer-check")); // Java virtual functions -> explicit dispatch tables: remove_virtual_functions(goto_model); // remove Java throw and catch @@ -489,6 +538,10 @@ void goto_analyzer_parse_optionst::help() // NOLINTNEXTLINE(whitespace/line_length) " --taint file_name perform taint analysis using rules in given file\n" " --unreachable-instructions list dead code\n" + // NOLINTNEXTLINE(whitespace/line_length) + " --unreachable-functions list functions unreachable from the entry point\n" + // NOLINTNEXTLINE(whitespace/line_length) + " --reachable-functions list functions reachable from the entry point\n" " --intervals interval analysis\n" " --non-null non-null analysis\n" "\n" @@ -538,6 +591,9 @@ void goto_analyzer_parse_optionst::help() // NOLINTNEXTLINE(whitespace/line_length) " --show-properties show the properties, but don't run analysis\n" "\n" + "Program instrumentation options:\n" + HELP_GOTO_CHECK + "\n" "Other options:\n" " --version show version and exit\n" "\n"; diff --git a/src/goto-analyzer/goto_analyzer_parse_options.h b/src/goto-analyzer/goto_analyzer_parse_options.h index 7b319c8b99b..a72dd9ca76a 100644 --- a/src/goto-analyzer/goto_analyzer_parse_options.h +++ b/src/goto-analyzer/goto_analyzer_parse_options.h @@ -17,6 +17,8 @@ Author: Daniel Kroening, kroening@kroening.com #include #include +#include + class bmct; class goto_functionst; class optionst; @@ -28,6 +30,7 @@ class optionst; "(16)(32)(64)(LP64)(ILP64)(LLP64)(ILP32)(LP32)" \ "(little-endian)(big-endian)" \ OPT_SHOW_GOTO_FUNCTIONS \ + OPT_GOTO_CHECK \ "(show-loops)" \ "(show-symbol-table)(show-parse-tree)" \ "(show-properties)(show-reachable-properties)(property):" \ @@ -36,7 +39,8 @@ class optionst; "(taint):(show-taint)" \ "(show-local-may-alias)" \ "(json):(xml):" \ - "(unreachable-instructions)" \ + "(unreachable-instructions)(unreachable-functions)" \ + "(reachable-functions)" \ "(intervals)(show-intervals)" \ "(non-null)(show-non-null)" diff --git a/src/goto-analyzer/unreachable_instructions.cpp b/src/goto-analyzer/unreachable_instructions.cpp index 06edd28bca6..73514f5b5d5 100644 --- a/src/goto-analyzer/unreachable_instructions.cpp +++ b/src/goto-analyzer/unreachable_instructions.cpp @@ -198,7 +198,12 @@ void unreachable_instructions( const goto_programt &goto_program=f_it->second.body; dead_mapt dead_map; - if(called.find(f_it->first)!=called.end()) + const symbolt &decl=ns.lookup(f_it->first); + + // f_it->first may be a link-time renamed version, use the + // base_name instead; do not list inlined functions + if(called.find(decl.base_name)!=called.end() || + f_it->second.is_inlined()) unreachable_instructions(goto_program, dead_map); else all_unreachable(goto_program, dead_map); @@ -215,3 +220,150 @@ void unreachable_instructions( if(json && !json_result.array.empty()) os << json_result << std::endl; } + +/*******************************************************************\ + +Function: json_output_function + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +static void json_output_function( + const irep_idt &function, + const source_locationt &first_location, + const source_locationt &last_location, + json_arrayt &dest) +{ + json_objectt &entry=dest.push_back().make_object(); + + entry["function"]=json_stringt(id2string(function)); + entry["file name"]= + json_stringt(concat_dir_file( + id2string(first_location.get_working_directory()), + id2string(first_location.get_file()))); + entry["first line"]= + json_numbert(id2string(first_location.get_line())); + entry["last line"]= + json_numbert(id2string(last_location.get_line())); +} + +/*******************************************************************\ + +Function: list_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +static void list_functions( + const goto_modelt &goto_model, + const bool json, + std::ostream &os, + bool unreachable) +{ + json_arrayt json_result; + + std::set called; + compute_called_functions(goto_model, called); + + const namespacet ns(goto_model.symbol_table); + + forall_goto_functions(f_it, goto_model.goto_functions) + { + const symbolt &decl=ns.lookup(f_it->first); + + // f_it->first may be a link-time renamed version, use the + // base_name instead; do not list inlined functions + if(unreachable == + (called.find(decl.base_name)!=called.end() || + f_it->second.is_inlined())) + continue; + + source_locationt first_location=decl.location; + + source_locationt last_location; + if(f_it->second.body_available()) + { + const goto_programt &goto_program=f_it->second.body; + + goto_programt::const_targett end_function= + goto_program.instructions.end(); + --end_function; + assert(end_function->is_end_function()); + last_location=end_function->source_location; + } + else + // completely ignore functions without a body, both for + // reachable and unreachable functions; we could also restrict + // this to macros/asm renaming + continue; + + if(!json) + { + os << concat_dir_file( + id2string(first_location.get_working_directory()), + id2string(first_location.get_file())) << " " + << decl.base_name << " " + << first_location.get_line() << " " + << last_location.get_line() << "\n"; + } + else + json_output_function( + decl.base_name, + first_location, + last_location, + json_result); + } + + if(json && !json_result.array.empty()) + os << json_result << std::endl; +} + +/*******************************************************************\ + +Function: unreachable_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +void unreachable_functions( + const goto_modelt &goto_model, + const bool json, + std::ostream &os) +{ + list_functions(goto_model, json, os, true); +} + +/*******************************************************************\ + +Function: reachable_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +void reachable_functions( + const goto_modelt &goto_model, + const bool json, + std::ostream &os) +{ + list_functions(goto_model, json, os, false); +} diff --git a/src/goto-analyzer/unreachable_instructions.h b/src/goto-analyzer/unreachable_instructions.h index 137e6a62040..a408e004bd8 100644 --- a/src/goto-analyzer/unreachable_instructions.h +++ b/src/goto-analyzer/unreachable_instructions.h @@ -20,4 +20,14 @@ void unreachable_instructions( const bool json, std::ostream &os); +void unreachable_functions( + const goto_modelt &, + const bool json, + std::ostream &os); + +void reachable_functions( + const goto_modelt &, + const bool json, + std::ostream &os); + #endif // CPROVER_GOTO_ANALYZER_UNREACHABLE_INSTRUCTIONS_H diff --git a/src/goto-diff/goto_diff_parse_options.cpp b/src/goto-diff/goto_diff_parse_options.cpp index 1ba3d96a9d4..c66bd9817a6 100644 --- a/src/goto-diff/goto_diff_parse_options.cpp +++ b/src/goto-diff/goto_diff_parse_options.cpp @@ -485,6 +485,7 @@ bool goto_diff_parse_optionst::process_goto_program( // remove function pointers status() << "Function Pointer Removal" << eom; remove_function_pointers( + get_message_handler(), symbol_table, goto_functions, cmdline.isset("pointer-check")); diff --git a/src/goto-instrument/Makefile b/src/goto-instrument/Makefile index 4cbd6121b24..3fbaac8620b 100644 --- a/src/goto-instrument/Makefile +++ b/src/goto-instrument/Makefile @@ -23,7 +23,8 @@ SRC = goto_instrument_parse_options.cpp rw_set.cpp \ wmm/event_graph.cpp wmm/pair_collection.cpp \ goto_instrument_main.cpp horn_encoding.cpp \ thread_instrumentation.cpp skip_loops.cpp loop_utils.cpp \ - code_contracts.cpp cover.cpp model_argc_argv.cpp + code_contracts.cpp cover.cpp model_argc_argv.cpp \ + undefined_functions.cpp OBJ += ../ansi-c/ansi-c$(LIBEXT) \ ../cpp/cpp$(LIBEXT) \ diff --git a/src/goto-instrument/call_sequences.cpp b/src/goto-instrument/call_sequences.cpp index 65fa225c7ed..875d89051a6 100644 --- a/src/goto-instrument/call_sequences.cpp +++ b/src/goto-instrument/call_sequences.cpp @@ -13,6 +13,7 @@ Date: April 2013 #include #include +#include #include "call_sequences.h" @@ -358,3 +359,83 @@ void check_call_sequence(const goto_functionst &goto_functions) check_call_sequencet(goto_functions, sequence)(); } + +/*******************************************************************\ + +Function: list_calls_and_arguments + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +static void list_calls_and_arguments( + const namespacet &ns, + const irep_idt &function, + const goto_programt &goto_program) +{ + forall_goto_program_instructions(i_it, goto_program) + { + if(!i_it->is_function_call()) + continue; + + const code_function_callt call=to_code_function_call(i_it->code); + + const exprt &f=call.function(); + + if(f.id()!=ID_symbol) + continue; + + const irep_idt &identifier=to_symbol_expr(f).get_identifier(); + if(identifier=="__CPROVER_initialize") + continue; + + std::string name=from_expr(ns, identifier, f); + std::string::size_type java_type_suffix=name.find(":("); + if(java_type_suffix!=std::string::npos) + name.erase(java_type_suffix); + + std::cout << "found call to " << name; + + if(!call.arguments().empty()) + { + std::cout << " with arguments "; + for(exprt::operandst::const_iterator + it=call.arguments().begin(); + it!=call.arguments().end(); + ++it) + { + if(it!=call.arguments().begin()) + std::cout << ", "; + std::cout << from_expr(ns, identifier, simplify_expr(*it, ns)); + } + } + + std::cout << '\n'; + } +} + +/*******************************************************************\ + +Function: show_call_sequences + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +void list_calls_and_arguments( + const namespacet &ns, + const goto_functionst &goto_functions) +{ + // do per function + + forall_goto_functions(f_it, goto_functions) + list_calls_and_arguments(ns, f_it->first, f_it->second.body); +} diff --git a/src/goto-instrument/call_sequences.h b/src/goto-instrument/call_sequences.h index 5036d5bc845..ecfc5921ef8 100644 --- a/src/goto-instrument/call_sequences.h +++ b/src/goto-instrument/call_sequences.h @@ -16,4 +16,8 @@ Date: September 2011 void show_call_sequences(const goto_functionst &goto_functions); void check_call_sequence(const goto_functionst &goto_functions); +void list_calls_and_arguments( + const namespacet &ns, + const goto_functionst &goto_functions); + #endif // CPROVER_GOTO_INSTRUMENT_CALL_SEQUENCES_H diff --git a/src/goto-instrument/count_eloc.cpp b/src/goto-instrument/count_eloc.cpp index 96b21195a82..a54bc11f2ad 100644 --- a/src/goto-instrument/count_eloc.cpp +++ b/src/goto-instrument/count_eloc.cpp @@ -14,6 +14,8 @@ Date: December 2012 #include #include +#include + #include "count_eloc.h" typedef std::unordered_set linest; @@ -104,3 +106,83 @@ void list_eloc(const goto_functionst &goto_functions) std::cout << file << ':' << line << '\n'; } } + +/*******************************************************************\ + +Function: print_path_lengths + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +void print_path_lengths(const goto_functionst &goto_functions) +{ + const irep_idt &entry_point=goto_functions.entry_point(); + goto_functionst::function_mapt::const_iterator start= + goto_functions.function_map.find(entry_point); + + if(start==goto_functions.function_map.end() || + !start->second.body_available()) + { + std::cout << "No entry point found, path length undefined\n"; + return; + } + + struct visited_cfg_nodet + { + bool visited; + + visited_cfg_nodet():visited(false) + { + } + }; + + typedef cfg_baset cfgt; + cfgt cfg; + cfg(goto_functions); + + const goto_programt &start_program=start->second.body; + + const cfgt::entryt &start_node= + cfg.entry_map[start_program.instructions.begin()]; + const cfgt::entryt &last_node= + cfg.entry_map[--start_program.instructions.end()]; + + cfgt::patht shortest_path; + cfg.shortest_path(start_node, last_node, shortest_path); + std::cout << "Shortest control-flow path: " << shortest_path.size() + << " instructions\n"; + + std::size_t n_loops=0, loop_ins=0; + forall_goto_functions(gf_it, goto_functions) + forall_goto_program_instructions(i_it, gf_it->second.body) + // loops or recursion + if(i_it->is_backwards_goto() || + i_it==gf_it->second.body.instructions.begin()) + { + const cfgt::entryt &node=cfg.entry_map[i_it]; + cfgt::patht loop; + cfg.shortest_loop(node, loop); + + if(!loop.empty()) + { + ++n_loops; + loop_ins+=loop.size()-1; + } + } + + if(n_loops>0) + std::cout << "Loop information: " << n_loops << " loops, " + << loop_ins << " instructions in shortest paths of loop bodies\n"; + + std::size_t n_reachable=0; + cfg.visit_reachable(start_node); + for(std::size_t i=0; ifirst==ID__start || + if(f_it->first==goto_functions.entry_point() || f_it->first=="__CPROVER_initialize") continue; diff --git a/src/goto-instrument/full_slicer.cpp b/src/goto-instrument/full_slicer.cpp index f7b42a0af3c..887805ad80a 100644 --- a/src/goto-instrument/full_slicer.cpp +++ b/src/goto-instrument/full_slicer.cpp @@ -13,9 +13,6 @@ Author: Daniel Kroening, kroening@kroening.com #include -#include - -#include "full_slicer.h" #include "full_slicer_class.h" /*******************************************************************\ diff --git a/src/goto-instrument/full_slicer_class.h b/src/goto-instrument/full_slicer_class.h index 4495fa95246..93894513f57 100644 --- a/src/goto-instrument/full_slicer_class.h +++ b/src/goto-instrument/full_slicer_class.h @@ -16,7 +16,9 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include + +#include "full_slicer.h" // #define DEBUG_FULL_SLICERT #if 0 @@ -30,8 +32,6 @@ echo 'digraph g {' > c.dot ; cat c.goto | \ dot -Tpdf -oc-red.pdf c-red.dot #endif -class dependence_grapht; - /*******************************************************************\ Class: full_slicert diff --git a/src/goto-instrument/goto_instrument_parse_options.cpp b/src/goto-instrument/goto_instrument_parse_options.cpp index 21000a78da6..66421b2e1e1 100644 --- a/src/goto-instrument/goto_instrument_parse_options.cpp +++ b/src/goto-instrument/goto_instrument_parse_options.cpp @@ -89,6 +89,7 @@ Author: Daniel Kroening, kroening@kroening.com #include "code_contracts.h" #include "unwind.h" #include "model_argc_argv.h" +#include "undefined_functions.h" /*******************************************************************\ @@ -456,6 +457,17 @@ int goto_instrument_parse_optionst::doit() return 0; } + if(cmdline.isset("list-calls-args")) + { + do_indirect_call_and_rtti_removal(); + do_partial_inlining(); + + namespacet ns(symbol_table); + list_calls_and_arguments(ns, goto_functions); + + return 0; + } + if(cmdline.isset("show-rw-set")) { namespacet ns(symbol_table); @@ -547,6 +559,12 @@ int goto_instrument_parse_optionst::doit() return 0; } + if(cmdline.isset("print-path-lengths")) + { + print_path_lengths(goto_functions); + return 0; + } + if(cmdline.isset("list-symbols")) { show_symbol_table(true); @@ -611,11 +629,7 @@ int goto_instrument_parse_optionst::doit() if(cmdline.isset("list-undefined-functions")) { const namespacet ns(symbol_table); - - Forall_goto_functions(it, goto_functions) - if(!ns.lookup(it->first).is_macro && - !it->second.body_available()) - std::cout << it->first << std::endl; + list_undefined_functions(goto_functions, ns, std::cout); return 0; } @@ -752,6 +766,13 @@ int goto_instrument_parse_optionst::doit() remove_unused_functions(goto_functions, get_message_handler()); } + if(cmdline.isset("undefined-function-is-assume-false")) + { + do_indirect_call_and_rtti_removal(); + + undefined_function_abort_path(goto_functions); + } + // write new binary? if(cmdline.args.size()==2) { @@ -814,6 +835,7 @@ void goto_instrument_parse_optionst::do_indirect_call_and_rtti_removal( status() << "Function Pointer Removal" << eom; remove_function_pointers( + get_message_handler(), symbol_table, goto_functions, cmdline.isset("pointer-check")); @@ -827,6 +849,39 @@ void goto_instrument_parse_optionst::do_indirect_call_and_rtti_removal( /*******************************************************************\ +Function: goto_instrument_parse_optionst::do_remove_const_function_pointers_only + + Inputs: + + Outputs: + + Purpose: Remove function pointers that can be resolved by analysing + const variables (i.e. can be resolved using + remove_const_function_pointers). Function pointers that cannot + be resolved will be left as function pointers. + +\*******************************************************************/ + +void goto_instrument_parse_optionst::do_remove_const_function_pointers_only() +{ + // Don't bother if we've already done a full function pointer + // removal. + if(function_pointer_removal_done) + { + return; + } + + status() << "Removing const function pointers only" << eom; + remove_function_pointers( + get_message_handler(), + symbol_table, + goto_functions, + cmdline.isset("pointer-check"), + true); // abort if we can't resolve via const pointers +} + +/*******************************************************************\ + Function: goto_instrument_parse_optionst::do_partial_inlining Inputs: @@ -1053,7 +1108,13 @@ void goto_instrument_parse_optionst::instrument_goto_program() // replace function pointers, if explicitly requested if(cmdline.isset("remove-function-pointers")) + { do_indirect_call_and_rtti_removal(); + } + else if(cmdline.isset("remove-const-function-pointers")) + { + do_remove_const_function_pointers_only(); + } if(cmdline.isset("function-inline")) { @@ -1441,7 +1502,10 @@ void goto_instrument_parse_optionst::instrument_goto_program() if(cmdline.isset("reachability-slice")) { status() << "Performing a reachability slice" << eom; - reachability_slicer(goto_functions); + if(cmdline.isset("property")) + reachability_slicer(goto_functions, cmdline.get_values("property")); + else + reachability_slicer(goto_functions); } // full slice? @@ -1508,6 +1572,8 @@ void goto_instrument_parse_optionst::help() " --list-undefined-functions list functions without body\n" " --show-struct-alignment show struct members that might be concurrently accessed\n" // NOLINT(*) " --show-natural-loops show natural loop heads\n" + // NOLINTNEXTLINE(whitespace/line_length) + " --list-calls-args list all function calls with their arguments\n" "\n" "Safety checks:\n" " --no-assertions ignore user assertions\n" @@ -1530,6 +1596,8 @@ void goto_instrument_parse_optionst::help() " --nondet-static add nondeterministic initialization of variables with static lifetime\n" // NOLINT(*) " --check-invariant function instruments invariant checking function\n" " --remove-pointers converts pointer arithmetic to base+offset expressions\n" // NOLINT(*) + " --undefined-function-is-assume-false\n" + " convert each call to an undefined function to assume(false)\n" "\n" "Loop transformations:\n" " --k-induction check loops with k-induction\n" @@ -1566,6 +1634,7 @@ void goto_instrument_parse_optionst::help() " --no-caching disable caching of intermediate results during transitive function inlining\n" // NOLINT(*) " --log log in json format which code segments were inlined, use with --function-inline\n" // NOLINT(*) " --remove-function-pointers replace function pointers by case statement over function calls\n" // NOLINT(*) + HELP_REMOVE_CONST_FUNCTION_POINTERS " --add-library add models of C library functions\n" " --model-argc-argv model up to command line arguments\n" "\n" diff --git a/src/goto-instrument/goto_instrument_parse_options.h b/src/goto-instrument/goto_instrument_parse_options.h index 180eeb7a2f5..788bf543953 100644 --- a/src/goto-instrument/goto_instrument_parse_options.h +++ b/src/goto-instrument/goto_instrument_parse_options.h @@ -15,6 +15,7 @@ Author: Daniel Kroening, kroening@kroening.com #include #include #include +#include #include @@ -55,6 +56,7 @@ Author: Daniel Kroening, kroening@kroening.com "(show-uninitialized)(show-locations)" \ "(full-slice)(reachability-slice)(slice-global-inits)" \ "(inline)(partial-inline)(function-inline):(log):(no-caching)" \ + OPT_REMOVE_CONST_FUNCTION_POINTERS \ "(remove-function-pointers)" \ "(show-claims)(show-properties)(property):" \ "(show-symbol-table)(show-points-to)(show-rw-set)" \ @@ -69,7 +71,8 @@ Author: Daniel Kroening, kroening@kroening.com "(list-symbols)(list-undefined-functions)" \ "(z3)(add-library)(show-dependence-graph)" \ "(horn)(skip-loops):(apply-code-contracts)(model-argc-argv):" \ - "(show-threaded)" + "(show-threaded)(list-calls-args)(print-path-lengths)" \ + "(undefined-function-is-assume-false)" class goto_instrument_parse_optionst: public parse_options_baset, @@ -99,6 +102,7 @@ class goto_instrument_parse_optionst: void eval_verbosity(); void do_indirect_call_and_rtti_removal(bool force=false); + void do_remove_const_function_pointers_only(); void do_partial_inlining(); void do_remove_returns(); diff --git a/src/goto-instrument/reachability_slicer.cpp b/src/goto-instrument/reachability_slicer.cpp index 231ae40cde9..073f9284add 100644 --- a/src/goto-instrument/reachability_slicer.cpp +++ b/src/goto-instrument/reachability_slicer.cpp @@ -13,6 +13,7 @@ Author: Daniel Kroening, kroening@kroening.com #include #include +#include "full_slicer_class.h" #include "reachability_slicer.h" #include "reachability_slicer_class.h" @@ -29,7 +30,8 @@ Function: reachability_slicert::fixedpoint_assertions \*******************************************************************/ void reachability_slicert::fixedpoint_assertions( - const is_threadedt &is_threaded) + const is_threadedt &is_threaded, + slicing_criteriont &criterion) { queuet queue; @@ -37,7 +39,7 @@ void reachability_slicert::fixedpoint_assertions( e_it=cfg.entry_map.begin(); e_it!=cfg.entry_map.end(); e_it++) - if(e_it->first->is_assert() || + if(criterion(e_it->first) || is_threaded(e_it->first)) queue.push(e_it->second); @@ -77,7 +79,7 @@ Function: reachability_slicert::slice void reachability_slicert::slice(goto_functionst &goto_functions) { // now replace those instructions that do not reach any assertions - // by self-loops + // by assume(false) Forall_goto_functions(f_it, goto_functions) if(f_it->second.body_available()) @@ -87,7 +89,7 @@ void reachability_slicert::slice(goto_functionst &goto_functions) const cfgt::nodet &e=cfg[cfg.entry_map[i_it]]; if(!e.reaches_assertion && !i_it->is_end_function()) - i_it->make_goto(i_it); + i_it->make_assumption(false_exprt()); } // replace unreachable code by skip @@ -113,5 +115,28 @@ Function: reachability_slicer void reachability_slicer(goto_functionst &goto_functions) { - reachability_slicert()(goto_functions); + reachability_slicert s; + assert_criteriont a; + s(goto_functions, a); +} + +/*******************************************************************\ + +Function: reachability_slicer + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +void reachability_slicer( + goto_functionst &goto_functions, + const std::list &properties) +{ + reachability_slicert s; + properties_criteriont p(properties); + s(goto_functions, p); } diff --git a/src/goto-instrument/reachability_slicer.h b/src/goto-instrument/reachability_slicer.h index 7ce03a1d612..e45aa81f27e 100644 --- a/src/goto-instrument/reachability_slicer.h +++ b/src/goto-instrument/reachability_slicer.h @@ -13,4 +13,8 @@ Author: Daniel Kroening, kroening@kroening.com void reachability_slicer(goto_functionst &goto_functions); +void reachability_slicer( + goto_functionst &goto_functions, + const std::list &properties); + #endif // CPROVER_GOTO_INSTRUMENT_REACHABILITY_SLICER_H diff --git a/src/goto-instrument/reachability_slicer_class.h b/src/goto-instrument/reachability_slicer_class.h index 85f1e62a345..224259b57cd 100644 --- a/src/goto-instrument/reachability_slicer_class.h +++ b/src/goto-instrument/reachability_slicer_class.h @@ -14,6 +14,8 @@ Author: Daniel Kroening, kroening@kroening.com #include +class slicing_criteriont; + /*******************************************************************\ Class: reachability_slicert @@ -25,11 +27,13 @@ Author: Daniel Kroening, kroening@kroening.com class reachability_slicert { public: - void operator()(goto_functionst &goto_functions) + void operator()( + goto_functionst &goto_functions, + slicing_criteriont &criterion) { cfg(goto_functions); is_threadedt is_threaded(goto_functions); - fixedpoint_assertions(is_threaded); + fixedpoint_assertions(is_threaded, criterion); slice(goto_functions); } @@ -48,7 +52,9 @@ class reachability_slicert typedef std::stack queuet; - void fixedpoint_assertions(const is_threadedt &is_threaded); + void fixedpoint_assertions( + const is_threadedt &is_threaded, + slicing_criteriont &criterion); void slice(goto_functionst &goto_functions); }; diff --git a/src/goto-instrument/undefined_functions.cpp b/src/goto-instrument/undefined_functions.cpp new file mode 100644 index 00000000000..53fff3ff84b --- /dev/null +++ b/src/goto-instrument/undefined_functions.cpp @@ -0,0 +1,81 @@ +/*******************************************************************\ + +Module: Handling of functions without body + +Author: Michael Tautschnig + +Date: July 2016 + +\*******************************************************************/ + +#include + +#include + +#include "undefined_functions.h" + +/*******************************************************************\ + +Function: list_undefined_functions + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +void list_undefined_functions( + const goto_functionst &goto_functions, + const namespacet &ns, + std::ostream &os) +{ + forall_goto_functions(it, goto_functions) + if(!ns.lookup(it->first).is_macro && + !it->second.body_available()) + os << it->first << std::endl; +} + +/*******************************************************************\ + +Function: undefined_function_abort_path + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +void undefined_function_abort_path(goto_functionst &goto_functions) +{ + Forall_goto_functions(it, goto_functions) + Forall_goto_program_instructions(iit, it->second.body) + { + goto_programt::instructiont &ins=*iit; + + if(!ins.is_function_call()) + continue; + + const code_function_callt &call=to_code_function_call(ins.code); + + if(call.function().id()!=ID_symbol) + continue; + + const irep_idt &function= + to_symbol_expr(call.function()).get_identifier(); + + goto_functionst::function_mapt::const_iterator entry= + goto_functions.function_map.find(function); + assert(entry!=goto_functions.function_map.end()); + + if(entry->second.body_available()) + continue; + + ins.make_assumption(false_exprt()); + ins.source_location.set_comment( + "`"+id2string(function)+"' is undefined"); + } +} diff --git a/src/goto-instrument/undefined_functions.h b/src/goto-instrument/undefined_functions.h new file mode 100644 index 00000000000..7b700c839a0 --- /dev/null +++ b/src/goto-instrument/undefined_functions.h @@ -0,0 +1,25 @@ +/*******************************************************************\ + +Module: Handling of functions without body + +Author: Michael Tautschnig + +Date: July 2016 + +\*******************************************************************/ + +#ifndef CPROVER_UNDEFINED_FUNCTIONS_H +#define CPROVER_UNDEFINED_FUNCTIONS_H + +#include + +class goto_functionst; + +void list_undefined_functions( + const goto_functionst &goto_functions, + const namespacet &ns, + std::ostream &os); + +void undefined_function_abort_path(goto_functionst &goto_functions); + +#endif diff --git a/src/goto-programs/Makefile b/src/goto-programs/Makefile index d5cc5ea25eb..bf6abb39ab6 100644 --- a/src/goto-programs/Makefile +++ b/src/goto-programs/Makefile @@ -20,7 +20,9 @@ SRC = goto_convert.cpp goto_convert_function_call.cpp \ slice_global_inits.cpp goto_inline_class.cpp class_identifier.cpp \ show_goto_functions_json.cpp \ show_goto_functions_xml.cpp \ - remove_static_init_loops.cpp remove_instanceof.cpp + remove_static_init_loops.cpp remove_instanceof.cpp \ + remove_const_function_pointers.cpp \ + # Empty last line INCLUDES= -I .. diff --git a/src/goto-programs/builtin_functions.cpp b/src/goto-programs/builtin_functions.cpp index 8fdcd28ae07..0cef3e382b4 100644 --- a/src/goto-programs/builtin_functions.cpp +++ b/src/goto-programs/builtin_functions.cpp @@ -580,7 +580,7 @@ void goto_convertt::do_cpp_new( if(new_array) new_call.arguments().push_back(count); new_call.arguments().push_back(object_size); - new_call.set("#type", lhs.type().subtype()); + new_call.set(ID_C_cxx_alloc_type, lhs.type().subtype()); new_call.lhs()=tmp_symbol_expr; new_call.add_source_location()=rhs.source_location(); @@ -612,7 +612,7 @@ void goto_convertt::do_cpp_new( new_call.arguments().push_back(count); new_call.arguments().push_back(object_size); new_call.arguments().push_back(rhs.op0()); // memory location - new_call.set("#type", lhs.type().subtype()); + new_call.set(ID_C_cxx_alloc_type, lhs.type().subtype()); new_call.lhs()=tmp_symbol_expr; new_call.add_source_location()=rhs.source_location(); @@ -1245,6 +1245,13 @@ void goto_convertt::do_function_call_symbol( error() << identifier << " expected not to have LHS" << eom; throw 0; } + + // __VERIFIER_error has abort() semantics, even if no assertions + // are being checked + goto_programt::targett a=dest.add_instruction(ASSUME); + a->guard=false_exprt(); + a->source_location=function.source_location(); + a->source_location.set("user-provided", true); } else if(has_prefix( id2string(identifier), "java::java.lang.AssertionError.:")) diff --git a/src/goto-programs/goto_functions_template.h b/src/goto-programs/goto_functions_template.h index 27757df4e87..7c427b4f72f 100644 --- a/src/goto-programs/goto_functions_template.h +++ b/src/goto-programs/goto_functions_template.h @@ -16,6 +16,7 @@ Date: June 2003 #include #include +#include template class goto_function_templatet @@ -123,7 +124,7 @@ class goto_functions_templatet static inline irep_idt entry_point() { // do not confuse with C's "int main()" - return ID__start; + return CPROVER_PREFIX "_start"; } void swap(goto_functions_templatet &other) diff --git a/src/goto-programs/graphml_witness.cpp b/src/goto-programs/graphml_witness.cpp index 8b0bd6dc46c..85bd1eec40f 100644 --- a/src/goto-programs/graphml_witness.cpp +++ b/src/goto-programs/graphml_witness.cpp @@ -146,8 +146,11 @@ std::string graphml_witnesst::convert_assign_rec( exprt clean_rhs=assign.rhs(); remove_l0_l1(clean_rhs); - result=from_expr(ns, identifier, assign.lhs())+" = "+ - from_expr(ns, identifier, clean_rhs)+";"; + std::string lhs=from_expr(ns, identifier, assign.lhs()); + if(lhs.find('$')!=std::string::npos) + lhs="\\result"; + + result=lhs+" = "+from_expr(ns, identifier, clean_rhs)+";"; } return result; @@ -155,6 +158,53 @@ std::string graphml_witnesst::convert_assign_rec( /*******************************************************************\ +Function: filter_out + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +static bool filter_out( + const goto_tracet &goto_trace, + const goto_tracet::stepst::const_iterator &prev_it, + goto_tracet::stepst::const_iterator &it) +{ + if(it->hidden && + (!it->is_assignment() || + to_code_assign(it->pc->code).rhs().id()!=ID_side_effect || + to_code_assign(it->pc->code).rhs().get(ID_statement)!=ID_nondet)) + return true; + + if(!it->is_assignment() && !it->is_goto() && !it->is_assert()) + return true; + + // we filter out steps with the same source location + // TODO: if these are assignments we should accumulate them into + // a single edge + if(prev_it!=goto_trace.steps.end() && + prev_it->pc->source_location==it->pc->source_location) + return true; + + if(it->is_goto() && it->pc->guard.is_true()) + return true; + + const source_locationt &source_location=it->pc->source_location; + + if(source_location.is_nil() || + source_location.get_file().empty() || + source_location.is_built_in() || + source_location.get_line().empty()) + return true; + + return false; +} + +/*******************************************************************\ + Function: graphml_witnesst::operator() Inputs: @@ -184,20 +234,7 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace) it!=goto_trace.steps.end(); it++) // we cannot replace this by a ranged for { - const source_locationt &source_location=it->pc->source_location; - - if(it->hidden || - (!it->is_assignment() && !it->is_goto() && !it->is_assert()) || - // we filter out steps with the same source location - // TODO: if these are assignments we should accumulate them into - // a single edge - (prev_it!=goto_trace.steps.end() && - prev_it->pc->source_location==it->pc->source_location) || - (it->is_goto() && it->pc->guard.is_true()) || - source_location.is_nil() || - source_location.get_file().empty() || - source_location.is_built_in() || - source_location.get_line().empty()) + if(filter_out(goto_trace, prev_it, it)) { step_to_node[it->step_nr]=sink; @@ -219,6 +256,8 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace) prev_it=it; + const source_locationt &source_location=it->pc->source_location; + const graphmlt::node_indext node=graphml.add_node(); graphml[node].node_name= std::to_string(it->pc->location_number)+"."+std::to_string(it->step_nr); @@ -278,21 +317,25 @@ void graphml_witnesst::operator()(const goto_tracet &goto_trace) data_l.data=id2string(graphml[from].line); } - if((it->type==goto_trace_stept::ASSIGNMENT || - it->type==goto_trace_stept::DECL) && + if(it->type==goto_trace_stept::ASSIGNMENT && it->lhs_object_value.is_not_nil() && it->full_lhs.is_not_nil()) { - irep_idt identifier=it->lhs_object.get_identifier(); - - xmlt &val=edge.new_element("data"); - val.set_attribute("key", "assumption"); - code_assignt assign(it->lhs_object, it->lhs_object_value); - val.data=convert_assign_rec(identifier, assign); - - xmlt &val_s=edge.new_element("data"); - val_s.set_attribute("key", "assumption.scope"); - val_s.data=id2string(it->pc->source_location.get_function()); + if(!it->lhs_object_value.is_constant() || + !it->lhs_object_value.has_operands() || + !has_prefix(id2string(it->lhs_object_value.op0().get(ID_value)), + "INVALID-")) + { + xmlt &val=edge.new_element("data"); + val.set_attribute("key", "assumption"); + code_assignt assign(it->lhs_object, it->lhs_object_value); + irep_idt identifier=it->lhs_object.get_identifier(); + val.data=convert_assign_rec(identifier, assign); + + xmlt &val_s=edge.new_element("data"); + val_s.set_attribute("key", "assumption.scope"); + val_s.data=id2string(it->pc->source_location.get_function()); + } } else if(it->type==goto_trace_stept::GOTO && it->pc->is_goto()) diff --git a/src/goto-programs/remove_const_function_pointers.cpp b/src/goto-programs/remove_const_function_pointers.cpp new file mode 100644 index 00000000000..c0a7d8d5380 --- /dev/null +++ b/src/goto-programs/remove_const_function_pointers.cpp @@ -0,0 +1,1007 @@ +/*******************************************************************\ + +Module: Goto Programs + +Author: Thomas Kiley, thomas.kiley@diffblue.com + +\*******************************************************************/ + +#include +#include +#include + +#include "remove_const_function_pointers.h" + +#define LOG(message, irep) \ + debug() << "Case " << __LINE__ << " : " << message << "\n" \ + << irep.pretty() << eom; + +/*******************************************************************\ + +Function: remove_const_function_pointerst::remove_const_function_pointerst + + Inputs: + message_handler - The message handler for messaget + base_expression - The function call through a function pointer + ns - The namespace to use to resolve types + symbol_table - The symbol table to look up symbols in + + Outputs: + + Purpose: To take a function call on a function pointer, and if possible + resolve it to a small collection of possible values. + +\*******************************************************************/ + +remove_const_function_pointerst::remove_const_function_pointerst( + message_handlert &message_handler, + const exprt &base_expression, + const namespacet &ns, + const symbol_tablet &symbol_table): + messaget(message_handler), + original_expression(base_expression), + ns(ns), + symbol_table(symbol_table) +{} + +/*******************************************************************\ + +Function: remove_const_function_pointerst::operator() + + Inputs: + out_functions - The functions that (symbols of type ID_code) the base + expression could take. + + Outputs: Returns true if it was able to resolve the call, false if not. + If it returns true, out_functions will be populated by all the + possible values the function pointer could be. + + Purpose: To take a function call on a function pointer, and if possible + resolve it to a small collection of possible values. It will + resolve function pointers that are const and: + - assigned directly to a function + - assigned to a value in an array of functions + - assigned to a const struct component + Or variations within. + +\*******************************************************************/ + +bool remove_const_function_pointerst::operator()( + functionst &out_functions) +{ + // Replace all const symbols with their values + exprt non_symbol_expression=replace_const_symbols(original_expression); + return try_resolve_function_call(non_symbol_expression, out_functions); +} + +/*******************************************************************\ + +Function: remove_const_function_pointerst::replace_const_symbols + + Inputs: + expression - The expression to resolve symbols in + + Outputs: Returns a modified version of the expression, with all + const symbols resolved to their actual values. + + Purpose: To collapse the symbols down to their values where possible + This takes a very general approach, recreating the expr tree + exactly as it was and ignoring what type of expressions are found + and instead recurses over all the operands. + +\*******************************************************************/ + +exprt remove_const_function_pointerst::replace_const_symbols( + const exprt &expression) const +{ + if(expression.id()==ID_symbol) + { + if(is_const_expression(expression)) + { + const symbolt &symbol= + symbol_table.lookup(expression.get(ID_identifier)); + if(symbol.type.id()!=ID_code) + { + const exprt &symbol_value=symbol.value; + return replace_const_symbols(symbol_value); + } + else + { + return expression; + } + } + else + { + return expression; + } + } + else + { + exprt const_symbol_cleared_expr=expression; + const_symbol_cleared_expr.operands().clear(); + for(const exprt &op : expression.operands()) + { + exprt const_symbol_cleared_op=replace_const_symbols(op); + const_symbol_cleared_expr.operands().push_back(const_symbol_cleared_op); + } + + return const_symbol_cleared_expr; + } +} + +/*******************************************************************\ + +Function: remove_const_function_pointerst::resolve_symbol + + Inputs: + symbol_expr - The symbol expression + + Outputs: The expression value of the symbol. + + Purpose: Look up a symbol in the symbol table and return its value + +\*******************************************************************/ + +exprt remove_const_function_pointerst::resolve_symbol( + const symbol_exprt &symbol_expr) const +{ + const symbolt &symbol= + symbol_table.lookup(symbol_expr.get_identifier()); + return symbol.value; +} + +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_function_call + + Inputs: + expr - The expression to get the possible function calls + out_functions - The functions this expression could be resolved to + + Outputs: Returns true if it was able to resolve the expression to some + specific functions. If this is the case, out_functions will contain + the possible functions. + + Purpose: To resolve an expression to the specific function calls it can + be. This is different to try_resolve_expression which isn't + explicitly looking for functions and is instead just trying + to squash particular exprt structures. + +\*******************************************************************/ + +bool remove_const_function_pointerst::try_resolve_function_call( + const exprt &expr, functionst &out_functions) +{ + assert(out_functions.empty()); + const exprt &simplified_expr=simplify_expr(expr, ns); + bool resolved=false; + functionst resolved_functions; + if(simplified_expr.id()==ID_index) + { + const index_exprt &index_expr=to_index_expr(simplified_expr); + resolved=try_resolve_index_of_function_call(index_expr, resolved_functions); + } + else if(simplified_expr.id()==ID_member) + { + const member_exprt &member_expr=to_member_expr(simplified_expr); + resolved=try_resolve_member_function_call(member_expr, resolved_functions); + } + else if(simplified_expr.id()==ID_address_of) + { + address_of_exprt address_expr=to_address_of_expr(simplified_expr); + resolved=try_resolve_address_of_function_call( + address_expr, resolved_functions); + } + else if(simplified_expr.id()==ID_dereference) + { + const dereference_exprt &deref=to_dereference_expr(simplified_expr); + resolved=try_resolve_dereference_function_call(deref, resolved_functions); + } + else if(simplified_expr.id()==ID_typecast) + { + typecast_exprt typecast_expr=to_typecast_expr(simplified_expr); + resolved= + try_resolve_typecast_function_call(typecast_expr, resolved_functions); + } + else if(simplified_expr.id()==ID_symbol) + { + if(simplified_expr.type().id()==ID_code) + { + resolved_functions.insert(simplified_expr); + resolved=true; + } + else + { + LOG("Non const symbol wasn't squashed", simplified_expr); + resolved=false; + } + } + else + { + LOG("Unrecognised expression", simplified_expr); + resolved=false; + } + + if(resolved) + { + out_functions.insert(resolved_functions.begin(), resolved_functions.end()); + return true; + } + else + { + return false; + } +} + +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_function_calls + + Inputs: + exprs - The expressions to evaluate + out_functions - The functions these expressions resolve to + + Outputs: Returns true if able to resolve each of the expressions down + to one or more functions. + + Purpose: To resolve a collection of expressions to the specific function + calls they can be. Returns a collection if and only if all of + them can be resolved. + +\*******************************************************************/ + +bool remove_const_function_pointerst::try_resolve_function_calls( + const expressionst &exprs, functionst &out_functions) +{ + for(const exprt &value : exprs) + { + functionst potential_out_functions; + bool resolved_value= + try_resolve_function_call(value, potential_out_functions); + + if(resolved_value) + { + out_functions.insert( + potential_out_functions.begin(), + potential_out_functions.end()); + } + else + { + LOG("Could not resolve expression in array", value); + return false; + } + } + return true; +} + +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_index_of_function_call + + Inputs: + index_expr - The index expression to resolve to possible function calls + out_functions - The functions this expression could be + + Outputs: Returns true if it was able to resolve the index expression to some + specific functions. If this is the case, out_functions will contain + the possible functions. + + Purpose: To resolve an expression to the specific function calls it can + be. Specifically, this function deals with index expressions + where it squashes its array and squash its index + If we can get a precise number for the index, we + try_resolve_function_call on its value otherwise + try_resolve_function_call on each and return the union of them all + +\*******************************************************************/ + +bool remove_const_function_pointerst::try_resolve_index_of_function_call( + const index_exprt &index_expr, functionst &out_functions) +{ + expressionst potential_array_values; + bool array_const; + bool resolved= + try_resolve_index_of(index_expr, potential_array_values, array_const); + + if(!resolved) + { + LOG("Could not resolve array", index_expr); + return false; + } + + if(!array_const) + { + LOG("Array not const", index_expr); + return false; + } + + return try_resolve_function_calls(potential_array_values, out_functions); +} + +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_member_function_call + + Inputs: + member_expr - The member expression to resolve to possible function calls + out_functions - The functions this expression could be + + Outputs: Returns true if it was able to resolve the member expression to some + specific functions. If this is the case, out_functions will contain + the possible functions. + + Purpose: To resolve an expression to the specific function calls it can + be. Specifically, this function deals with member expressions + by using try_resolve_member and then recursing on its value. + +\*******************************************************************/ + +bool remove_const_function_pointerst::try_resolve_member_function_call( + const member_exprt &member_expr, functionst &out_functions) +{ + expressionst potential_component_values; + bool struct_const; + bool resolved= + try_resolve_member(member_expr, potential_component_values, struct_const); + + if(!resolved) + { + LOG("Could not resolve struct", member_expr); + return false; + } + + if(!struct_const) + { + LOG("Struct was not const so can't resolve values on it", member_expr); + return false; + } + + return try_resolve_function_calls(potential_component_values, out_functions); +} + +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_address_of_function_call + + Inputs: + address_expr - The address_of expression to resolve to possible function + calls + out_functions - The functions this expression could be + + Outputs: Returns true if it was able to resolve the address_of expression to + some specific functions. If this is the case, out_functions will + contain the possible functions. + + Purpose: To resolve an expression to the specific function calls it can + be. Specifically, this function deals with address_of expressions. + +\*******************************************************************/ + +bool remove_const_function_pointerst::try_resolve_address_of_function_call( + const address_of_exprt &address_expr, functionst &out_functions) +{ + bool resolved= + try_resolve_function_call(address_expr.object(), out_functions); + if(!resolved) + { + LOG("Failed to resolve address of", address_expr); + } + return resolved; +} + +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_dereference_function_call + + Inputs: + deref_expr - The dereference expression to resolve to possible function calls + out_functions - The functions this expression could be + + Outputs: Returns true if it was able to resolve the dereference expression to + some specific functions. If this is the case, out_functions will + contain the possible functions. + + Purpose: To resolve an expression to the specific function calls it can + be. Specifically, this function deals with dereference expressions + by using try_resolve_dereferebce and then recursing on its value. + +\*******************************************************************/ + +bool remove_const_function_pointerst::try_resolve_dereference_function_call( + const dereference_exprt &deref_expr, functionst &out_functions) +{ + expressionst potential_deref_values; + bool deref_const; + bool resolved= + try_resolve_dereference(deref_expr, potential_deref_values, deref_const); + + if(!resolved) + { + LOG("Failed to squash dereference", deref_expr); + return false; + } + + if(!deref_const) + { + LOG("Dereferenced value was not const so can't dereference", deref_expr); + return false; + } + + return try_resolve_function_calls(potential_deref_values, out_functions); +} + +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_typecast_function_call + + Inputs: + typecast_expr - The typecast expression to resolve to possible function calls + out_functions - The functions this expression could be + + Outputs: Returns true if it was able to resolve the typecast expression to + some specific functions. If this is the case, out_functions will + contain the possible functions. + + Purpose: To resolve an expression to the specific function calls it can + be. Specifically, this function deals with typecast expressions + by looking at the type cast values. + +\*******************************************************************/ + +bool remove_const_function_pointerst::try_resolve_typecast_function_call( + const typecast_exprt &typecast_expr, functionst &out_functions) +{ + // We simply ignore typecasts and assume they are valid + // I thought simplify_expr would deal with this, but for example + // a cast from a 32 bit width int to a 64bit width int it doesn't seem + // to allow + functionst typecast_values; + bool resolved= + try_resolve_function_call(typecast_expr.op(), typecast_values); + + if(resolved) + { + out_functions.insert(typecast_values.begin(), typecast_values.end()); + return true; + } + else + { + LOG("Failed to squash typecast", typecast_expr); + return false; + } +} + +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_expression + + Inputs: + expr - The expression to try and squash + out_resolved_expression - The squashed version of this expression + out_is_const - Is the squashed expression constant + + Outputs: Returns true providing the squashing went OK (note it + may not have squashed anything). The out_resolved_expression will in + this case be all the possible squashed versions of the supplied + expression. + The out_is_const will return whether the squashed value is suitably + const (e.g. if we squashed a struct access, was the struct const). + + Purpose: To squash various expr types to simplify the expression. + ID_index -> dig to find ID_array and get the values out of it + ID_member -> dig to find ID_struct and extract the component value + ID_dereference -> dig to find ID_address_of and extract the value + ID_typecast -> return the value + ID_symbol -> return false, const symbols are squashed first and + non const symbols cannot be squashed + Everything else -> unchanged + +\*******************************************************************/ + +bool remove_const_function_pointerst::try_resolve_expression( + const exprt &expr, expressionst &out_resolved_expression, bool &out_is_const) +{ + exprt simplified_expr=simplify_expr(expr, ns); + bool resolved; + expressionst resolved_expressions; + bool is_resolved_expression_const; + if(simplified_expr.id()==ID_index) + { + const index_exprt &index_expr=to_index_expr(simplified_expr); + resolved= + try_resolve_index_of( + index_expr, resolved_expressions, is_resolved_expression_const); + } + else if(simplified_expr.id()==ID_member) + { + const member_exprt &member_expr=to_member_expr(simplified_expr); + resolved=try_resolve_member( + member_expr, resolved_expressions, is_resolved_expression_const); + } + else if(simplified_expr.id()==ID_dereference) + { + const dereference_exprt &deref=to_dereference_expr(simplified_expr); + resolved= + try_resolve_dereference( + deref, resolved_expressions, is_resolved_expression_const); + } + else if(simplified_expr.id()==ID_typecast) + { + typecast_exprt typecast_expr=to_typecast_expr(simplified_expr); + resolved= + try_resolve_typecast( + typecast_expr, resolved_expressions, is_resolved_expression_const); + } + else if(simplified_expr.id()==ID_symbol) + { + LOG("Non const symbol will not be squashed", simplified_expr); + resolved=false; + } + else + { + resolved_expressions.push_back(simplified_expr); + is_resolved_expression_const=is_const_expression(simplified_expr); + resolved=true; + } + + if(resolved) + { + out_resolved_expression.insert( + out_resolved_expression.end(), + resolved_expressions.begin(), + resolved_expressions.end()); + out_is_const=is_resolved_expression_const; + return true; + } + else + { + return false; + } +} + +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_index_value + + Inputs: + expr - The expression of the index of the index expression (e.g. + index_exprt::index()) + out_array_index - The constant value the index takes + + Outputs: Returns true if was able to find a constant value for the index + expression. If true, then out_array_index will be the index within + the array that the function pointer is pointing to. + + Purpose: Given an index into an array, resolve, if possible, the index + that is being accessed. This deals with symbols and typecasts to + constant values. + +\*******************************************************************/ + +bool remove_const_function_pointerst::try_resolve_index_value( + const exprt &expr, mp_integer &out_array_index) +{ + expressionst index_value_expressions; + bool is_const=false; + bool resolved=try_resolve_expression(expr, index_value_expressions, is_const); + if(resolved) + { + if(index_value_expressions.size()==1 && + index_value_expressions.front().id()==ID_constant) + { + const constant_exprt &constant_expr= + to_constant_expr(index_value_expressions.front()); + mp_integer array_index; + bool errors=to_integer(constant_expr, array_index); + if(!errors) + { + out_array_index=array_index; + } + return !errors; + } + else + { + return false; + } + } + else + { + return false; + } +} + +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_index_of + + Inputs: + index_expr - The index expression to to resolve + out_expressions - The expressions this expression could be + out_is_const - Is the squashed expression constant + + Outputs: Returns true if it was able to squash the index expression + If this is the case, out_expressions will contain + the possible values this index_of could return + The out_is_const will return whether either the array itself + is const, or the values of the array are const. + + Purpose: To squash an index access by first finding the array it is accessing + Then if the index can be resolved, return the squashed value. If + the index can't be determined then squash each value in the array + and return them all. + +\*******************************************************************/ + +bool remove_const_function_pointerst::try_resolve_index_of( + const index_exprt &index_expr, + expressionst &out_expressions, + bool &out_is_const) +{ + // Get the array(s) it belongs to + expressionst potential_array_exprs; + bool array_const=false; + bool resolved_array= + try_resolve_expression( + index_expr.array(), + potential_array_exprs, + array_const); + + if(resolved_array) + { + bool all_possible_const=true; + for(const exprt &potential_array_expr : potential_array_exprs) + { + all_possible_const= + all_possible_const && + is_const_type(potential_array_expr.type().subtype()); + + if(potential_array_expr.id()==ID_array) + { + // Get the index if we can + mp_integer value; + if(try_resolve_index_value(index_expr.index(), value)) + { + expressionst array_out_functions; + const exprt &func_expr= + potential_array_expr.operands()[integer2size_t(value)]; + bool value_const=false; + bool resolved_value= + try_resolve_expression(func_expr, array_out_functions, value_const); + + if(resolved_value) + { + out_expressions.insert( + out_expressions.end(), + array_out_functions.begin(), + array_out_functions.end()); + } + else + { + LOG("Failed to resolve array value", func_expr); + return false; + } + } + else + { + // We don't know what index it is, + // but we know the value is from the array + for(const exprt &array_entry : potential_array_expr.operands()) + { + expressionst array_contents; + bool is_entry_const; + bool resolved_value= + try_resolve_expression( + array_entry, array_contents, is_entry_const); + + if(!resolved_value) + { + LOG("Failed to resolve array value", array_entry); + return false; + } + + for(const exprt &resolved_array_entry : array_contents) + { + if(!resolved_array_entry.is_zero()) + { + out_expressions.push_back(resolved_array_entry); + } + } + } + } + } + else + { + LOG( + "Squashing index of did not result in an array", + potential_array_expr); + return false; + } + } + + out_is_const=all_possible_const || array_const; + return true; + } + else + { + LOG("Failed to squash index of to array expression", index_expr); + return false; + } +} + +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_member + + Inputs: + member_expr - The member expression to resolve. + out_expressions - The expressions this component could be + out_is_const - Is the squashed expression constant + + Outputs: Returns true if it was able to squash the member expression + If this is the case, out_expressions will contain + the possible values this member could return + The out_is_const will return whether the struct + is const. + + Purpose: To squash an member access by first finding the struct it is accessing + Then return the squashed value of the relevant component. + +\*******************************************************************/ + +bool remove_const_function_pointerst::try_resolve_member( + const member_exprt &member_expr, + expressionst &out_expressions, + bool &out_is_const) +{ + expressionst potential_structs; + bool is_struct_const; + + // Get the struct it belongs to + bool resolved_struct= + try_resolve_expression( + member_expr.compound(), potential_structs, is_struct_const); + if(resolved_struct) + { + for(const exprt &potential_struct : potential_structs) + { + if(potential_struct.id()==ID_struct) + { + struct_exprt struct_expr=to_struct_expr(potential_struct); + const exprt &component_value= + get_component_value(struct_expr, member_expr); + expressionst resolved_expressions; + bool component_const=false; + bool resolved= + try_resolve_expression( + component_value, resolved_expressions, component_const); + if(resolved) + { + out_expressions.insert( + out_expressions.end(), + resolved_expressions.begin(), + resolved_expressions.end()); + } + else + { + LOG("Could not resolve component value", component_value); + return false; + } + } + else + { + LOG( + "Squashing member access did not resolve in a struct", + potential_struct); + return false; + } + } + out_is_const=is_struct_const; + return true; + } + else + { + LOG("Failed to squash struct access", member_expr); + return false; + } +} + +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_dereference + + Inputs: + deref_expr - The dereference expression to resolve. + out_expressions - The expressions this dereference could be + out_is_const - Is the squashed expression constant + + Outputs: Returns true if it was able to squash the dereference expression + If this is the case, out_expressions will contain + the possible values this dereference could return + The out_is_const will return whether the object that gets + dereferenced is constant. + + Purpose: To squash a dereference access by first finding the address_of + the dereference is dereferencing. + Then return the squashed value of the relevant component. + +\*******************************************************************/ + +bool remove_const_function_pointerst::try_resolve_dereference( + const dereference_exprt &deref_expr, + expressionst &out_expressions, + bool &out_is_const) +{ + // We had a pointer, we need to check both the pointer + // type can't be changed, and what it what pointing to + // can't be changed + expressionst pointer_values; + bool pointer_const; + bool resolved= + try_resolve_expression(deref_expr.pointer(), pointer_values, pointer_const); + if(resolved && pointer_const) + { + bool all_objects_const=true; + for(const exprt &pointer_val : pointer_values) + { + if(pointer_val.id()==ID_address_of) + { + address_of_exprt address_expr=to_address_of_expr(pointer_val); + bool object_const=false; + expressionst out_object_values; + bool resolved= + try_resolve_expression( + address_expr.object(), out_object_values, object_const); + + if(resolved) + { + out_expressions.insert( + out_expressions.end(), + out_object_values.begin(), + out_object_values.end()); + + all_objects_const&=object_const; + } + else + { + LOG("Failed to resolve value of a dereference", address_expr); + } + } + else + { + LOG( + "Squashing dereference did not result in an address", pointer_val); + return false; + } + } + out_is_const=all_objects_const; + return true; + } + else + { + if(!resolved) + { + LOG("Failed to resolve pointer of dereference", deref_expr); + } + else if(!pointer_const) + { + LOG("Pointer value not const so can't squash", deref_expr); + } + return false; + } +} + +/*******************************************************************\ + +Function: remove_const_function_pointerst::try_resolve_dereference + + Inputs: + typecast_expr - The typecast expression to resolve. + out_expressions - The expressions this typecast could be + out_is_const - Is the squashed expression constant + + Outputs: Returns true if it was able to squash the typecast expression + If this is the case, out_expressions will contain + the possible values after removing the typecast. + + Purpose: To squash a typecast access. + +\*******************************************************************/ + +bool remove_const_function_pointerst::try_resolve_typecast( + const typecast_exprt &typecast_expr, + expressionst &out_expressions, + bool &out_is_const) +{ + expressionst typecast_values; + bool typecast_const; + bool resolved= + try_resolve_expression( + typecast_expr.op(), typecast_values, typecast_const); + + if(resolved) + { + out_expressions.insert( + out_expressions.end(), + typecast_values.begin(), + typecast_values.end()); + out_is_const=typecast_const; + return true; + } + else + { + LOG("Could not resolve typecast value", typecast_expr); + return false; + } +} + +/*******************************************************************\ + +Function: remove_const_function_pointerst::is_expression_const + + Inputs: + expression - The expression to check + + Outputs: Returns true if the type of the expression is constant. + + Purpose: To evaluate the const-ness of the expression type. + +\*******************************************************************/ + +bool remove_const_function_pointerst::is_const_expression( + const exprt &expression) const +{ + return is_const_type(expression.type()); +} + +/*******************************************************************\ + +Function: remove_const_function_pointerst::is_type_const + + Inputs: + type - The type to check + + Outputs: Returns true if the type has ID_C_constant or is an array + since arrays are implicitly const in C. + + Purpose: To evaluate the const-ness of the type. + +\*******************************************************************/ + +bool remove_const_function_pointerst::is_const_type(const typet &type) const +{ + c_qualifierst qualifers(type); + if(type.id()==ID_array) + { + c_qualifierst array_type_qualifers(type.subtype()); + return qualifers.is_constant || array_type_qualifers.is_constant; + } + else + { + return qualifers.is_constant; + } +} + +/*******************************************************************\ + +Function: remove_const_function_pointerst::get_component_value + + Inputs: + struct_expr - The expression of the structure being accessed + member_expr - The expression saying which component is being accessed + + Outputs: Returns the value of a specific component for a given struct + expression. + + Purpose: To extract the value of the specific component within a struct + +\*******************************************************************/ + +exprt remove_const_function_pointerst::get_component_value( + const struct_exprt &struct_expr, const member_exprt &member_expr) +{ + const struct_typet &struct_type=to_struct_type(ns.follow(struct_expr.type())); + size_t component_number= + struct_type.component_number(member_expr.get_component_name()); + + return struct_expr.operands()[component_number]; +} diff --git a/src/goto-programs/remove_const_function_pointers.h b/src/goto-programs/remove_const_function_pointers.h new file mode 100644 index 00000000000..6516fb6ec64 --- /dev/null +++ b/src/goto-programs/remove_const_function_pointers.h @@ -0,0 +1,105 @@ +/*******************************************************************\ + +Module: Goto Programs + +Author: Thomas Kiley, thomas.kiley@diffblue.com + +\*******************************************************************/ + +#ifndef CPROVER_GOTO_PROGRAMS_REMOVE_CONST_FUNCTION_POINTERS_H +#define CPROVER_GOTO_PROGRAMS_REMOVE_CONST_FUNCTION_POINTERS_H + +#include + +#include "goto_model.h" +#include +#include +#include + + +class remove_const_function_pointerst:public messaget +{ +public: + typedef std::unordered_set functionst; + typedef std::list expressionst; + remove_const_function_pointerst( + message_handlert &message_handler, + const exprt &base_expression, + const namespacet &ns, + const symbol_tablet &symbol_table); + + bool operator()(functionst &out_functions); + +private: + exprt replace_const_symbols(const exprt &expression) const; + exprt resolve_symbol(const symbol_exprt &symbol_expr) const; + + // recursive functions for dealing with the function pointer + bool try_resolve_function_call(const exprt &expr, functionst &out_functions); + + bool try_resolve_function_calls( + const expressionst &exprs, functionst &out_functions); + + bool try_resolve_index_of_function_call( + const index_exprt &index_expr, functionst &out_functions); + + bool try_resolve_member_function_call( + const member_exprt &member_expr, functionst &out_functions); + + bool try_resolve_address_of_function_call( + const address_of_exprt &address_expr, functionst &out_functions); + + bool try_resolve_dereference_function_call( + const dereference_exprt &deref_expr, functionst &out_functions); + + bool try_resolve_typecast_function_call( + const typecast_exprt &typecast_expr, functionst &out_functions); + + // recursive functions for dealing with the auxiliary elements + bool try_resolve_expression( + const exprt &expr, + expressionst &out_resolved_expression, + bool &out_is_const); + + bool try_resolve_index_of( + const index_exprt &index_expr, + expressionst &out_expressions, + bool &out_is_const); + + bool try_resolve_member( + const member_exprt &member_expr, + expressionst &out_expressions, + bool &out_is_const); + + bool try_resolve_dereference( + const dereference_exprt &deref_expr, + expressionst &out_expressions, + bool &out_is_const); + + bool try_resolve_typecast( + const typecast_exprt &typecast_expr, + expressionst &out_expressions, + bool &out_is_const); + + bool is_const_expression(const exprt &expression) const; + bool is_const_type(const typet &type) const; + + bool try_resolve_index_value( + const exprt &index_value_expr, mp_integer &out_array_index); + + exprt get_component_value( + const struct_exprt &struct_expr, const member_exprt &member_expr); + + const exprt original_expression; + const namespacet &ns; + const symbol_tablet &symbol_table; +}; + +#define OPT_REMOVE_CONST_FUNCTION_POINTERS \ + "(remove-const-function-pointers)" + +#define HELP_REMOVE_CONST_FUNCTION_POINTERS \ + " --remove-const-function-pointers Remove function pointers that are constant or constant part of an array\n" // NOLINT(*) + + +#endif // CPROVER_GOTO_PROGRAMS_REMOVE_CONST_FUNCTION_POINTERS_H diff --git a/src/goto-programs/remove_function_pointers.cpp b/src/goto-programs/remove_function_pointers.cpp index 3893729a1e1..2d5be9c0ab2 100644 --- a/src/goto-programs/remove_function_pointers.cpp +++ b/src/goto-programs/remove_function_pointers.cpp @@ -14,12 +14,17 @@ Author: Daniel Kroening, kroening@kroening.com #include #include #include +#include +#include +#include +#include #include #include "remove_skip.h" #include "remove_function_pointers.h" #include "compute_called_functions.h" +#include "remove_const_function_pointers.h" /*******************************************************************\ @@ -29,12 +34,14 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ -class remove_function_pointerst +class remove_function_pointerst:public messaget { public: remove_function_pointerst( + message_handlert &_message_handler, symbol_tablet &_symbol_table, bool _add_safety_assertion, + bool only_resolve_const_fps, const goto_functionst &goto_functions); void operator()(goto_functionst &goto_functions); @@ -46,6 +53,14 @@ class remove_function_pointerst symbol_tablet &symbol_table; bool add_safety_assertion; + // We can optionally halt the FP removal if we aren't able to use + // remove_const_function_pointerst to sucessfully narrow to a small + // subset of possible functions and just leave the function pointer + // as it is. + // This can be activated in goto-instrument using + // --remove-const-function-pointers instead of --remove-function-pointers + bool only_resolve_const_fps; + void remove_function_pointer( goto_programt &goto_program, goto_programt::targett target); @@ -92,12 +107,15 @@ Function: remove_function_pointerst::remove_function_pointerst \*******************************************************************/ remove_function_pointerst::remove_function_pointerst( + message_handlert &_message_handler, symbol_tablet &_symbol_table, - bool _add_safety_assertion, + bool _add_safety_assertion, bool only_resolve_const_fps, const goto_functionst &goto_functions): + messaget(_message_handler), ns(_symbol_table), symbol_table(_symbol_table), - add_safety_assertion(_add_safety_assertion) + add_safety_assertion(_add_safety_assertion), + only_resolve_const_fps(only_resolve_const_fps) { compute_address_taken_in_symbols(address_taken); compute_address_taken_functions(goto_functions, address_taken); @@ -338,41 +356,71 @@ void remove_function_pointerst::remove_function_pointer( assert(function.id()==ID_dereference); assert(function.operands().size()==1); - const exprt &pointer=function.op0(); + bool found_functions; - // Is this simple? - if(pointer.id()==ID_address_of && - to_address_of_expr(pointer).object().id()==ID_symbol) + const exprt &pointer=function.op0(); + remove_const_function_pointerst::functionst functions; + does_remove_constt const_removal_check(goto_program, ns); + if(const_removal_check()) { - to_code_function_call(target->code).function()= - to_address_of_expr(pointer).object(); - return; + warning() << "Cast from const to non-const pointer found, only worst case" + << " function pointer removal will be done." << eom; + found_functions=false; } + else + { + remove_const_function_pointerst fpr( + get_message_handler(), pointer, ns, symbol_table); + + found_functions=fpr(functions); - typedef std::list functionst; - functionst functions; + // Either found_functions is true therefore the functions should not + // be empty + // Or found_functions is false therefore the functions should be empty + assert(found_functions != functions.empty()); - bool return_value_used=code.lhs().is_not_nil(); + if(functions.size()==1) + { + to_code_function_call(target->code).function()=*functions.cbegin(); + return; + } + } - // get all type-compatible functions - // whose address is ever taken - for(const auto &t : type_map) + if(!found_functions) { - // address taken? - if(address_taken.find(t.first)==address_taken.end()) - continue; + if(only_resolve_const_fps) + { + // If this mode is enabled, we only remove function pointers + // that we can resolve either to an exact funciton, or an exact subset + // (e.g. a variable index in a constant array). + // Since we haven't found functions, we would now resort to + // replacing the function pointer with any function with a valid signature + // Since we don't want to do that, we abort. + return; + } - // type-compatible? - if(!is_type_compatible(return_value_used, call_type, t.second)) - continue; + bool return_value_used=code.lhs().is_not_nil(); + + // get all type-compatible functions + // whose address is ever taken + for(const auto &t : type_map) + { + // address taken? + if(address_taken.find(t.first)==address_taken.end()) + continue; - if(t.first=="pthread_mutex_cleanup") - continue; + // type-compatible? + if(!is_type_compatible(return_value_used, call_type, t.second)) + continue; - symbol_exprt expr; - expr.type()=t.second; - expr.set_identifier(t.first); - functions.push_back(expr); + if(t.first=="pthread_mutex_cleanup") + continue; + + symbol_exprt expr; + expr.type()=t.second; + expr.set_identifier(t.first); + functions.insert(expr); + } } // the final target is a skip @@ -455,6 +503,11 @@ void remove_function_pointerst::remove_function_pointer( code_expression.expression()=function; target->code.swap(code_expression); target->type=OTHER; + + // report statistics + statistics().source_location=target->source_location; + statistics() << "replacing function pointer by " + << functions.size() << " possible targets" << eom; } /*******************************************************************\ @@ -539,14 +592,20 @@ Function: remove_function_pointers \*******************************************************************/ -bool remove_function_pointers( +bool remove_function_pointers(message_handlert &_message_handler, symbol_tablet &symbol_table, const goto_functionst &goto_functions, goto_programt &goto_program, - bool add_safety_assertion) + bool add_safety_assertion, + bool only_remove_const_fps) { remove_function_pointerst - rfp(symbol_table, add_safety_assertion, goto_functions); + rfp( + _message_handler, + symbol_table, + add_safety_assertion, + only_remove_const_fps, + goto_functions); return rfp.remove_function_pointers(goto_program); } @@ -564,12 +623,19 @@ Function: remove_function_pointers \*******************************************************************/ void remove_function_pointers( + message_handlert &_message_handler, symbol_tablet &symbol_table, goto_functionst &goto_functions, - bool add_safety_assertion) + bool add_safety_assertion, + bool only_remove_const_fps) { remove_function_pointerst - rfp(symbol_table, add_safety_assertion, goto_functions); + rfp( + _message_handler, + symbol_table, + add_safety_assertion, + only_remove_const_fps, + goto_functions); rfp(goto_functions); } @@ -586,11 +652,15 @@ Function: remove_function_pointers \*******************************************************************/ -void remove_function_pointers( +void remove_function_pointers(message_handlert &_message_handler, goto_modelt &goto_model, - bool add_safety_assertion) + bool add_safety_assertion, + bool only_remove_const_fps) { remove_function_pointers( - goto_model.symbol_table, goto_model.goto_functions, - add_safety_assertion); + _message_handler, + goto_model.symbol_table, + goto_model.goto_functions, + add_safety_assertion, + only_remove_const_fps); } diff --git a/src/goto-programs/remove_function_pointers.h b/src/goto-programs/remove_function_pointers.h index 6f1f26984df..e8eea37ea75 100644 --- a/src/goto-programs/remove_function_pointers.h +++ b/src/goto-programs/remove_function_pointers.h @@ -12,22 +12,29 @@ Date: June 2003 #define CPROVER_GOTO_PROGRAMS_REMOVE_FUNCTION_POINTERS_H #include "goto_model.h" +#include // remove indirect function calls // and replace by case-split void remove_function_pointers( + message_handlert &_message_handler, goto_modelt &goto_model, - bool add_safety_assertion); + bool add_safety_assertion, + bool only_remove_const_fps=false); void remove_function_pointers( + message_handlert &_message_handler, symbol_tablet &symbol_table, goto_functionst &goto_functions, - bool add_safety_assertion); + bool add_safety_assertion, + bool only_remove_const_fps=false); bool remove_function_pointers( + message_handlert &_message_handler, symbol_tablet &symbol_table, const goto_functionst &goto_functions, goto_programt &goto_program, - bool add_safety_assertion); + bool add_safety_assertion, + bool only_remove_const_fps=false); #endif // CPROVER_GOTO_PROGRAMS_REMOVE_FUNCTION_POINTERS_H diff --git a/src/goto-programs/remove_returns.cpp b/src/goto-programs/remove_returns.cpp index b3afbf967fc..9ca6554275c 100644 --- a/src/goto-programs/remove_returns.cpp +++ b/src/goto-programs/remove_returns.cpp @@ -269,6 +269,46 @@ void remove_returns(goto_modelt &goto_model) /*******************************************************************\ +Function: original_return_type + +Inputs: + +Outputs: + +Purpose: + +\*******************************************************************/ + +code_typet original_return_type( + const symbol_tablet &symbol_table, + const irep_idt &function_id) +{ + code_typet type; + type.make_nil(); + + // do we have X#return_value? + std::string rv_name=id2string(function_id)+RETURN_VALUE_SUFFIX; + + symbol_tablet::symbolst::const_iterator rv_it= + symbol_table.symbols.find(rv_name); + + if(rv_it!=symbol_table.symbols.end()) + { + // look up the function symbol + symbol_tablet::symbolst::const_iterator s_it= + symbol_table.symbols.find(function_id); + + assert(s_it!=symbol_table.symbols.end()); + + type=to_code_type(s_it->second.type); + type.return_type()=rv_it->second.type; + } + + return type; +} + +/*******************************************************************\ + Function: remove_returnst::restore_returns Inputs: @@ -301,7 +341,7 @@ bool remove_returnst::restore_returns( symbolt &function_symbol=s_it->second; // restore the return type - f_it->second.type.return_type()=rv_it->second.type; + f_it->second.type=original_return_type(symbol_table, function_id); function_symbol.type=f_it->second.type; // remove the return_value symbol from the symbol_table diff --git a/src/goto-programs/remove_returns.h b/src/goto-programs/remove_returns.h index 3f68d3e89e2..453d8a7be7f 100644 --- a/src/goto-programs/remove_returns.h +++ b/src/goto-programs/remove_returns.h @@ -26,4 +26,8 @@ void remove_returns(goto_modelt &); // reverse the above operations void restore_returns(symbol_tablet &, goto_functionst &); +code_typet original_return_type( + const symbol_tablet &symbol_table, + const irep_idt &function_id); + #endif // CPROVER_GOTO_PROGRAMS_REMOVE_RETURNS_H diff --git a/src/goto-programs/show_goto_functions_json.cpp b/src/goto-programs/show_goto_functions_json.cpp index 1f61e30d2f6..47a19e0662a 100644 --- a/src/goto-programs/show_goto_functions_json.cpp +++ b/src/goto-programs/show_goto_functions_json.cpp @@ -67,7 +67,7 @@ json_objectt show_goto_functions_jsont::convert( json_function["isBodyAvailable"]= jsont::json_boolean(function.body_available()); bool is_internal=(has_prefix(id2string(function_name), CPROVER_PREFIX) || - function_name==ID__start); + function_name==goto_functions.entry_point()); json_function["isInternal"]=jsont::json_boolean(is_internal); if(function.body_available()) diff --git a/src/goto-programs/show_goto_functions_xml.cpp b/src/goto-programs/show_goto_functions_xml.cpp index a5d1c9d5dd4..7ccdd71a4ff 100644 --- a/src/goto-programs/show_goto_functions_xml.cpp +++ b/src/goto-programs/show_goto_functions_xml.cpp @@ -80,7 +80,7 @@ xmlt show_goto_functions_xmlt::convert( xml_function.set_attribute_bool( "is_body_available", function.body_available()); bool is_internal=(has_prefix(id2string(function_name), CPROVER_PREFIX) || - function_name==ID__start); + function_name==goto_functions.entry_point()); xml_function.set_attribute_bool("is_internal", is_internal); if(function.body_available()) diff --git a/src/goto-symex/goto_symex.h b/src/goto-symex/goto_symex.h index de71fcc9d09..f8c2cda0bf9 100644 --- a/src/goto-symex/goto_symex.h +++ b/src/goto-symex/goto_symex.h @@ -175,6 +175,10 @@ class goto_symext // gotos void merge_gotos(statet &state); + virtual void merge_goto( + const statet::goto_statet &goto_state, + statet &state); + void merge_value_sets( const statet::goto_statet &goto_state, statet &dest); diff --git a/src/goto-symex/goto_symex_state.h b/src/goto-symex/goto_symex_state.h index 5439af37e05..292dec478c7 100644 --- a/src/goto-symex/goto_symex_state.h +++ b/src/goto-symex/goto_symex_state.h @@ -189,6 +189,7 @@ class goto_symex_statet level2t::current_namest level2_current_names; value_sett value_set; guardt guard; + symex_targett::sourcet source; propagationt propagation; unsigned atomic_section_id; @@ -197,6 +198,7 @@ class goto_symex_statet level2_current_names(s.level2.current_names), value_set(s.value_set), guard(s.guard), + source(s.source), propagation(s.propagation), atomic_section_id(s.atomic_section_id) { diff --git a/src/goto-symex/symex_goto.cpp b/src/goto-symex/symex_goto.cpp index b8e6f1a0a36..8b36cfc26af 100644 --- a/src/goto-symex/symex_goto.cpp +++ b/src/goto-symex/symex_goto.cpp @@ -69,6 +69,27 @@ void goto_symext::symex_goto(statet &state) if(!forward) // backwards? { + // is it label: goto label; or while(cond); - popular in SV-COMP + if(goto_target==state.source.pc || + (instruction.incoming_edges.size()==1 && + *instruction.incoming_edges.begin()==goto_target)) + { + // generate assume(false) or a suitable negation if this + // instruction is a conditional goto + exprt negated_cond; + + if(new_guard.is_true()) + negated_cond=false_exprt(); + else + negated_cond=not_exprt(new_guard); + + symex_assume(state, negated_cond); + + // next instruction + state.source.pc++; + return; + } + unsigned &unwind= frame.loop_iterations[goto_programt::loop_id(state.source.pc)].count; unwind++; @@ -121,8 +142,6 @@ void goto_symext::symex_goto(statet &state) state_pc=goto_target; } - state.source.pc=state_pc; - // put into state-queue statet::goto_state_listt &goto_state_list= state.top().goto_state_map[new_state_pc]; @@ -130,6 +149,8 @@ void goto_symext::symex_goto(statet &state) goto_state_list.push_back(statet::goto_statet(state)); statet::goto_statet &new_state=goto_state_list.back(); + state.source.pc=state_pc; + // adjust guards if(new_guard.is_true()) { @@ -244,27 +265,42 @@ void goto_symext::merge_gotos(statet &state) list_it=state_list.rbegin(); list_it!=state_list.rend(); list_it++) - { - statet::goto_statet &goto_state=*list_it; + merge_goto(*list_it, state); - // check atomic section - if(state.atomic_section_id!=goto_state.atomic_section_id) - throw "atomic sections differ across branches"; + // clean up to save some memory + frame.goto_state_map.erase(state_map_it); +} - // do SSA phi functions - phi_function(goto_state, state); +/*******************************************************************\ - merge_value_sets(goto_state, state); +Function: goto_symext::merge_goto - // adjust guard - state.guard|=goto_state.guard; + Inputs: - // adjust depth - state.depth=std::min(state.depth, goto_state.depth); - } + Outputs: - // clean up to save some memory - frame.goto_state_map.erase(state_map_it); + Purpose: + +\*******************************************************************/ + +void goto_symext::merge_goto( + const statet::goto_statet &goto_state, + statet &state) +{ + // check atomic section + if(state.atomic_section_id!=goto_state.atomic_section_id) + throw "atomic sections differ across branches"; + + // do SSA phi functions + phi_function(goto_state, state); + + merge_value_sets(goto_state, state); + + // adjust guard + state.guard|=goto_state.guard; + + // adjust depth + state.depth=std::min(state.depth, goto_state.depth); } /*******************************************************************\ diff --git a/src/java_bytecode/Makefile b/src/java_bytecode/Makefile index 20958a3ede3..d5d427747c2 100644 --- a/src/java_bytecode/Makefile +++ b/src/java_bytecode/Makefile @@ -6,7 +6,7 @@ SRC = java_bytecode_language.cpp java_bytecode_parse_tree.cpp \ java_root_class.cpp java_bytecode_parser.cpp bytecode_info.cpp \ java_class_loader.cpp jar_file.cpp java_object_factory.cpp \ java_bytecode_convert_method.cpp java_local_variable_table.cpp \ - java_pointer_casts.cpp java_utils.cpp + java_pointer_casts.cpp java_utils.cpp java_class_loader_limit.cpp INCLUDES= -I .. diff --git a/src/java_bytecode/jar_file.cpp b/src/java_bytecode/jar_file.cpp index 07d7719e500..ee08a50838a 100644 --- a/src/java_bytecode/jar_file.cpp +++ b/src/java_bytecode/jar_file.cpp @@ -12,7 +12,9 @@ Author: Daniel Kroening, kroening@kroening.com #include #include + #include "jar_file.h" + /*******************************************************************\ Function: jar_filet::open @@ -26,7 +28,7 @@ Function: jar_filet::open \*******************************************************************/ void jar_filet::open( - std::string &java_cp_include_files, + java_class_loader_limitt &class_loader_limit, const std::string &filename) { if(!mz_ok) @@ -38,34 +40,6 @@ void jar_filet::open( if(mz_ok) { - // '@' signals file reading with list of class files to load - bool regex_match=java_cp_include_files[0]!='@'; - std::regex regex_matcher; - std::smatch string_matcher; - std::unordered_set set_matcher; - jsont json_cp_config; - if(regex_match) - regex_matcher=std::regex(java_cp_include_files); - else - { - assert(java_cp_include_files.length()>1); - if(parse_json( - java_cp_include_files.substr(1), - get_message_handler(), - json_cp_config)) - throw "cannot read JSON input configuration for JAR loading"; - if(!json_cp_config.is_object()) - throw "the JSON file has a wrong format"; - jsont include_files=json_cp_config["classFiles"]; - if(!include_files.is_array()) - throw "the JSON file has a wrong format"; - for(const jsont &file_entry : include_files.array) - { - assert(file_entry.is_string()); - set_matcher.insert(file_entry.value); - } - } - std::size_t number_of_files= mz_zip_reader_get_num_files(&zip); @@ -80,12 +54,8 @@ void jar_filet::open( // non-class files are loaded in any case bool add_file=!has_suffix(file_name, ".class"); - // load .class file only if they match regex - if(regex_match) - add_file|=std::regex_match(file_name, string_matcher, regex_matcher); - // load .class file only if it is in the match set - else - add_file|=set_matcher.find(file_name)!=set_matcher.end(); + // load .class file only if they match regex / are in match set + add_file|=class_loader_limit.load_class_file(file_name); if(add_file) { if(has_suffix(file_name, ".class")) diff --git a/src/java_bytecode/jar_file.h b/src/java_bytecode/jar_file.h index 9407e711128..3ecdfc80d0f 100644 --- a/src/java_bytecode/jar_file.h +++ b/src/java_bytecode/jar_file.h @@ -18,6 +18,8 @@ Author: Daniel Kroening, kroening@kroening.com #include #include +#include "java_class_loader_limit.h" + class jar_filet:public messaget { public: @@ -25,7 +27,7 @@ class jar_filet:public messaget ~jar_filet(); - void open(std::string &java_cp_include_files, const std::string &); + void open(java_class_loader_limitt &, const std::string &); // Test for error; 'true' means we are good. explicit operator bool() const { return mz_ok; } @@ -47,21 +49,16 @@ class jar_filet:public messaget class jar_poolt:public messaget { public: - void set_java_cp_include_files(std::string &_java_cp_include_files) - { - java_cp_include_files=_java_cp_include_files; - } - - jar_filet &operator()(const std::string &file_name) + jar_filet &operator()( + java_class_loader_limitt &class_loader_limit, + const std::string &file_name) { - if(java_cp_include_files.empty()) - throw "class regexp cannot be empty"; file_mapt::iterator it=file_map.find(file_name); if(it==file_map.end()) { jar_filet &jar_file=file_map[file_name]; jar_file.set_message_handler(get_message_handler()); - jar_file.open(java_cp_include_files, file_name); + jar_file.open(class_loader_limit, file_name); return jar_file; } else diff --git a/src/java_bytecode/java_bytecode_language.cpp b/src/java_bytecode/java_bytecode_language.cpp index 277b117c715..120c3742eec 100644 --- a/src/java_bytecode/java_bytecode_language.cpp +++ b/src/java_bytecode/java_bytecode_language.cpp @@ -169,11 +169,14 @@ bool java_bytecode_languaget::parse( } else if(has_suffix(path, ".jar")) { + java_class_loader_limitt class_loader_limit( + get_message_handler(), + java_cp_include_files); if(config.java.main_class.empty()) { // Does it have a main class set in the manifest? jar_filet::manifestt manifest= - java_class_loader.jar_pool(path).get_manifest(); + java_class_loader.jar_pool(class_loader_limit, path).get_manifest(); std::string manifest_main_class=manifest["Main-Class"]; if(manifest_main_class!="") @@ -185,8 +188,8 @@ bool java_bytecode_languaget::parse( // Do we have one now? if(main_class.empty()) { - status() << "JAR file without entry point: loading it all" << eom; - java_class_loader.load_entire_jar(path); + status() << "JAR file without entry point: loading class files" << eom; + java_class_loader.load_entire_jar(class_loader_limit, path); for(const auto &kv : java_class_loader.jar_map.at(path).entries) main_jar_classes.push_back(kv.first); } diff --git a/src/java_bytecode/java_class_loader.cpp b/src/java_bytecode/java_class_loader.cpp index db5f63b08b9..fdd37c4b312 100644 --- a/src/java_bytecode/java_class_loader.cpp +++ b/src/java_bytecode/java_class_loader.cpp @@ -44,6 +44,9 @@ java_bytecode_parse_treet &java_class_loadert::operator()( queue.push("java.lang.Class"); queue.push(class_name); + java_class_loader_limitt class_loader_limit( + get_message_handler(), java_cp_include_files); + while(!queue.empty()) { irep_idt c=queue.top(); @@ -56,7 +59,7 @@ java_bytecode_parse_treet &java_class_loadert::operator()( debug() << "Reading class " << c << eom; java_bytecode_parse_treet &parse_tree= - get_parse_tree(c); + get_parse_tree(class_loader_limit, c); // add any dependencies to queue for(java_bytecode_parse_treet::class_refst::const_iterator @@ -71,6 +74,25 @@ java_bytecode_parse_treet &java_class_loadert::operator()( /*******************************************************************\ +Function: java_class_loadert::set_java_cp_include_files + + Inputs: + + Outputs: + + Purpose: + +\*******************************************************************/ + +void java_class_loadert::set_java_cp_include_files( + std::string &_java_cp_include_files) +{ + java_cp_include_files=_java_cp_include_files; + jar_pool.set_message_handler(get_message_handler()); +} + +/*******************************************************************\ + Function: java_class_loadert::get_parse_tree Inputs: @@ -82,6 +104,7 @@ Function: java_class_loadert::get_parse_tree \*******************************************************************/ java_bytecode_parse_treet &java_class_loadert::get_parse_tree( + java_class_loader_limitt &class_loader_limit, const irep_idt &class_name) { java_bytecode_parse_treet &parse_tree=class_map[class_name]; @@ -89,7 +112,7 @@ java_bytecode_parse_treet &java_class_loadert::get_parse_tree( // First check given JAR files for(const auto &jf : jar_files) { - read_jar_file(jf); + read_jar_file(class_loader_limit, jf); const auto &jm=jar_map[jf]; @@ -100,7 +123,8 @@ java_bytecode_parse_treet &java_class_loadert::get_parse_tree( debug() << "Getting class `" << class_name << "' from JAR " << jf << eom; - std::string data=jar_pool(jf).get_entry(jm_it->second.class_file_name); + std::string data=jar_pool(class_loader_limit, jf) + .get_entry(jm_it->second.class_file_name); std::istringstream istream(data); @@ -114,13 +138,12 @@ java_bytecode_parse_treet &java_class_loadert::get_parse_tree( } // See if we can find it in the class path - for(const auto &cp : config.java.classpath) { // in a JAR? if(has_suffix(cp, ".jar")) { - read_jar_file(cp); + read_jar_file(class_loader_limit, cp); const auto &jm=jar_map[cp]; @@ -131,7 +154,8 @@ java_bytecode_parse_treet &java_class_loadert::get_parse_tree( debug() << "Getting class `" << class_name << "' from JAR " << cp << eom; - std::string data=jar_pool(cp).get_entry(jm_it->second.class_file_name); + std::string data=jar_pool(class_loader_limit, cp) + .get_entry(jm_it->second.class_file_name); std::istringstream istream(data); @@ -153,7 +177,9 @@ java_bytecode_parse_treet &java_class_loadert::get_parse_tree( cp+'/'+class_name_to_file(class_name); #endif - if(std::ifstream(full_path)) + // full class path starts with './' + if(class_loader_limit.load_class_file(full_path.substr(2)) && + std::ifstream(full_path)) { if(!java_bytecode_parse( full_path, @@ -182,9 +208,11 @@ Function: java_class_loadert::load_entire_jar \*******************************************************************/ -void java_class_loadert::load_entire_jar(const std::string &file) +void java_class_loadert::load_entire_jar( + java_class_loader_limitt &class_loader_limit, + const std::string &file) { - read_jar_file(file); + read_jar_file(class_loader_limit, file); const auto &jm=jar_map[file]; @@ -208,13 +236,15 @@ Function: java_class_loadert::read_jar_file \*******************************************************************/ -void java_class_loadert::read_jar_file(const irep_idt &file) +void java_class_loadert::read_jar_file( + java_class_loader_limitt &class_loader_limit, + const irep_idt &file) { // done already? if(jar_map.find(file)!=jar_map.end()) return; - jar_filet &jar_file=jar_pool(id2string(file)); + jar_filet &jar_file=jar_pool(class_loader_limit, id2string(file)); if(!jar_file) { diff --git a/src/java_bytecode/java_class_loader.h b/src/java_bytecode/java_class_loader.h index 7a8f6da2b5c..c4676ff31f0 100644 --- a/src/java_bytecode/java_class_loader.h +++ b/src/java_bytecode/java_class_loader.h @@ -10,10 +10,13 @@ Author: Daniel Kroening, kroening@kroening.com #define CPROVER_JAVA_BYTECODE_JAVA_CLASS_LOADER_H #include +#include +#include #include #include "java_bytecode_parse_tree.h" +#include "java_class_loader_limit.h" #include "jar_file.h" class java_class_loadert:public messaget @@ -21,11 +24,7 @@ class java_class_loadert:public messaget public: java_bytecode_parse_treet &operator()(const irep_idt &); - void set_java_cp_include_files(std::string &java_cp_include_files) - { - jar_pool.set_java_cp_include_files(java_cp_include_files); - jar_pool.set_message_handler(get_message_handler()); - } + void set_java_cp_include_files(std::string &); // maps class names to the parse trees typedef std::map class_mapt; @@ -39,7 +38,7 @@ class java_class_loadert:public messaget jar_files.push_back(f); } - void load_entire_jar(const std::string &f); + void load_entire_jar(java_class_loader_limitt &, const std::string &f); jar_poolt jar_pool; @@ -60,12 +59,14 @@ class java_class_loadert:public messaget typedef std::map jar_mapt; jar_mapt jar_map; - void read_jar_file(const irep_idt &); + void read_jar_file(java_class_loader_limitt &, const irep_idt &); // get a parse tree for given class - java_bytecode_parse_treet &get_parse_tree(const irep_idt &); + java_bytecode_parse_treet &get_parse_tree( + java_class_loader_limitt &, const irep_idt &); std::list jar_files; + std::string java_cp_include_files; }; #endif // CPROVER_JAVA_BYTECODE_JAVA_CLASS_LOADER_H diff --git a/src/java_bytecode/java_class_loader_limit.cpp b/src/java_bytecode/java_class_loader_limit.cpp new file mode 100644 index 00000000000..3a9ed66d3d5 --- /dev/null +++ b/src/java_bytecode/java_class_loader_limit.cpp @@ -0,0 +1,81 @@ +/*******************************************************************\ + +Module: limit class path loading + +Author: Daniel Kroening, kroening@kroening.com + +\*******************************************************************/ + +#include + +#include "java_class_loader_limit.h" + +/*******************************************************************\ + +Function: java_class_loader_limitt::setup_class_load_limit + + Inputs: parameter from `java-cp-include-files` + + Outputs: + + Purpose: initializes class with either regex matcher or match set + +\*******************************************************************/ + +void java_class_loader_limitt::setup_class_load_limit( + std::string &java_cp_include_files) +{ + if(java_cp_include_files.empty()) + throw "class regexp cannot be empty"; + + // '@' signals file reading with list of class files to load + regex_match=java_cp_include_files[0]!='@'; + if(regex_match) + regex_matcher=std::regex(java_cp_include_files); + else + { + assert(java_cp_include_files.length()>1); + jsont json_cp_config; + if(parse_json( + java_cp_include_files.substr(1), + get_message_handler(), + json_cp_config)) + throw "cannot read JSON input configuration for JAR loading"; + if(!json_cp_config.is_object()) + throw "the JSON file has a wrong format"; + jsont include_files=json_cp_config["classFiles"]; + if(!include_files.is_null() && !include_files.is_array()) + throw "the JSON file has a wrong format"; + for(const jsont &file_entry : include_files.array) + { + assert(file_entry.is_string()); + set_matcher.insert(file_entry.value); + } + } +} + +/*******************************************************************\ + +Function: java_class_loader_limitt::load_class_file + + Inputs: class file name + + Outputs: true if file should be loaded, else false + + Purpose: + +\*******************************************************************/ + +bool java_class_loader_limitt::load_class_file(const irep_idt &file_name) +{ + if(regex_match) + { + return std::regex_match( + id2string(file_name), + string_matcher, + regex_matcher); + } + // load .class file only if it is in the match set + else + return set_matcher.find(id2string(file_name))!=set_matcher.end(); +} diff --git a/src/java_bytecode/java_class_loader_limit.h b/src/java_bytecode/java_class_loader_limit.h new file mode 100644 index 00000000000..fa5e21ffd95 --- /dev/null +++ b/src/java_bytecode/java_class_loader_limit.h @@ -0,0 +1,38 @@ +/*******************************************************************\ + +Module: limit class path loading + +Author: Daniel Kroening, kroening@kroening.com + +\*******************************************************************/ + +#ifndef CPROVER_JAVA_BYTECODE_JAVA_CLASS_LOADER_LIMIT_H +#define CPROVER_JAVA_BYTECODE_JAVA_CLASS_LOADER_LIMIT_H + +#include +#include + +#include +#include + +class java_class_loader_limitt:public messaget +{ + std::regex regex_matcher; + std::set set_matcher; + bool regex_match; + std::smatch string_matcher; + + void setup_class_load_limit(std::string &); + public: + explicit java_class_loader_limitt( + message_handlert &_message_handler, + std::string &java_cp_include_files) : + messaget(_message_handler), + regex_match(false) + { + setup_class_load_limit(java_cp_include_files); + } + bool load_class_file(const irep_idt &class_file_name); +}; + +#endif diff --git a/src/musketeer/fence_inserter.cpp b/src/musketeer/fence_inserter.cpp index dc1de9fb037..20236dfb956 100644 --- a/src/musketeer/fence_inserter.cpp +++ b/src/musketeer/fence_inserter.cpp @@ -494,7 +494,7 @@ void inline fence_insertert::mip_fill_matrix( e_c_it!=e_i->end(); ++e_c_it) { - std::set pt_set; + std::set pt_set; assert(map_to_e.find(*e_c_it)!=map_to_e.end()); const_graph_visitor.PT(map_to_e.find(*e_c_it)->second, pt_set); /* sum_e' f_e' */ @@ -538,7 +538,7 @@ void inline fence_insertert::mip_fill_matrix( e_nc_it!=e_i->end(); ++e_nc_it) { - std::set pt_set; + std::set pt_set; assert(map_to_e.find(*e_nc_it)!=map_to_e.end()); const_graph_visitor.PT(map_to_e.find(*e_nc_it)->second, pt_set); /* sum_e' (f_e' + lwf_e') */ @@ -582,7 +582,7 @@ void inline fence_insertert::mip_fill_matrix( e_nc_it!=e_i->end(); ++e_nc_it) { - std::set pt_set; + std::set pt_set; assert(map_to_e.find(*e_nc_it)!=map_to_e.end()); const_graph_visitor.PT(map_to_e.find(*e_nc_it)->second, pt_set); /* dp_e + sum_e' (f_e' + lwf_e' + br_e') */ @@ -649,12 +649,12 @@ void inline fence_insertert::mip_fill_matrix( e_nc_it!=e_i->end(); ++e_nc_it) { - std::set pt_set; + std::set pt_set; assert(map_to_e.find(*e_nc_it)!=map_to_e.end()); const_graph_visitor.PT(map_to_e.find(*e_nc_it)->second, pt_set); // uncomment for cf #if 0 - std::set it_set; + std::set it_set; IT(map_to_e.find(*e_nc_it)->second, it_set); #endif /* dp_e + sum_e' (f_e' + lwf_e') + sum_e'' cf_e'') */ @@ -722,13 +722,13 @@ void inline fence_insertert::mip_fill_matrix( { unsigned possibilities_met=0; - std::set ct_set; + std::set ct_set; assert(invisible_var.map_to_e.find(*e_c_it)!= invisible_var.map_to_e.end()); const_graph_visitor.CT(invisible_var.map_to_e.find(*e_c_it)->second, ct_set); - std::set ct_not_powr_set; + std::set ct_not_powr_set; const_graph_visitor.CT_not_powr(invisible_var.map_to_e.find( *e_c_it)->second, ct_not_powr_set); @@ -801,7 +801,7 @@ void fence_insertert::solve() assert(i-1==constraints_number); const std::size_t const_constraints_number=constraints_number; - const event_idt const_unique=unique; + const unsigned const_unique=unique; const std::size_t mat_size= // NOLINTNEXTLINE(whitespace/operators) @@ -1234,13 +1234,13 @@ void fence_insertert::print_vars() const { instrumenter.message.statistics() << "---- pos/pos+ (visible) variables ----" << messaget::eom; - for(std::map::const_iterator it=map_from_e.begin(); + for(std::map::const_iterator it=map_from_e.begin(); it!=map_from_e.end(); ++it) instrumenter.message.statistics() << it->first.first << "," << it->first.second << messaget::eom; instrumenter.message.statistics() << "---- cmp (invisible) variables ----" << messaget::eom; - for(std::map::const_iterator it= + for(std::map::const_iterator it= invisible_var.map_from_e.begin(); it!=invisible_var.map_from_e.end(); ++it) instrumenter.message.statistics() << it->first.first << "," diff --git a/src/musketeer/fence_inserter.h b/src/musketeer/fence_inserter.h index eaabff176ff..8f5e6286407 100644 --- a/src/musketeer/fence_inserter.h +++ b/src/musketeer/fence_inserter.h @@ -30,19 +30,19 @@ struct mip_vart { typedef event_grapht::critical_cyclet::delayt edget; - event_idt unique; + unsigned unique; - std::map map_to_e; - std::map map_from_e; + std::map map_to_e; + std::map map_from_e; - event_idt add_edge(const edget &e) + unsigned add_edge(const edget &e) { if(map_from_e.find(e) != map_from_e.end()) return map_from_e[e]; else { ++unique; - map_to_e.insert(std::pair(unique, e)); + map_to_e.insert(std::pair(unique, e)); map_from_e[e] = unique; return unique; } @@ -62,10 +62,10 @@ class fence_insertert instrumentert &instrumenter; /* normal variables used almost everytime */ - std::map &map_to_e; - std::map &map_from_e; - event_idt add_edge(const edget &e) { return var.add_edge(e); } - event_idt add_invisible_edge(const edget &e) + std::map &map_to_e; + std::map &map_from_e; + unsigned add_edge(const edget &e) { return var.add_edge(e); } + unsigned add_invisible_edge(const edget &e) { return invisible_var.add_edge(e); } @@ -78,7 +78,7 @@ class fence_insertert const_graph_visitort const_graph_visitor; protected: - event_idt &unique; + unsigned &unique; unsigned fence_options; /* MIP variables to edges in po^+/\C */ diff --git a/src/musketeer/musketeer_parse_options.cpp b/src/musketeer/musketeer_parse_options.cpp index 9114b8d7802..ae40a2f2318 100644 --- a/src/musketeer/musketeer_parse_options.cpp +++ b/src/musketeer/musketeer_parse_options.cpp @@ -214,7 +214,10 @@ void goto_fence_inserter_parse_optionst::instrument_goto_program( if(cmdline.isset("remove-function-pointers")) { status() << "remove soundly function pointers" << eom; - remove_function_pointers(symbol_table, goto_functions, + remove_function_pointers( + get_message_handler(), + symbol_table, + goto_functions, cmdline.isset("pointer-check")); } @@ -241,14 +244,11 @@ void goto_fence_inserter_parse_optionst::instrument_goto_program( // return; #if 0 status() << "Function Pointer Removal" << eom; - remove_function_pointers(symbol_table, goto_functions, - cmdline.isset("pointer-check")); -#endif - -#if 0 - // do partial inlining - status() << "Partial Inlining" << eom; - goto_partial_inline(goto_functions, ns, ui_message_handler); + remove_function_pointers( + get_message_handler(), + symbol_table, + goto_functions, + cmdline.isset("pointer-check"); #endif status() << "Pointer Analysis" << eom; diff --git a/src/pointer-analysis/value_set.cpp b/src/pointer-analysis/value_set.cpp index b83ed38fbf9..1def54bfab1 100644 --- a/src/pointer-analysis/value_set.cpp +++ b/src/pointer-analysis/value_set.cpp @@ -807,7 +807,7 @@ void value_sett::get_value_set_rec( assert(suffix==""); const typet &dynamic_type= - static_cast(expr.find("#type")); + static_cast(expr.find(ID_C_cxx_alloc_type)); // Create the most-recent-allocation dynamic-object dynamic_object_exprt dynamic_object_recent(dynamic_type, true); diff --git a/src/pointer-analysis/value_set_fi.cpp b/src/pointer-analysis/value_set_fi.cpp index 0fd9eaa6565..c66aa7004d7 100644 --- a/src/pointer-analysis/value_set_fi.cpp +++ b/src/pointer-analysis/value_set_fi.cpp @@ -724,7 +724,7 @@ void value_set_fit::get_value_set_rec( assert(suffix==""); const typet &dynamic_type= - static_cast(expr.find("#type")); + static_cast(expr.find(ID_C_cxx_alloc_type)); dynamic_object_exprt dynamic_object(dynamic_type); // let's make up a `unique' number for this object... diff --git a/src/pointer-analysis/value_set_fivr.cpp b/src/pointer-analysis/value_set_fivr.cpp index 5becc34b8c2..51da72fa875 100644 --- a/src/pointer-analysis/value_set_fivr.cpp +++ b/src/pointer-analysis/value_set_fivr.cpp @@ -854,7 +854,7 @@ void value_set_fivrt::get_value_set_rec( assert(suffix==""); const typet &dynamic_type= - static_cast(expr.find("#type")); + static_cast(expr.find(ID_C_cxx_alloc_type)); dynamic_object_exprt dynamic_object(dynamic_type); // let's make up a `unique' number for this object... diff --git a/src/pointer-analysis/value_set_fivrns.cpp b/src/pointer-analysis/value_set_fivrns.cpp index 7d0c2f198d2..98657fc092d 100644 --- a/src/pointer-analysis/value_set_fivrns.cpp +++ b/src/pointer-analysis/value_set_fivrns.cpp @@ -628,7 +628,7 @@ void value_set_fivrnst::get_value_set_rec( assert(suffix==""); const typet &dynamic_type= - static_cast(expr.find("#type")); + static_cast(expr.find(ID_C_cxx_alloc_type)); dynamic_object_exprt dynamic_object(dynamic_type); // let's make up a `unique' number for this object... diff --git a/src/solvers/miniBDD/Makefile b/src/solvers/miniBDD/Makefile index aa4d2f532df..55b6a0ed86c 100644 --- a/src/solvers/miniBDD/Makefile +++ b/src/solvers/miniBDD/Makefile @@ -16,7 +16,7 @@ test_miniBDD: miniBDD.o test_miniBDD.o g++ $(CPLUSFLAGS) miniBDD.o test_miniBDD.o -o test_miniBDD clean: - rm -f miniBDD.o test_miniBDD.o test_miniBDD + $(RM) miniBDD.o test_miniBDD.o test_miniBDD miniBDD.tgz: miniBDD.cpp miniBDD.inc miniBDD.h test_miniBDD.cpp Makefile tar cvfz miniBDD.tgz miniBDD.cpp miniBDD.inc \ diff --git a/src/solvers/qbf/qbf_bdd_core.cpp b/src/solvers/qbf/qbf_bdd_core.cpp index 7071a6abc66..9fa58639ad0 100644 --- a/src/solvers/qbf/qbf_bdd_core.cpp +++ b/src/solvers/qbf/qbf_bdd_core.cpp @@ -445,7 +445,7 @@ void qbf_bdd_coret::compress_certificate(void) if(model==bdd_manager->bddOne() || model==bdd_manager->bddZero()) { - for(const quantifiert &quantifier2 : quantifier) + for(const quantifiert &quantifier2 : quantifiers) { BDD &model2=*model_bdds[quantifier2.var_no]; diff --git a/src/symex/path_search.cpp b/src/symex/path_search.cpp index fe34b04cc66..fcbaebbc39a 100644 --- a/src/symex/path_search.cpp +++ b/src/symex/path_search.cpp @@ -6,6 +6,7 @@ Author: Daniel Kroening, kroening@kroening.com \*******************************************************************/ +#include #include #include @@ -315,8 +316,10 @@ Function: path_searcht::drop_state \*******************************************************************/ -bool path_searcht::drop_state(const statet &state) const +bool path_searcht::drop_state(const statet &state) { + goto_programt::const_targett pc=state.get_instruction(); + // depth limit if(depth_limit_set && state.get_depth()>depth_limit) return true; @@ -345,6 +348,22 @@ bool path_searcht::drop_state(const statet &state) const return true; } + if(pc->is_assume() && + simplify_expr(pc->guard, ns).is_false()) + { + debug() << "aborting path on assume(false) at " + << pc->source_location + << " thread " << state.get_current_thread(); + + const irep_idt &c=pc->source_location.get_comment(); + if(!c.empty()) + debug() << ": " << c; + + debug() << eom; + + return true; + } + return false; } diff --git a/src/symex/path_search.h b/src/symex/path_search.h index b72588c593c..49fc621b84e 100644 --- a/src/symex/path_search.h +++ b/src/symex/path_search.h @@ -120,7 +120,7 @@ class path_searcht:public safety_checkert bool is_feasible(statet &state); void do_show_vcc(statet &state); - bool drop_state(const statet &state) const; + bool drop_state(const statet &state); void report_statistics(); diff --git a/src/util/Makefile b/src/util/Makefile index 870b524e609..ead015e81eb 100644 --- a/src/util/Makefile +++ b/src/util/Makefile @@ -31,30 +31,9 @@ INCLUDES= -I .. include ../config.inc include ../common -CLEANFILES = util$(LIBEXT) \ - irep_ids.h irep_ids.inc \ - irep_ids_convert$(EXEEXT) irep_ids_convert$(OBJEXT) irep_ids_convert.d +CLEANFILES = util$(LIBEXT) all: util$(LIBEXT) -############################################################################### - -irep_ids.h: irep_ids.txt irep_ids_convert$(EXEEXT) - ./irep_ids_convert$(EXEEXT) header < $< > $@ - -irep_ids.inc: irep_ids.txt irep_ids_convert$(EXEEXT) - ./irep_ids_convert$(EXEEXT) table < $< > $@ - -irep_ids.cpp: irep_ids.inc irep_ids.h - -irep_ids_convert$(EXEEXT): irep_ids_convert.cpp - $(LINKNATIVE) - -generated_files: irep_ids.h irep_ids.inc - -# Most of the others will need irep_ids.h, -# which we first need to generate. -$(OBJ): irep_ids.h - util$(LIBEXT): $(OBJ) $(LINKLIB) diff --git a/src/util/dstring.h b/src/util/dstring.h index c2efaad4662..ae219a01bb0 100644 --- a/src/util/dstring.h +++ b/src/util/dstring.h @@ -16,7 +16,9 @@ Author: Daniel Kroening, kroening@kroening.com class serializert; -class dstringt +// Marked final to disable inheritance. +// No virtual destructor, so runtime-polymorphic use would be unsafe. +class dstringt final { public: // this is safe for static objects @@ -28,12 +30,12 @@ class dstringt } // this is safe for static objects - // the 2nd argument is to avoid accidental conversions #ifdef __GNUC__ constexpr #endif - dstringt(unsigned _no, unsigned):no(_no) + static dstringt make_from_table_index(unsigned no) { + return dstringt(no); } #if 0 @@ -140,7 +142,14 @@ class dstringt return no; } -protected: +private: + #ifdef __GNUC__ + constexpr + #endif + explicit dstringt(unsigned _no):no(_no) + { + } + unsigned no; // the reference returned is guaranteed to be stable diff --git a/src/util/irep.h b/src/util/irep.h index 7287eca93b6..49ed9fb3070 100644 --- a/src/util/irep.h +++ b/src/util/irep.h @@ -14,7 +14,8 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#define USE_DSTRING +#include "irep_ids.h" + #define SHARING // #define HASH_CODE #define USE_MOVE @@ -26,12 +27,6 @@ Author: Daniel Kroening, kroening@kroening.com #include #endif -#ifdef USE_DSTRING -#include "dstring.h" -#endif - -#include "irep_ids.h" - #ifdef USE_DSTRING typedef dstringt irep_idt; typedef dstringt irep_namet; diff --git a/src/util/irep_ids.cpp b/src/util/irep_ids.cpp index 154683d3552..bb67b275f0a 100644 --- a/src/util/irep_ids.cpp +++ b/src/util/irep_ids.cpp @@ -13,10 +13,32 @@ Author: Daniel Kroening, kroening@kroening.com const char *irep_ids_table[]= { - #include "irep_ids.inc" - NULL +#define IREP_ID_ONE(id) #id, +#define IREP_ID_TWO(id, str) #str, + +#include "irep_ids.def" + + NULL, }; +#ifdef USE_DSTRING + +#define IREP_ID_ONE(the_id) \ + const dstringt ID_##the_id=dstringt::make_from_table_index( \ + static_cast(idt::id_##the_id)); +#define IREP_ID_TWO(the_id, str) \ + const dstringt ID_##the_id=dstringt::make_from_table_index( \ + static_cast(idt::id_##the_id)); + +#else + +#define IREP_ID_ONE(the_id) const std::string ID_##the_id(#the_id); +#define IREP_ID_TWO(the_id, str) const std::string ID_##the_id(#the_id); + +#endif + +#include "irep_ids.def" // NOLINT(build/include) + /*******************************************************************\ Function: initialize_string_container diff --git a/src/util/irep_ids.def b/src/util/irep_ids.def new file mode 100644 index 00000000000..0f73c268ab0 --- /dev/null +++ b/src/util/irep_ids.def @@ -0,0 +1,818 @@ +IREP_ID_TWO(empty_string, ) +IREP_ID_ONE(let) +IREP_ID_ONE(nil) +IREP_ID_ONE(type) +IREP_ID_ONE(operands) +IREP_ID_ONE(bool) +IREP_ID_ONE(c_bool) +IREP_ID_ONE(proper_bool) +IREP_ID_ONE(signedbv) +IREP_ID_ONE(unsignedbv) +IREP_ID_ONE(verilog_signedbv) +IREP_ID_ONE(verilog_unsignedbv) +IREP_ID_ONE(floatbv) +IREP_ID_ONE(fixedbv) +IREP_ID_ONE(x86_extended) +IREP_ID_TWO(C_source_location, #source_location) +IREP_ID_TWO(C_end_location, #end_location) +IREP_ID_TWO(C_is_padding, #is_padding) +IREP_ID_ONE(file) +IREP_ID_ONE(line) +IREP_ID_ONE(column) +IREP_ID_ONE(comment) +IREP_ID_ONE(property) +IREP_ID_ONE(property_class) +IREP_ID_ONE(property_id) +IREP_ID_ONE(function) +IREP_ID_ONE(code) +IREP_ID_ONE(typecast) +IREP_ID_ONE(static_cast) +IREP_ID_ONE(dynamic_cast) +IREP_ID_ONE(const_cast) +IREP_ID_ONE(reinterpret_cast) +IREP_ID_ONE(index) +IREP_ID_ONE(index_range) +IREP_ID_ONE(ptrmember) +IREP_ID_ONE(member) +IREP_ID_ONE(member_name) +IREP_ID_TWO(C_member_name, #member_name) +IREP_ID_TWO(equal, =) +IREP_ID_TWO(implies, =>) +IREP_ID_TWO(iff, <=>) +IREP_ID_ONE(and) +IREP_ID_ONE(nand) +IREP_ID_ONE(or) +IREP_ID_ONE(nor) +IREP_ID_ONE(xor) +IREP_ID_ONE(xnor) +IREP_ID_ONE(not) +IREP_ID_ONE(bitand) +IREP_ID_ONE(bitor) +IREP_ID_ONE(bitnot) +IREP_ID_ONE(bitxor) +IREP_ID_ONE(bitnand) +IREP_ID_ONE(bitnor) +IREP_ID_ONE(bitxnor) +IREP_ID_ONE(notequal) +IREP_ID_ONE(if) +IREP_ID_ONE(symbol) +IREP_ID_ONE(next_symbol) +IREP_ID_ONE(nondet_symbol) +IREP_ID_ONE(predicate) +IREP_ID_ONE(predicate_symbol) +IREP_ID_ONE(predicate_next_symbol) +IREP_ID_ONE(nondet_bool) +IREP_ID_ONE(empty) +IREP_ID_ONE(side_effect) +IREP_ID_ONE(statement) +IREP_ID_ONE(statement_expression) +IREP_ID_ONE(value) +IREP_ID_ONE(constant) +IREP_ID_ONE(block) +IREP_ID_ONE(decl) +IREP_ID_ONE(dead) +IREP_ID_ONE(assign) +IREP_ID_ONE(assign_div) +IREP_ID_TWO(assign_mult, assign*) +IREP_ID_TWO(assign_plus, assign+) +IREP_ID_TWO(assign_minus, assign-) +IREP_ID_ONE(assign_mod) +IREP_ID_ONE(assign_shl) +IREP_ID_ONE(assign_shr) +IREP_ID_ONE(assign_ashr) +IREP_ID_ONE(assign_lshr) +IREP_ID_ONE(assign_bitand) +IREP_ID_ONE(assign_bitxor) +IREP_ID_ONE(assign_bitor) +IREP_ID_ONE(assume) +IREP_ID_ONE(assert) +IREP_ID_ONE(assertion) +IREP_ID_ONE(goto) +IREP_ID_ONE(gcc_computed_goto) +IREP_ID_ONE(ifthenelse) +IREP_ID_ONE(label) +IREP_ID_ONE(break) +IREP_ID_ONE(continue) +IREP_ID_ONE(function_call) +IREP_ID_ONE(return) +IREP_ID_ONE(skip) +IREP_ID_ONE(arguments) +IREP_ID_ONE(array) +IREP_ID_ONE(size) +IREP_ID_ONE(pointer) +IREP_ID_ONE(block_pointer) +IREP_ID_ONE(switch) +IREP_ID_ONE(switch_case) +IREP_ID_ONE(gcc_switch_case_range) +IREP_ID_ONE(for) +IREP_ID_ONE(while) +IREP_ID_ONE(dowhile) +IREP_ID_ONE(int) +IREP_ID_ONE(integer) +IREP_ID_ONE(natural) +IREP_ID_ONE(real) +IREP_ID_ONE(rational) +IREP_ID_ONE(complex) +IREP_ID_ONE(signed) +IREP_ID_ONE(unsigned) +IREP_ID_ONE(asm) +IREP_ID_ONE(gcc_asm_input) +IREP_ID_ONE(gcc_asm_output) +IREP_ID_ONE(gcc_asm_clobbered_register) +IREP_ID_ONE(incomplete_array) +IREP_ID_ONE(incomplete_struct) +IREP_ID_ONE(incomplete_union) +IREP_ID_ONE(incomplete_class) +IREP_ID_ONE(incomplete_c_enum) +IREP_ID_TWO(C_incomplete, #incomplete) +IREP_ID_ONE(identifier) +IREP_ID_ONE(name) +IREP_ID_ONE(cpp_name) +IREP_ID_ONE(component_cpp_name) +IREP_ID_TWO(C_id_class, #id_class) +IREP_ID_ONE(declaration) +IREP_ID_ONE(declaration_list) +IREP_ID_ONE(declarator) +IREP_ID_ONE(struct) +IREP_ID_ONE(c_bit_field) +IREP_ID_ONE(union) +IREP_ID_ONE(class) +IREP_ID_ONE(merged_type) +IREP_ID_ONE(range) +IREP_ID_ONE(from) +IREP_ID_ONE(to) +IREP_ID_ONE(module) +IREP_ID_ONE(module_instance) +IREP_ID_ONE(macromodule) +IREP_ID_ONE(primitive_module_instance) +IREP_ID_ONE(module_items) +IREP_ID_ONE(module_source) +IREP_ID_ONE(parameter_decl) +IREP_ID_ONE(local_parameter_decl) +IREP_ID_ONE(parameter) +IREP_ID_ONE(component_name) +IREP_ID_ONE(component_number) +IREP_ID_ONE(tag) +IREP_ID_ONE(default) +IREP_ID_TWO(C_default_value, #default_value) +IREP_ID_ONE(base_name) +IREP_ID_TWO(C_base_name, #base_name) +IREP_ID_ONE(string) +IREP_ID_TWO(C_string_constant, #string_constant) +IREP_ID_ONE(string_constant) +IREP_ID_ONE(width) +IREP_ID_ONE(components) +IREP_ID_ONE(bv) +IREP_ID_ONE(f) +IREP_ID_ONE(ports) +IREP_ID_ONE(port) +IREP_ID_ONE(offset) +IREP_ID_ONE(with) +IREP_ID_ONE(trans) +IREP_ID_ONE(throw) +IREP_ID_ONE(catch) +IREP_ID_ONE(try_catch) +IREP_ID_ONE(noexcept) +IREP_ID_ONE(CPROVER_throw) +IREP_ID_ONE(CPROVER_try_catch) +IREP_ID_ONE(CPROVER_try_finally) +IREP_ID_ONE(protection) +IREP_ID_ONE(private) +IREP_ID_ONE(public) +IREP_ID_ONE(protected) +IREP_ID_ONE(virtual) +IREP_ID_ONE(volatile) +IREP_ID_ONE(const) +IREP_ID_ONE(constexpr) +IREP_ID_ONE(inline) +IREP_ID_ONE(forall) +IREP_ID_ONE(exists) +IREP_ID_ONE(forever) +IREP_ID_ONE(repeat) +IREP_ID_ONE(extractbit) +IREP_ID_ONE(extractbits) +IREP_ID_ONE(reference) +IREP_ID_TWO(C_reference, #reference) +IREP_ID_TWO(C_rvalue_reference, #rvalue_reference) +IREP_ID_ONE(true) +IREP_ID_ONE(false) +IREP_ID_ONE(address_of) +IREP_ID_ONE(dereference) +IREP_ID_TWO(C_lvalue, #lvalue) +IREP_ID_TWO(C_base, #base) +IREP_ID_ONE(destination) +IREP_ID_ONE(main) +IREP_ID_ONE(expression) +IREP_ID_ONE(free) +IREP_ID_ONE(malloc) +IREP_ID_TWO(C_cxx_alloc_type, #cxx_alloc_type) +IREP_ID_ONE(cpp_new) +IREP_ID_ONE(cpp_delete) +IREP_ID_TWO(cpp_new_array, cpp_new[]) +IREP_ID_TWO(cpp_delete_array, cpp_delete[]) +IREP_ID_ONE(java_new) +IREP_ID_ONE(java_new_array) +IREP_ID_ONE(java_string_literal) +IREP_ID_ONE(printf) +IREP_ID_ONE(input) +IREP_ID_ONE(output) +IREP_ID_ONE(output_register) +IREP_ID_ONE(inout) +IREP_ID_ONE(nondet) +IREP_ID_ONE(NULL) +IREP_ID_ONE(null) +IREP_ID_ONE(nullptr) +IREP_ID_ONE(c_enum) +IREP_ID_ONE(enumeration) +IREP_ID_ONE(elements) +IREP_ID_ONE(unknown) +IREP_ID_ONE(uninitialized) +IREP_ID_ONE(invalid) +IREP_ID_TWO(C_invalid_object, #invalid_object) +IREP_ID_ONE(pointer_offset) +IREP_ID_ONE(pointer_object) +IREP_ID_TWO(invalid_pointer, invalid-pointer) +IREP_ID_ONE(ieee_float_equal) +IREP_ID_ONE(ieee_float_notequal) +IREP_ID_ONE(isnan) +IREP_ID_ONE(lambda) +IREP_ID_ONE(array_of) +IREP_ID_ONE(array_equal) +IREP_ID_ONE(array_set) +IREP_ID_ONE(array_copy) +IREP_ID_ONE(mod) +IREP_ID_ONE(rem) +IREP_ID_ONE(shr) +IREP_ID_ONE(ashr) +IREP_ID_ONE(lshr) +IREP_ID_ONE(shl) +IREP_ID_ONE(rol) +IREP_ID_ONE(ror) +IREP_ID_ONE(comma) +IREP_ID_ONE(concatenation) +IREP_ID_ONE(infinity) +IREP_ID_ONE(return_type) +IREP_ID_ONE(typedef) +IREP_ID_TWO(C_typedef, #typedef) +IREP_ID_ONE(extern) +IREP_ID_ONE(static) +IREP_ID_ONE(auto) +IREP_ID_ONE(register) +IREP_ID_ONE(thread_local) +IREP_ID_ONE(thread) +IREP_ID_TWO(C_thread_local, #thread_local) +IREP_ID_TWO(C_static_lifetime, #static_lifetime) +IREP_ID_ONE(mutable) +IREP_ID_ONE(void) +IREP_ID_ONE(int8) +IREP_ID_ONE(int16) +IREP_ID_ONE(int32) +IREP_ID_ONE(int64) +IREP_ID_ONE(ptr32) +IREP_ID_ONE(ptr64) +IREP_ID_ONE(char) +IREP_ID_ONE(short) +IREP_ID_ONE(long) +IREP_ID_ONE(longlong) +IREP_ID_ONE(float) +IREP_ID_ONE(double) +IREP_ID_ONE(byte) +IREP_ID_ONE(boolean) +IREP_ID_ONE(long_double) +IREP_ID_ONE(signed_char) +IREP_ID_ONE(unsigned_char) +IREP_ID_ONE(signed_int) +IREP_ID_ONE(unsigned_int) +IREP_ID_ONE(signed_long_int) +IREP_ID_ONE(unsigned_long_int) +IREP_ID_ONE(signed_short_int) +IREP_ID_ONE(unsigned_short_int) +IREP_ID_ONE(signed_long_long_int) +IREP_ID_ONE(unsigned_long_long_int) +IREP_ID_ONE(signed_int128) +IREP_ID_ONE(unsigned_int128) +IREP_ID_ONE(case) +IREP_ID_ONE(casex) +IREP_ID_ONE(casez) +IREP_ID_ONE(case_item) +IREP_ID_TWO(C_inlined, #inlined) +IREP_ID_TWO(C_hide, #hide) +IREP_ID_ONE(hide) +IREP_ID_ONE(abs) +IREP_ID_ONE(sign) +IREP_ID_ONE(access) +IREP_ID_TWO(C_access, #access) +IREP_ID_ONE(postincrement) +IREP_ID_ONE(postdecrement) +IREP_ID_ONE(preincrement) +IREP_ID_ONE(predecrement) +IREP_ID_ONE(integer_bits) +IREP_ID_ONE(KnR) +IREP_ID_TWO(C_KnR, #KnR) +IREP_ID_ONE(constraint_select_one) +IREP_ID_ONE(cond) +IREP_ID_ONE(bv_literals) +IREP_ID_ONE(isfinite) +IREP_ID_ONE(isinf) +IREP_ID_ONE(isnormal) +IREP_ID_ONE(AG) +IREP_ID_ONE(AF) +IREP_ID_ONE(AX) +IREP_ID_ONE(EG) +IREP_ID_ONE(EF) +IREP_ID_ONE(EX) +IREP_ID_ONE(U) +IREP_ID_ONE(R) +IREP_ID_ONE(A) +IREP_ID_ONE(F) +IREP_ID_ONE(E) +IREP_ID_ONE(G) +IREP_ID_ONE(X) +IREP_ID_ONE(continuous_assign) +IREP_ID_ONE(blocking_assign) +IREP_ID_ONE(non_blocking_assign) +IREP_ID_ONE(alignof) +IREP_ID_ONE(gcc_builtin_va_arg) +IREP_ID_ONE(gcc_builtin_types_compatible_p) +IREP_ID_ONE(gcc_builtin_va_arg_next) +IREP_ID_ONE(gcc_builtin_va_list) +IREP_ID_ONE(gcc_float80) +IREP_ID_ONE(gcc_float128) +IREP_ID_ONE(gcc_int128) +IREP_ID_ONE(gcc_decimal32) +IREP_ID_ONE(gcc_decimal64) +IREP_ID_ONE(gcc_decimal128) +IREP_ID_ONE(builtin_offsetof) +IREP_ID_ONE(0) +IREP_ID_ONE(1) +IREP_ID_ONE(8) +IREP_ID_ONE(16) +IREP_ID_ONE(32) +IREP_ID_ONE(64) +IREP_ID_ONE(128) +IREP_ID_ONE(sizeof) +IREP_ID_ONE(type_arg) +IREP_ID_ONE(expr_arg) +IREP_ID_ONE(expression_list) +IREP_ID_ONE(initializer_list) +IREP_ID_ONE(gcc_conditional_expression) +IREP_ID_ONE(gcc_local_label) +IREP_ID_ONE(gcc) +IREP_ID_ONE(msc) +IREP_ID_ONE(typeof) +IREP_ID_ONE(ellipsis) +IREP_ID_ONE(flavor) +IREP_ID_TWO(ge, >=) +IREP_ID_TWO(le, <=) +IREP_ID_TWO(gt, >) +IREP_ID_TWO(lt, <) +IREP_ID_TWO(plus, +) +IREP_ID_TWO(minus, -) +IREP_ID_TWO(unary_minus, unary-) +IREP_ID_TWO(unary_plus, unary+) +IREP_ID_TWO(mult, *) +IREP_ID_TWO(div, /) +IREP_ID_TWO(power, **) +IREP_ID_ONE(factorial_power) +IREP_ID_ONE(component) +IREP_ID_ONE(pretty_name) +IREP_ID_TWO(C_class, #class) +IREP_ID_TWO(C_interface, #interface) +IREP_ID_ONE(interface) +IREP_ID_ONE(targets) +IREP_ID_ONE(location) +IREP_ID_ONE(labels) +IREP_ID_ONE(event) +IREP_ID_ONE(guard) +IREP_ID_ONE(designated_initializer) +IREP_ID_ONE(designator) +IREP_ID_ONE(member_designator) +IREP_ID_ONE(index_designator) +IREP_ID_ONE(offset_designator) +IREP_ID_TWO(C_constant, #constant) +IREP_ID_TWO(C_volatile, #volatile) +IREP_ID_TWO(C_restricted, #restricted) +IREP_ID_TWO(C_identifier, #identifier) +IREP_ID_TWO(C_implicit, #implicit) +IREP_ID_TWO(C_ptr32, #ptr32) +IREP_ID_TWO(C_ptr64, #ptr64) +IREP_ID_TWO(C_atomic, #atomic) +IREP_ID_ONE(restrict) +IREP_ID_ONE(byte_extract_big_endian) +IREP_ID_ONE(byte_extract_little_endian) +IREP_ID_ONE(byte_update_big_endian) +IREP_ID_ONE(byte_update_little_endian) +IREP_ID_ONE(replication) +IREP_ID_ONE(dummy) +IREP_ID_ONE(init) +IREP_ID_ONE(cprover_atomic) +IREP_ID_ONE(atomic) +IREP_ID_ONE(atomic_type_specifier) +IREP_ID_ONE(atomic_begin) +IREP_ID_ONE(atomic_end) +IREP_ID_ONE(start_thread) +IREP_ID_ONE(end_thread) +IREP_ID_ONE(specc_notify) +IREP_ID_ONE(specc_par) +IREP_ID_ONE(specc_wait) +IREP_ID_ONE(specc_event) +IREP_ID_ONE(bp_enforce) +IREP_ID_ONE(bp_abortif) +IREP_ID_ONE(bp_constrain) +IREP_ID_ONE(bp_schoose) +IREP_ID_ONE(bp_dead) +IREP_ID_ONE(instance) +IREP_ID_ONE(cover) +IREP_ID_ONE(coverage_criterion) +IREP_ID_ONE(initializer) +IREP_ID_ONE(anonymous) +IREP_ID_TWO(C_is_anonymous, #is_anonymous) +IREP_ID_ONE(is_macro) +IREP_ID_ONE(is_enum_constant) +IREP_ID_ONE(is_inline) +IREP_ID_ONE(is_extern) +IREP_ID_ONE(is_global) +IREP_ID_ONE(is_thread_local) +IREP_ID_ONE(is_parameter) +IREP_ID_ONE(is_member) +IREP_ID_ONE(is_type) +IREP_ID_ONE(is_register) +IREP_ID_ONE(is_typedef) +IREP_ID_ONE(is_static) +IREP_ID_ONE(is_template) +IREP_ID_ONE(is_static_assert) +IREP_ID_ONE(is_virtual) +IREP_ID_TWO(C_is_virtual, #is_virtual) +IREP_ID_ONE(literal) +IREP_ID_ONE(member_initializers) +IREP_ID_ONE(member_initializer) +IREP_ID_ONE(method_qualifier) +IREP_ID_ONE(methods) +IREP_ID_ONE(constructor) +IREP_ID_ONE(destructor) +IREP_ID_ONE(bases) +IREP_ID_ONE(base) +IREP_ID_ONE(from_base) +IREP_ID_ONE(operator) +IREP_ID_ONE(template) +IREP_ID_ONE(template_class_instance) +IREP_ID_ONE(template_function_instance) +IREP_ID_ONE(template_type) +IREP_ID_ONE(template_args) +IREP_ID_ONE(template_parameter) +IREP_ID_ONE(template_parameters) +IREP_ID_TWO(C_template, #template) +IREP_ID_TWO(C_template_arguments, #template_arguments) +IREP_ID_ONE(typename) +IREP_ID_ONE(C) +IREP_ID_ONE(cpp) +IREP_ID_ONE(java) +IREP_ID_ONE(SpecC) +IREP_ID_ONE(SystemC) +IREP_ID_ONE(decl_block) +IREP_ID_ONE(decl_type) +IREP_ID_ONE(genvar) +IREP_ID_ONE(realtime) +IREP_ID_ONE(parameters) +IREP_ID_ONE(parameter_assignments) +IREP_ID_ONE(named_parameter_assignment) +IREP_ID_ONE(specify) +IREP_ID_ONE(pullup) +IREP_ID_ONE(pulldown) +IREP_ID_ONE(automatic) +IREP_ID_ONE(rcmos) +IREP_ID_ONE(cmos) +IREP_ID_ONE(nmos) +IREP_ID_ONE(pmos) +IREP_ID_ONE(rnmos) +IREP_ID_ONE(rpmos) +IREP_ID_ONE(wchar_t) +IREP_ID_ONE(char16_t) +IREP_ID_ONE(char32_t) +IREP_ID_ONE(size_t) +IREP_ID_ONE(ssize_t) +IREP_ID_ONE(inst) +IREP_ID_ONE(inst_builtin) +IREP_ID_ONE(always) +IREP_ID_ONE(initial) +IREP_ID_ONE(mode) +IREP_ID_ONE(this) +IREP_ID_TWO(C_this, #this) +IREP_ID_ONE(reduction_and) +IREP_ID_ONE(reduction_or) +IREP_ID_ONE(reduction_nand) +IREP_ID_ONE(reduction_nor) +IREP_ID_ONE(reduction_xor) +IREP_ID_ONE(reduction_xnor) +IREP_ID_TWO(C_zero_initializer, #zero_initializer) +IREP_ID_ONE(body) +IREP_ID_ONE(entity) +IREP_ID_ONE(temporary_object) +IREP_ID_TWO(overflow_plus, overflow-+) +IREP_ID_TWO(overflow_minus, overflow--) +IREP_ID_TWO(overflow_mult, overflow-*) +IREP_ID_TWO(overflow_unary_minus, overflow-unary-) +IREP_ID_ONE(object_descriptor) +IREP_ID_ONE(dynamic_object) +IREP_ID_ONE(is_most_recent_allocation) +IREP_ID_ONE(most_recent_allocation) +IREP_ID_ONE(any_allocation) +IREP_ID_ONE(object_size) +IREP_ID_ONE(good_pointer) +IREP_ID_ONE(integer_address) +IREP_ID_ONE(integer_address_object) +IREP_ID_ONE(null_object) +IREP_ID_ONE(static_object) +IREP_ID_ONE(stack_object) +IREP_ID_TWO(C_is_failed_symbol, #is_failed_symbol) +IREP_ID_TWO(C_failed_symbol, #failed_symbol) +IREP_ID_ONE(list) +IREP_ID_ONE(map) +IREP_ID_ONE(set) +IREP_ID_ONE(storage) +IREP_ID_ONE(friend) +IREP_ID_ONE(explicit) +IREP_ID_ONE(storage_spec) +IREP_ID_ONE(member_spec) +IREP_ID_ONE(msc_declspec) +IREP_ID_ONE(packed) +IREP_ID_TWO(C_packed, #packed) +IREP_ID_ONE(transparent_union) +IREP_ID_TWO(C_transparent_union, #transparent_union) +IREP_ID_ONE(aligned) +IREP_ID_TWO(C_alignment, #alignment) +IREP_ID_ONE(vector) +IREP_ID_ONE(abstract) +IREP_ID_ONE(bit) +IREP_ID_ONE(logic) +IREP_ID_ONE(chandle) +IREP_ID_ONE(reg) +IREP_ID_ONE(wire) +IREP_ID_ONE(tri) +IREP_ID_ONE(tri1) +IREP_ID_ONE(supply0) +IREP_ID_ONE(wand) +IREP_ID_ONE(triand) +IREP_ID_ONE(tri0) +IREP_ID_ONE(supply1) +IREP_ID_ONE(wor) +IREP_ID_ONE(trior) +IREP_ID_ONE(trireg) +IREP_ID_ONE(function_application) +IREP_ID_ONE(cpp_declarator) +IREP_ID_ONE(cpp_linkage_spec) +IREP_ID_ONE(cpp_namespace_spec) +IREP_ID_ONE(cpp_storage_spec) +IREP_ID_ONE(cpp_using) +IREP_ID_ONE(cpp_declaration) +IREP_ID_ONE(cpp_static_assert) +IREP_ID_ONE(cpp_member_spec) +IREP_ID_TWO(C_c_type, #c_type) +IREP_ID_ONE(namespace) +IREP_ID_ONE(linkage) +IREP_ID_ONE(decltype) +IREP_ID_ONE(buf) +IREP_ID_ONE(bufif0) +IREP_ID_ONE(bufif1) +IREP_ID_ONE(notif0) +IREP_ID_ONE(notif1) +IREP_ID_ONE(task) +IREP_ID_TWO(C_little_endian, #little_endian) +IREP_ID_TWO(C_offset, #offset) +IREP_ID_TWO(C_tag_only_declaration, #tag_only_declaration) +IREP_ID_ONE(struct_tag) +IREP_ID_ONE(union_tag) +IREP_ID_ONE(c_enum_tag) +IREP_ID_ONE(enum_constant) +IREP_ID_ONE(bit_select) +IREP_ID_ONE(part_select) +IREP_ID_ONE(indexed_part_select_plus) +IREP_ID_ONE(indexed_part_select_minus) +IREP_ID_ONE(generate_block) +IREP_ID_ONE(generate_assign) +IREP_ID_ONE(generate_skip) +IREP_ID_ONE(generate_case) +IREP_ID_ONE(generate_if) +IREP_ID_ONE(generate_for) +IREP_ID_ONE(delay) +IREP_ID_ONE(verilog_cycle_delay) +IREP_ID_ONE(sva_cycle_delay) +IREP_ID_ONE(sva_sequence_throughout) +IREP_ID_ONE(sva_sequence_concatenation) +IREP_ID_ONE(sva_sequence_first_match) +IREP_ID_ONE(sva_always) +IREP_ID_ONE(sva_nexttime) +IREP_ID_ONE(sva_s_nexttime) +IREP_ID_ONE(sva_eventually) +IREP_ID_ONE(sva_s_eventually) +IREP_ID_ONE(sva_until) +IREP_ID_ONE(sva_s_until) +IREP_ID_ONE(sva_until_with) +IREP_ID_ONE(sva_s_until_with) +IREP_ID_ONE(sva_overlapped_implication) +IREP_ID_ONE(sva_non_overlapped_implication) +IREP_ID_ONE(hierarchical_identifier) +IREP_ID_ONE(named_port_connection) +IREP_ID_ONE(named_block) +IREP_ID_ONE(verilog_primitive_module) +IREP_ID_ONE(verilog_module) +IREP_ID_ONE(verilog_case_equality) +IREP_ID_ONE(verilog_case_inequality) +IREP_ID_ONE(event_guard) +IREP_ID_ONE(posedge) +IREP_ID_ONE(negedge) +IREP_ID_ONE(pointer_and_address_pair) +IREP_ID_ONE(user_specified_predicate) +IREP_ID_ONE(user_specified_parameter_predicates) +IREP_ID_ONE(user_specified_return_predicates) +IREP_ID_ONE(unassigned) +IREP_ID_ONE(new_object) +IREP_ID_ONE(complex_real) +IREP_ID_ONE(complex_imag) +IREP_ID_ONE(imag) +IREP_ID_ONE(msc_try_except) +IREP_ID_ONE(msc_try_finally) +IREP_ID_ONE(msc_leave) +IREP_ID_ONE(msc_uuidof) +IREP_ID_ONE(msc_if_exists) +IREP_ID_ONE(msc_if_not_exists) +IREP_ID_ONE(msc_underlying_type) +IREP_ID_ONE(msc_based) +IREP_ID_ONE(alias) +IREP_ID_ONE(auto_object) +IREP_ID_ONE(ssa_object) +IREP_ID_ONE(ptr_object) +IREP_ID_TWO(C_c_sizeof_type, #c_sizeof_type) +IREP_ID_ONE(array_update) +IREP_ID_ONE(struct_update) +IREP_ID_ONE(union_update) +IREP_ID_ONE(update) +IREP_ID_ONE(float_debug1) +IREP_ID_ONE(float_debug2) +IREP_ID_ONE(static_assert) +IREP_ID_ONE(gcc_attribute_mode) +IREP_ID_TWO(built_in, ) +IREP_ID_ONE(exception_list) +IREP_ID_ONE(exception_id) +IREP_ID_ONE(priority) +IREP_ID_ONE(predicate_passive_symbol) +IREP_ID_ONE(all) +IREP_ID_ONE(when) +IREP_ID_ONE(cw_va_arg_typeof) +IREP_ID_ONE(fence) +IREP_ID_ONE(sync) +IREP_ID_ONE(lwsync) +IREP_ID_ONE(isync) +IREP_ID_ONE(WRfence) +IREP_ID_ONE(RRfence) +IREP_ID_ONE(RWfence) +IREP_ID_ONE(WWfence) +IREP_ID_ONE(RRcumul) +IREP_ID_ONE(RWcumul) +IREP_ID_ONE(WWcumul) +IREP_ID_ONE(WRcumul) +IREP_ID_ONE(claim) +IREP_ID_ONE(generic_selection) +IREP_ID_ONE(generic_associations) +IREP_ID_ONE(generic_association) +IREP_ID_ONE(floatbv_plus) +IREP_ID_ONE(floatbv_minus) +IREP_ID_ONE(floatbv_mult) +IREP_ID_ONE(floatbv_div) +IREP_ID_ONE(floatbv_rem) +IREP_ID_ONE(floatbv_sin) +IREP_ID_ONE(floatbv_cos) +IREP_ID_ONE(floatbv_typecast) +IREP_ID_ONE(read) +IREP_ID_ONE(write) +IREP_ID_ONE(native) +IREP_ID_ONE(final) +IREP_ID_ONE(compound_literal) +IREP_ID_ONE(custom_bv) +IREP_ID_ONE(custom_unsignedbv) +IREP_ID_ONE(custom_signedbv) +IREP_ID_ONE(custom_fixedbv) +IREP_ID_ONE(custom_floatbv) +IREP_ID_TWO(C_SSA_symbol, #SSA_symbol) +IREP_ID_TWO(C_full_identifier, #full_identifier) +IREP_ID_ONE(L0) +IREP_ID_ONE(L1) +IREP_ID_ONE(L2) +IREP_ID_ONE(L1_object_identifier) +IREP_ID_ONE(already_typechecked) +IREP_ID_TWO(C_va_arg_type, #va_arg_type) +IREP_ID_ONE(smt2_symbol) +IREP_ID_ONE(VHDL) +IREP_ID_ONE(Verilog) +IREP_ID_ONE(verilog_realtime) +IREP_ID_ONE(onehot) +IREP_ID_ONE(onehot0) +IREP_ID_ONE(verilog_star_event) +IREP_ID_ONE(verilog_attribute) +IREP_ID_ONE(time) +IREP_ID_ONE(fork) +IREP_ID_ONE(disable) +IREP_ID_ONE(wait) +IREP_ID_ONE(deassign) +IREP_ID_ONE(force) +IREP_ID_ONE(release) +IREP_ID_ONE(popcount) +IREP_ID_ONE(function_type) +IREP_ID_ONE(noreturn) +IREP_ID_TWO(C_noreturn, #noreturn) +IREP_ID_ONE(process) +IREP_ID_ONE(signal) +IREP_ID_ONE(weak) +IREP_ID_ONE(is_weak) +IREP_ID_TWO(C_spec_loop_invariant, #spec_loop_invariant) +IREP_ID_TWO(C_spec_requires, #spec_requires) +IREP_ID_TWO(C_spec_ensures, #spec_ensures) +IREP_ID_ONE(virtual_function) +IREP_ID_TWO(C_element_type, #element_type) +IREP_ID_ONE(working_directory) +IREP_ID_ONE(section) +IREP_ID_ONE(msb) +IREP_ID_ONE(lsb) +IREP_ID_ONE(verilog_signed_vector) +IREP_ID_ONE(verilog_unsigned_vector) +IREP_ID_ONE(verilog_array) +IREP_ID_ONE(low) +IREP_ID_ONE(high) +IREP_ID_ONE(bswap) +IREP_ID_ONE(java_bytecode_index) +IREP_ID_ONE(java_instanceof) +IREP_ID_ONE(java_super_method_call) +IREP_ID_ONE(java_enum_static_unwind) +IREP_ID_ONE(push_catch) +IREP_ID_ONE(string_constraint) +IREP_ID_ONE(string_not_contains_constraint) +IREP_ID_ONE(cprover_char_literal_func) +IREP_ID_ONE(cprover_string_literal_func) +IREP_ID_ONE(cprover_string_char_at_func) +IREP_ID_ONE(cprover_string_char_set_func) +IREP_ID_ONE(cprover_string_code_point_at_func) +IREP_ID_ONE(cprover_string_code_point_before_func) +IREP_ID_ONE(cprover_string_code_point_count_func) +IREP_ID_ONE(cprover_string_offset_by_code_point_func) +IREP_ID_ONE(cprover_string_compare_to_func) +IREP_ID_ONE(cprover_string_concat_func) +IREP_ID_ONE(cprover_string_concat_int_func) +IREP_ID_ONE(cprover_string_concat_long_func) +IREP_ID_ONE(cprover_string_concat_char_func) +IREP_ID_ONE(cprover_string_concat_bool_func) +IREP_ID_ONE(cprover_string_concat_double_func) +IREP_ID_ONE(cprover_string_concat_float_func) +IREP_ID_ONE(cprover_string_concat_code_point_func) +IREP_ID_ONE(cprover_string_contains_func) +IREP_ID_ONE(cprover_string_copy_func) +IREP_ID_ONE(cprover_string_delete_func) +IREP_ID_ONE(cprover_string_delete_char_at_func) +IREP_ID_ONE(cprover_string_equal_func) +IREP_ID_ONE(cprover_string_equals_ignore_case_func) +IREP_ID_ONE(cprover_string_empty_string_func) +IREP_ID_ONE(cprover_string_endswith_func) +IREP_ID_ONE(cprover_string_format_func) +IREP_ID_ONE(cprover_string_hash_code_func) +IREP_ID_ONE(cprover_string_index_of_func) +IREP_ID_ONE(cprover_string_intern_func) +IREP_ID_ONE(cprover_string_insert_func) +IREP_ID_ONE(cprover_string_insert_int_func) +IREP_ID_ONE(cprover_string_insert_long_func) +IREP_ID_ONE(cprover_string_insert_bool_func) +IREP_ID_ONE(cprover_string_insert_char_func) +IREP_ID_ONE(cprover_string_insert_float_func) +IREP_ID_ONE(cprover_string_insert_double_func) +IREP_ID_ONE(cprover_string_insert_char_array_func) +IREP_ID_ONE(cprover_string_is_prefix_func) +IREP_ID_ONE(cprover_string_is_suffix_func) +IREP_ID_ONE(cprover_string_is_empty_func) +IREP_ID_ONE(cprover_string_last_index_of_func) +IREP_ID_ONE(cprover_string_length_func) +IREP_ID_ONE(cprover_string_data_func) +IREP_ID_ONE(cprover_string_of_int_func) +IREP_ID_ONE(cprover_string_of_int_hex_func) +IREP_ID_ONE(cprover_string_of_long_func) +IREP_ID_ONE(cprover_string_of_bool_func) +IREP_ID_ONE(cprover_string_of_float_func) +IREP_ID_ONE(cprover_string_of_double_func) +IREP_ID_ONE(cprover_string_of_char_func) +IREP_ID_ONE(cprover_string_of_char_array_func) +IREP_ID_ONE(cprover_string_parse_int_func) +IREP_ID_ONE(cprover_string_replace_func) +IREP_ID_ONE(cprover_string_set_length_func) +IREP_ID_ONE(cprover_string_startswith_func) +IREP_ID_ONE(cprover_string_substring_func) +IREP_ID_ONE(cprover_string_to_char_array_func) +IREP_ID_ONE(cprover_string_to_lower_case_func) +IREP_ID_ONE(cprover_string_to_upper_case_func) +IREP_ID_ONE(cprover_string_trim_func) +IREP_ID_ONE(cprover_string_value_of_func) +IREP_ID_ONE(external_value_set) +IREP_ID_ONE(access_path_entry) +IREP_ID_ONE(access_path_label) +IREP_ID_ONE(access_path_function) +IREP_ID_ONE(access_path_loc) +IREP_ID_ONE(declared_on_type) + +#undef IREP_ID_ONE +#undef IREP_ID_TWO diff --git a/src/util/irep_ids.h b/src/util/irep_ids.h new file mode 100644 index 00000000000..50fc06314b5 --- /dev/null +++ b/src/util/irep_ids.h @@ -0,0 +1,40 @@ +/*******************************************************************\ + +Module: util + +Author: Reuben Thomas, reuben.thomas@me.com + +\*******************************************************************/ + +#ifndef CPROVER_UTIL_IREP_IDS_H +#define CPROVER_UTIL_IREP_IDS_H + +#define USE_DSTRING + +#ifdef USE_DSTRING +#include "dstring.h" +#endif + +enum class idt:unsigned +{ +#define IREP_ID_ONE(the_id) id_##the_id, +#define IREP_ID_TWO(the_id, str) id_##the_id, + +#include "irep_ids.def" +}; + +#ifdef USE_DSTRING + +#define IREP_ID_ONE(the_id) extern const dstringt ID_##the_id; +#define IREP_ID_TWO(the_id, str) extern const dstringt ID_##the_id; + +#else + +#define IREP_ID_ONE(the_id) extern const std::string ID_##the_id; +#define IREP_ID_TWO(the_id, str) extern const std::string ID_##the_id; + +#endif + +#include "irep_ids.def" // NOLINT(build/include) + +#endif diff --git a/src/util/irep_ids.txt b/src/util/irep_ids.txt deleted file mode 100644 index a119c085012..00000000000 --- a/src/util/irep_ids.txt +++ /dev/null @@ -1,813 +0,0 @@ -let -nil -type -operands -bool -c_bool -proper_bool -signedbv -unsignedbv -verilog_signedbv -verilog_unsignedbv -floatbv -fixedbv -x86_extended -C_source_location #source_location -C_end_location #end_location -C_is_padding #is_padding -file -line -column -comment -property -property_class -property_id -function -code -typecast -static_cast -dynamic_cast -const_cast -reinterpret_cast -index -index_range -ptrmember -member -member_name -C_member_name #member_name -equal = -implies => -iff <=> -and -nand -or -nor -xor -xnor -not -bitand -bitor -bitnot -bitxor -bitnand -bitnor -bitxnor -notequal -if -symbol -next_symbol -nondet_symbol -predicate -predicate_symbol -predicate_next_symbol -nondet_bool -empty -side_effect -statement -statement_expression -value -constant -block -decl -dead -assign -assign_div -assign_mult assign* -assign_plus assign+ -assign_minus assign- -assign_mod -assign_shl -assign_shr -assign_ashr -assign_lshr -assign_bitand -assign_bitxor -assign_bitor -assume -assert -assertion -goto -gcc_computed_goto -ifthenelse -label -break -continue -function_call -return -skip -arguments -array -size -pointer -block_pointer -switch -switch_case -gcc_switch_case_range -for -while -dowhile -int -integer -natural -real -rational -complex -signed -unsigned -asm -gcc_asm_input -gcc_asm_output -gcc_asm_clobbered_register -incomplete_array -incomplete_struct -incomplete_union -incomplete_class -incomplete_c_enum -C_incomplete #incomplete -identifier -name -cpp_name -component_cpp_name -C_id_class #id_class -declaration -declaration_list -declarator -struct -c_bit_field -union -class -merged_type -range -from -to -module -module_instance -macromodule -primitive_module_instance -module_items -module_source -parameter_decl -local_parameter_decl -parameter -component_name -component_number -tag -default -C_default_value #default_value -base_name -C_base_name #base_name -string -C_string_constant #string_constant -string_constant -width -components -bv -f -ports -port -offset -with -trans -throw -catch -try_catch -noexcept -CPROVER_throw -CPROVER_try_catch -CPROVER_try_finally -protection -private -public -protected -virtual -volatile -const -constexpr -inline -forall -exists -forever -repeat -extractbit -extractbits -reference -C_reference #reference -C_rvalue_reference #rvalue_reference -true -false -address_of -dereference -C_lvalue #lvalue -C_base #base -destination -main -expression -free -malloc -cpp_new -cpp_delete -cpp_new_array cpp_new[] -cpp_delete_array cpp_delete[] -java_new -java_new_array -java_string_literal -printf -input -output -output_register -inout -nondet -NULL -null -nullptr -c_enum -enumeration -elements -unknown -uninitialized -invalid -C_invalid_object #invalid_object -pointer_offset -pointer_object -invalid_pointer invalid-pointer -ieee_float_equal -ieee_float_notequal -isnan -lambda -array_of -array_equal -array_set -array_copy -mod -rem -shr -ashr -lshr -shl -rol -ror -comma -concatenation -infinity -return_type -typedef -extern -static -auto -register -thread_local -thread -C_thread_local #thread_local -C_static_lifetime #static_lifetime -mutable -void -int8 -int16 -int32 -int64 -ptr32 -ptr64 -char -short -long -longlong -float -double -byte -boolean -long_double -signed_char -unsigned_char -signed_int -unsigned_int -signed_long_int -unsigned_long_int -signed_short_int -unsigned_short_int -signed_long_long_int -unsigned_long_long_int -signed_int128 -unsigned_int128 -case -casex -casez -case_item -C_inlined #inlined -C_hide #hide -hide -abs -sign -access -C_access #access -postincrement -postdecrement -preincrement -predecrement -integer_bits -KnR -C_KnR #KnR -constraint_select_one -cond -bv_literals -isfinite -isinf -isnormal -AG -AF -AX -EG -EF -EX -U -R -A -F -E -G -X -continuous_assign -blocking_assign -non_blocking_assign -alignof -gcc_builtin_va_arg -gcc_builtin_types_compatible_p -gcc_builtin_va_arg_next -gcc_builtin_va_list -gcc_float80 -gcc_float128 -gcc_int128 -gcc_decimal32 -gcc_decimal64 -gcc_decimal128 -builtin_offsetof -0 -1 -8 -16 -32 -64 -128 -sizeof -type_arg -expr_arg -expression_list -initializer_list -gcc_conditional_expression -gcc_local_label -gcc -msc -typeof -ellipsis -flavor -ge >= -le <= -gt > -lt < -plus + -minus - -unary_minus unary- -unary_plus unary+ -mult * -div / -power ** -factorial_power -component -pretty_name -C_class #class -C_interface #interface -interface -targets -location -labels -event -guard -designated_initializer -designator -member_designator -index_designator -offset_designator -C_constant #constant -C_volatile #volatile -C_restricted #restricted -C_identifier #identifier -C_implicit #implicit -C_ptr32 #ptr32 -C_ptr64 #ptr64 -C_atomic #atomic -restrict -byte_extract_big_endian -byte_extract_little_endian -byte_update_big_endian -byte_update_little_endian -replication -dummy -init -cprover_atomic -atomic -atomic_type_specifier -atomic_begin -atomic_end -start_thread -end_thread -specc_notify -specc_par -specc_wait -specc_event -bp_enforce -bp_abortif -bp_constrain -bp_schoose -bp_dead -instance -cover -coverage_criterion -initializer -anonymous -C_is_anonymous #is_anonymous -is_macro -is_enum_constant -is_inline -is_extern -is_global -is_thread_local -is_parameter -is_member -is_type -is_register -is_typedef -is_static -is_template -is_static_assert -is_virtual -C_is_virtual #is_virtual -literal -member_initializers -member_initializer -method_qualifier -methods -constructor -destructor -bases -base -from_base -operator -template -template_class_instance -template_function_instance -template_type -template_args -template_parameter -template_parameters -C_template #template -C_template_arguments #template_arguments -typename -C -cpp -java -SpecC -SystemC -decl_block -decl_type -genvar -realtime -parameters -parameter_assignments -named_parameter_assignment -specify -pullup -pulldown -automatic -rcmos -cmos -nmos -pmos -rnmos -rpmos -wchar_t -char16_t -char32_t -size_t -ssize_t -inst -inst_builtin -always -initial -mode -this -C_this #this -reduction_and -reduction_or -reduction_nand -reduction_nor -reduction_xor -reduction_xnor -C_zero_initializer #zero_initializer -body -entity -temporary_object -overflow_plus overflow-+ -overflow_minus overflow-- -overflow_mult overflow-* -overflow_unary_minus overflow-unary- -object_descriptor -dynamic_object -is_most_recent_allocation -most_recent_allocation -any_allocation -object_size -good_pointer -integer_address -integer_address_object -null_object -static_object -stack_object -C_is_failed_symbol #is_failed_symbol -C_failed_symbol #failed_symbol -list -map -set -storage -friend -explicit -storage_spec -member_spec -msc_declspec -packed -C_packed #packed -transparent_union -C_transparent_union #transparent_union -aligned -C_alignment #alignment -vector -abstract -bit -logic -chandle -reg -wire -tri -tri1 -supply0 -wand -triand -tri0 -supply1 -wor -trior -trireg -function_application -cpp_declarator -cpp_linkage_spec -cpp_namespace_spec -cpp_storage_spec -cpp_using -cpp_declaration -cpp_static_assert -cpp_member_spec -C_c_type #c_type -namespace -linkage -decltype -buf -bufif0 -bufif1 -notif0 -notif1 -task -C_little_endian #little_endian -C_offset #offset -C_tag_only_declaration #tag_only_declaration -struct_tag -union_tag -c_enum_tag -enum_constant -bit_select -part_select -indexed_part_select_plus -indexed_part_select_minus -generate_block -generate_assign -generate_skip -generate_case -generate_if -generate_for -delay -verilog_cycle_delay -sva_cycle_delay -sva_sequence_throughout -sva_sequence_concatenation -sva_sequence_first_match -sva_always -sva_nexttime -sva_s_nexttime -sva_eventually -sva_s_eventually -sva_until -sva_s_until -sva_until_with -sva_s_until_with -sva_overlapped_implication -sva_non_overlapped_implication -hierarchical_identifier -named_port_connection -named_block -verilog_primitive_module -verilog_module -verilog_case_equality -verilog_case_inequality -event_guard -posedge -negedge -pointer_and_address_pair -user_specified_predicate -user_specified_parameter_predicates -user_specified_return_predicates -unassigned -new_object -complex_real -complex_imag -imag -msc_try_except -msc_try_finally -msc_leave -msc_uuidof -msc_if_exists -msc_if_not_exists -msc_underlying_type -msc_based -alias -auto_object -ssa_object -ptr_object -C_c_sizeof_type #c_sizeof_type -array_update -struct_update -union_update -update -float_debug1 -float_debug2 -static_assert -gcc_attribute_mode -built_in -exception_list -exception_id -priority -predicate_passive_symbol -all -when -cw_va_arg_typeof -fence -sync -lwsync -isync -WRfence -RRfence -RWfence -WWfence -RRcumul -RWcumul -WWcumul -WRcumul -claim -generic_selection -generic_associations -generic_association -floatbv_plus -floatbv_minus -floatbv_mult -floatbv_div -floatbv_rem -floatbv_sin -floatbv_cos -floatbv_typecast -read -write -native -final -_start -compound_literal -custom_bv -custom_unsignedbv -custom_signedbv -custom_fixedbv -custom_floatbv -C_SSA_symbol #SSA_symbol -C_full_identifier #full_identifier -L0 -L1 -L2 -L1_object_identifier -already_typechecked -C_va_arg_type #va_arg_type -smt2_symbol -VHDL -Verilog -verilog_realtime -onehot -onehot0 -verilog_star_event -verilog_attribute -time -fork -disable -wait -deassign -force -release -popcount -function_type -noreturn -C_noreturn #noreturn -process -signal -weak -is_weak -C_spec_loop_invariant #spec_loop_invariant -C_spec_requires #spec_requires -C_spec_ensures #spec_ensures -virtual_function -C_element_type #element_type -working_directory -section -msb -lsb -verilog_signed_vector -verilog_unsigned_vector -verilog_array -low -high -bswap -java_bytecode_index -java_instanceof -java_super_method_call -java_enum_static_unwind -push_catch -string_constraint -string_not_contains_constraint -cprover_char_literal_func -cprover_string_literal_func -cprover_string_char_at_func -cprover_string_char_set_func -cprover_string_code_point_at_func -cprover_string_code_point_before_func -cprover_string_code_point_count_func -cprover_string_offset_by_code_point_func -cprover_string_compare_to_func -cprover_string_concat_func -cprover_string_concat_int_func -cprover_string_concat_long_func -cprover_string_concat_char_func -cprover_string_concat_bool_func -cprover_string_concat_double_func -cprover_string_concat_float_func -cprover_string_concat_code_point_func -cprover_string_contains_func -cprover_string_copy_func -cprover_string_delete_func -cprover_string_delete_char_at_func -cprover_string_equal_func -cprover_string_equals_ignore_case_func -cprover_string_empty_string_func -cprover_string_endswith_func -cprover_string_format_func -cprover_string_hash_code_func -cprover_string_index_of_func -cprover_string_intern_func -cprover_string_insert_func -cprover_string_insert_int_func -cprover_string_insert_long_func -cprover_string_insert_bool_func -cprover_string_insert_char_func -cprover_string_insert_float_func -cprover_string_insert_double_func -cprover_string_insert_char_array_func -cprover_string_is_prefix_func -cprover_string_is_suffix_func -cprover_string_is_empty_func -cprover_string_last_index_of_func -cprover_string_length_func -cprover_string_data_func -cprover_string_of_int_func -cprover_string_of_int_hex_func -cprover_string_of_long_func -cprover_string_of_bool_func -cprover_string_of_float_func -cprover_string_of_double_func -cprover_string_of_char_func -cprover_string_of_char_array_func -cprover_string_parse_int_func -cprover_string_replace_func -cprover_string_set_length_func -cprover_string_startswith_func -cprover_string_substring_func -cprover_string_to_char_array_func -cprover_string_to_lower_case_func -cprover_string_to_upper_case_func -cprover_string_trim_func -cprover_string_value_of_func -external_value_set -access_path_entry -access_path_label -access_path_function -access_path_loc -declared_on_type diff --git a/src/util/irep_ids_convert.cpp b/src/util/irep_ids_convert.cpp deleted file mode 100644 index b55a3e7a96a..00000000000 --- a/src/util/irep_ids_convert.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/*******************************************************************\ - -Module: Build pre-initialized entries for C-string container - -Author: Daniel Kroening, kroening@kroening.com - -\*******************************************************************/ - -#include -#include - -#define USE_DSTRING - -int main(int argc, const char **argv) -{ - if(argc!=2) - return 1; - - std::cout << "// Generated by irep_ids_convert" - << std::endl << std::endl; - - if(std::string(argv[1])=="header") - { - std::string line; - - std::cout << "#ifndef CPROVER_UTIL_IREP_IDS_H" << std::endl; - std::cout << "#define CPROVER_UTIL_IREP_IDS_H" << std::endl; - std::cout << std::endl; - - unsigned count=1; - - while(getline(std::cin, line)) - { - if(line=="") - continue; - - std::cout << "#define ID_"; - - std::size_t pos=line.find(' '); - -#ifdef USE_DSTRING - if(pos==std::string::npos) - std::cout << line - << " dstringt(" << count << ", 0)"; - else - std::cout << std::string(line, 0, pos) - << " dstringt(" << count << ", 0)" - << " // " - << std::string(line, pos+1, std::string::npos); -#else - if(pos==std::string::npos) - std::cout << line - << " \"" << line << "\""; - else - std::cout << std::string(line, 0, pos) - << " \"" << std::string(line, 0, pos) << "\"" - << " // " - << std::string(line, pos+1, std::string::npos); -#endif - - std::cout << std::endl; - - count++; - } - - std::cout << std::endl; - std::cout << "#endif" << std::endl; - } - else if(std::string(argv[1])=="table") - { - std::string line; - - std::cout << " \"\"," << std::endl; - - while(getline(std::cin, line)) - { - if(line=="") - continue; - - std::cout << " \""; - - std::size_t pos=line.find(' '); - - if(pos==std::string::npos) - std::cout << line << "\","; - else - std::cout << std::string(line, pos+1, std::string::npos) - << "\", // ID_" - << std::string(line, 0, pos); - - std::cout << std::endl; - } - } - - return 0; -} diff --git a/src/util/symbol_table.cpp b/src/util/symbol_table.cpp index 970801802b4..37053b7737b 100644 --- a/src/util/symbol_table.cpp +++ b/src/util/symbol_table.cpp @@ -14,11 +14,14 @@ Author: Daniel Kroening, kroening@kroening.com Function: symbol_tablet::add - Inputs: + Inputs: + symbol - The symbol to be added to the symbol table - Outputs: + Outputs: Returns a boolean indicating whether the process failed, + which should only happen if there is a symbol with the same + name already in the symbol table - Purpose: + Purpose: Add a new symbol to the symbol table \*******************************************************************/ @@ -39,11 +42,28 @@ bool symbol_tablet::add(const symbolt &symbol) Function: symbol_tablet::move - Inputs: - - Outputs: - - Purpose: + Inputs: + symbol - The symbol to be added to the symbol table + new_symbol - Pointer which the function will set to either point + to the symbol in the symbol table with the same name + or to the symbol that has been successfully moved + into the symbol table + + Outputs: Returns a boolean indicating whether the process failed, + which should only happen if there is a symbol with the + same name already in the symbol table. If the process + failed then symbol is unchanged and new_symbol points to + the symbol with the same name. If the process succeeded + symbol is set to be empty and new_symbol points to its new + location in the symbol table + + Purpose: Move a symbol into the symbol table. If there is already + a symbol with the same name then symbol is unchanged, + new_symbol points to the symbol with the same name and + true is returned. Otherwise, the symbol is moved into the + symbol table, symbol is set to be empty, new_symbol points + to its new location in the symbol table and false is + returned \*******************************************************************/ @@ -75,11 +95,12 @@ bool symbol_tablet::move(symbolt &symbol, symbolt *&new_symbol) Function: symbol_tablet::remove - Inputs: + Inputs: + name - The name of the symbol to remove - Outputs: + Outputs: Returns a boolean indicating whether the process failed - Purpose: + Purpose: Remove a symbol from the symbol table \*******************************************************************/ @@ -121,11 +142,12 @@ bool symbol_tablet::remove(const irep_idt &name) Function: symbol_tablet::show - Inputs: + Inputs: + out - The ostream to direct output to Outputs: - Purpose: + Purpose: Print the contents of the symbol table \*******************************************************************/ @@ -141,11 +163,13 @@ void symbol_tablet::show(std::ostream &out) const Function: symbol_tablet::lookup - Inputs: + Inputs: + identifier - The name of the symbol to look for - Outputs: + Outputs: The symbol in the symbol table with the correct name - Purpose: + Purpose: Find a symbol in the symbol table. Throws a string if no + such symbol is found. \*******************************************************************/ @@ -163,11 +187,13 @@ const symbolt &symbol_tablet::lookup(const irep_idt &identifier) const Function: symbol_tablet::lookup - Inputs: + Inputs: + identifier - The name of the symbol to look for - Outputs: + Outputs: The symbol in the symbol table with the correct name - Purpose: + Purpose: Find a symbol in the symbol table. Throws a string if no + such symbol is found. \*******************************************************************/ @@ -185,11 +211,13 @@ symbolt &symbol_tablet::lookup(const irep_idt &identifier) Function: operator << - Inputs: + Inputs: + out - The ostream to direct output to + symbol_table - The symbol table to print out Outputs: - Purpose: + Purpose: Print the contents of the symbol table \*******************************************************************/