adlint 2.6.14 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +1 -3
- data/ChangeLog +511 -0
- data/INSTALL +1 -1
- data/MANIFEST +57 -37
- data/NEWS +36 -7
- data/README +2 -2
- data/Rakefile +6 -6
- data/TODO +1 -1
- data/bin/adlint +25 -16
- data/bin/adlint_chk +22 -12
- data/bin/adlint_cma +17 -12
- data/bin/adlint_sma +22 -12
- data/bin/adlintize +98 -17
- data/etc/conf.d/fallback/cinit.erb +1 -1
- data/etc/conf.d/fallback/traits.erb +37 -37
- data/etc/conf.d/i686-cygwin/cinit-gcc_4.3.4.erb +1 -1
- data/etc/conf.d/i686-cygwin/traits-gcc_4.3.4.erb +41 -41
- data/etc/conf.d/i686-devkit/cinit-gcc_4.5.2.erb +1 -1
- data/etc/conf.d/i686-devkit/traits-gcc_4.5.2.erb +40 -40
- data/etc/conf.d/i686-linux/cinit-gcc_4.5.1.erb +1 -1
- data/etc/conf.d/i686-linux/traits-gcc_4.5.1.erb +40 -40
- data/etc/conf.d/i686-mingw/cinit-gcc_4.6.1.erb +1 -1
- data/etc/conf.d/i686-mingw/traits-gcc_4.6.1.erb +40 -40
- data/etc/conf.d/noarch/GNUmakefile.erb +1 -1
- data/etc/conf.d/noarch/adlint_all_bat.erb +1 -1
- data/etc/conf.d/noarch/adlint_all_sh.erb +1 -1
- data/etc/conf.d/noarch/pinit.erb +1 -1
- data/etc/conf.d/x86_64-ubuntu_12.04/cinit-gcc_4.6.3.erb +1 -1
- data/etc/conf.d/x86_64-ubuntu_12.04/traits-gcc_4.6.3.erb +42 -42
- data/etc/mesg.d/c_builtin/en_US/messages.yml +33 -33
- data/etc/mesg.d/c_builtin/ja_JP/messages.yml +5 -5
- data/etc/mesg.d/core/en_US/messages.yml +2 -2
- data/etc/mesg.d/core/ja_JP/messages.yml +2 -2
- data/features/code_check/W0018.feature +197 -0
- data/features/code_check/W0019.feature +79 -0
- data/features/code_check/W0021.feature +81 -0
- data/features/code_check/W0023.feature +203 -0
- data/features/code_check/W0024.feature +226 -0
- data/features/code_check/W0025.feature +5 -0
- data/features/code_check/W0088.feature +2 -2
- data/features/code_check/W0109.feature +2 -2
- data/features/code_check/W0477.feature +0 -3
- data/features/code_check/W0478.feature +0 -1
- data/features/code_check/W0582.feature +3 -3
- data/features/code_check/W0583.feature +4 -7
- data/features/code_check/W0646.feature +0 -1
- data/features/code_check/W0695.feature +0 -1
- data/features/code_check/W0705.feature +8 -0
- data/features/code_check/W0723.feature +0 -1
- data/features/code_check/W0745.feature +1 -0
- data/features/code_check/W0781.feature +1 -0
- data/features/code_check/W1057.feature +141 -0
- data/features/code_check/W1058.feature +93 -0
- data/features/code_check/W1059.feature +86 -0
- data/features/code_check/W1060.feature +77 -0
- data/features/code_check/W1061.feature +143 -0
- data/features/code_check/W1062.feature +162 -0
- data/features/code_check/W1063.feature +123 -0
- data/features/code_check/W1064.feature +83 -0
- data/features/code_check/W1065.feature +82 -0
- data/features/code_check/W9003.feature +2 -0
- data/features/step_definitions/code_check_steps.rb +1 -0
- data/features/support/env.rb +16 -13
- data/lib/adlint.rb +7 -4
- data/lib/adlint/analyzer.rb +131 -157
- data/lib/adlint/annot.rb +149 -0
- data/lib/adlint/cc1.rb +57 -0
- data/lib/adlint/{c → cc1}/branch.rb +74 -62
- data/lib/adlint/{c → cc1}/builtin.rb +21 -21
- data/lib/adlint/{c → cc1}/const.rb +119 -117
- data/lib/adlint/{c → cc1}/conv.rb +76 -78
- data/lib/adlint/{c → cc1}/ctrlexpr.rb +69 -86
- data/lib/adlint/cc1/domain.rb +8103 -0
- data/lib/adlint/{c → cc1}/enum.rb +3 -3
- data/lib/adlint/{c → cc1}/environ.rb +21 -21
- data/lib/adlint/{c → cc1}/expr.rb +232 -218
- data/lib/adlint/{c → cc1}/format.rb +305 -342
- data/lib/adlint/{c → cc1}/interp.rb +269 -220
- data/lib/adlint/cc1/lexer.rb +246 -0
- data/lib/adlint/{c → cc1}/mediator.rb +78 -84
- data/lib/adlint/{c → cc1}/object.rb +261 -264
- data/lib/adlint/{c → cc1}/operator.rb +7 -7
- data/lib/adlint/{c → cc1}/option.rb +4 -3
- data/lib/adlint/{c → cc1}/parser.rb +274 -506
- data/lib/adlint/{c → cc1}/parser.y +69 -301
- data/lib/adlint/cc1/phase.rb +138 -0
- data/lib/adlint/{c → cc1}/resolver.rb +66 -78
- data/lib/adlint/{c → cc1}/scanner.rb +57 -49
- data/lib/adlint/{c → cc1}/scope.rb +3 -3
- data/lib/adlint/{c → cc1}/seqp.rb +13 -5
- data/lib/adlint/{c → cc1}/syntax.rb +819 -1122
- data/lib/adlint/{c → cc1}/type.rb +1498 -1479
- data/lib/adlint/{c → cc1}/util.rb +20 -12
- data/lib/adlint/{c → cc1}/value.rb +699 -642
- data/lib/adlint/code.rb +163 -164
- data/lib/adlint/cpp.rb +2 -2
- data/lib/adlint/cpp/asm.rb +13 -14
- data/lib/adlint/cpp/constexpr.rb +42 -38
- data/lib/adlint/cpp/constexpr.y +44 -40
- data/lib/adlint/cpp/eval.rb +435 -435
- data/lib/adlint/cpp/lexer.rb +343 -340
- data/lib/adlint/cpp/macro.rb +188 -190
- data/lib/adlint/cpp/phase.rb +66 -45
- data/lib/adlint/cpp/scanner.rb +14 -17
- data/lib/adlint/cpp/source.rb +49 -55
- data/lib/adlint/cpp/subst.rb +65 -65
- data/lib/adlint/cpp/syntax.rb +155 -275
- data/lib/adlint/cpp/util.rb +22 -19
- data/lib/adlint/driver.rb +86 -93
- data/lib/adlint/error.rb +33 -52
- data/lib/adlint/exam.rb +158 -24
- data/lib/adlint/exam/c_builtin.rb +7 -7
- data/lib/adlint/exam/c_builtin/cc1_check.rb +20522 -0
- data/lib/adlint/exam/c_builtin/cc1_check_shima.rb +957 -0
- data/lib/adlint/exam/c_builtin/cc1_code.rb +459 -0
- data/lib/adlint/exam/c_builtin/cc1_metric.rb +794 -0
- data/lib/adlint/exam/c_builtin/cpp_check.rb +486 -441
- data/lib/adlint/exam/c_builtin/cpp_check_shima.rb +36 -39
- data/lib/adlint/exam/c_builtin/cpp_code.rb +63 -65
- data/lib/adlint/exam/c_builtin/ld_check.rb +136 -129
- data/lib/adlint/exam/c_builtin/ld_metric.rb +11 -11
- data/lib/adlint/lang.rb +25 -25
- data/lib/adlint/ld.rb +2 -2
- data/lib/adlint/ld/object.rb +220 -188
- data/lib/adlint/ld/phase.rb +94 -63
- data/lib/adlint/ld/typedef.rb +22 -11
- data/lib/adlint/ld/util.rb +43 -35
- data/lib/adlint/lexer.rb +59 -56
- data/lib/adlint/location.rb +140 -0
- data/lib/adlint/memo.rb +157 -0
- data/lib/adlint/message.rb +207 -156
- data/lib/adlint/metric.rb +139 -217
- data/lib/adlint/monitor.rb +45 -43
- data/lib/adlint/phase.rb +56 -29
- data/lib/adlint/prelude.rb +66 -54
- data/lib/adlint/report.rb +253 -332
- data/lib/adlint/source.rb +26 -27
- data/lib/adlint/supp.rb +131 -0
- data/lib/adlint/symbol.rb +14 -16
- data/lib/adlint/token.rb +19 -91
- data/lib/adlint/traits.rb +242 -226
- data/lib/adlint/util.rb +116 -205
- data/lib/adlint/version.rb +8 -8
- data/share/HEADER +2 -2
- data/share/doc/developers_guide_ja.html +148 -19
- data/share/doc/developers_guide_ja.texi +141 -11
- data/share/doc/samples/GNUmakefile +1 -1
- data/share/doc/samples/adlint_traits.yml +45 -36
- data/share/doc/users_guide_en.html +1321 -1252
- data/share/doc/users_guide_en.texi +475 -408
- data/share/doc/users_guide_ja.html +1932 -1878
- data/share/doc/users_guide_ja.texi +324 -273
- data/share/sample/bison-2.5/adlint/GNUmakefile +5 -1
- data/share/sample/bison-2.5/adlint/adlint_traits.yml +38 -38
- data/share/sample/bison-2.5/adlint/lib/GNUmakefile +1 -1
- data/share/sample/bison-2.5/adlint/lib/adlint_cinit.h +1 -1
- data/share/sample/bison-2.5/adlint/lib/adlint_pinit.h +1 -1
- data/share/sample/bison-2.5/adlint/lib/adlint_traits.yml +50 -42
- data/share/sample/bison-2.5/adlint/src/GNUmakefile +1 -1
- data/share/sample/bison-2.5/adlint/src/adlint_cinit.h +1 -1
- data/share/sample/bison-2.5/adlint/src/adlint_pinit.h +1 -1
- data/share/sample/bison-2.5/adlint/src/adlint_traits.yml +50 -42
- data/share/sample/ctags-5.8/adlint/GNUmakefile +1 -1
- data/share/sample/ctags-5.8/adlint/adlint_cinit.h +1 -1
- data/share/sample/ctags-5.8/adlint/adlint_pinit.h +1 -1
- data/share/sample/ctags-5.8/adlint/adlint_traits.yml +50 -42
- data/share/sample/flex-2.5.35/adlint/GNUmakefile +1 -1
- data/share/sample/flex-2.5.35/adlint/adlint_cinit.h +1 -1
- data/share/sample/flex-2.5.35/adlint/adlint_pinit.h +1 -1
- data/share/sample/flex-2.5.35/adlint/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/adlint_traits.yml +46 -38
- data/share/sample/ruby-1.9.3-p0/adlint/core/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/enc/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_traits.yml +50 -42
- data/share/sample/screen-4.0.3/adlint/GNUmakefile +1 -1
- data/share/sample/screen-4.0.3/adlint/adlint_cinit.h +1 -1
- data/share/sample/screen-4.0.3/adlint/adlint_pinit.h +1 -1
- data/share/sample/screen-4.0.3/adlint/adlint_traits.yml +50 -42
- data/share/sample/vim-7.3/adlint/vim/GNUmakefile +1 -1
- data/share/sample/vim-7.3/adlint/vim/adlint_cinit.h +1 -1
- data/share/sample/vim-7.3/adlint/vim/adlint_pinit.h +1 -1
- data/share/sample/vim-7.3/adlint/vim/adlint_traits.yml +50 -42
- data/share/sample/vim-7.3/adlint/xxd/GNUmakefile +1 -1
- data/share/sample/vim-7.3/adlint/xxd/adlint_cinit.h +1 -1
- data/share/sample/vim-7.3/adlint/xxd/adlint_pinit.h +1 -1
- data/share/sample/vim-7.3/adlint/xxd/adlint_traits.yml +49 -41
- data/share/sample/zsh-4.3.15/adlint/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/adlint_traits.yml +46 -38
- data/share/sample/zsh-4.3.15/adlint/builtins/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_traits.yml +50 -42
- data/share/sample/zsh-4.3.15/adlint/core/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/core/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/core/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/core/adlint_traits.yml +50 -42
- data/share/sample/zsh-4.3.15/adlint/modules/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_traits.yml +50 -42
- data/share/sample/zsh-4.3.15/adlint/zle/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_traits.yml +50 -42
- data/spec/adlint/{c → cc1}/ctrlexpr_spec.rb +51 -49
- data/spec/adlint/{c → cc1}/domain_spec.rb +210 -179
- data/spec/adlint/{c → cc1}/operator_spec.rb +3 -3
- data/spec/adlint/{c → cc1}/syntax_spec.rb +10 -12
- data/spec/adlint/{c → cc1}/type_spec.rb +61 -68
- data/{lib/adlint/c.rb → spec/adlint/location_spec.rb} +24 -29
- data/spec/conf.d/default_traits.yml +38 -37
- data/spec/conf.d/empty_cinit.h +1 -1
- data/spec/conf.d/empty_pinit.h +1 -1
- data/spec/conf.d/project/foo.c +0 -0
- data/spec/spec_helper.rb +2 -2
- metadata +60 -40
- data/lib/adlint/c/domain.rb +0 -7931
- data/lib/adlint/c/lexer.rb +0 -252
- data/lib/adlint/c/phase.rb +0 -135
- data/lib/adlint/exam/c_builtin/c_check.rb +0 -20745
- data/lib/adlint/exam/c_builtin/c_check_shima.rb +0 -983
- data/lib/adlint/exam/c_builtin/c_code.rb +0 -477
- data/lib/adlint/exam/c_builtin/c_metric.rb +0 -818
@@ -0,0 +1,957 @@
|
|
1
|
+
# Code checkings (cc1-phase) of adlint-exam-c_builtin package.
|
2
|
+
#
|
3
|
+
# Author:: Rie Shima <mailto:rkakuuchi@users.sourceforge.net>
|
4
|
+
# Copyright:: Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
5
|
+
# License:: GPLv3+: GNU General Public License version 3 or later
|
6
|
+
#
|
7
|
+
# Owner:: Rie Shima <mailto:rkakuuchi@users.sourceforge.net>
|
8
|
+
|
9
|
+
#--
|
10
|
+
# ___ ____ __ ___ _________
|
11
|
+
# / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
|
12
|
+
# / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
|
13
|
+
# / __ |/ /_/ / /___/ / /| / / /
|
14
|
+
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
15
|
+
#
|
16
|
+
# This file is part of AdLint.
|
17
|
+
#
|
18
|
+
# AdLint is free software: you can redistribute it and/or modify it under the
|
19
|
+
# terms of the GNU General Public License as published by the Free Software
|
20
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
21
|
+
# version.
|
22
|
+
#
|
23
|
+
# AdLint is distributed in the hope that it will be useful, but WITHOUT ANY
|
24
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
25
|
+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
26
|
+
#
|
27
|
+
# You should have received a copy of the GNU General Public License along with
|
28
|
+
# AdLint. If not, see <http://www.gnu.org/licenses/>.
|
29
|
+
#
|
30
|
+
#++
|
31
|
+
|
32
|
+
require "adlint/exam"
|
33
|
+
require "adlint/report"
|
34
|
+
require "adlint/cc1/phase"
|
35
|
+
require "adlint/cc1/syntax"
|
36
|
+
require "adlint/cc1/format"
|
37
|
+
|
38
|
+
module AdLint #:nodoc:
|
39
|
+
module Exam #:nodoc:
|
40
|
+
module CBuiltin #:nodoc:
|
41
|
+
|
42
|
+
class W0573 < PassiveCodeCheck
|
43
|
+
def_registrant_phase Cc1::Prepare2Phase
|
44
|
+
|
45
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
46
|
+
# step-in analysis is supported.
|
47
|
+
mark_as_unique
|
48
|
+
|
49
|
+
def initialize(phase_ctxt)
|
50
|
+
super
|
51
|
+
interp = phase_ctxt[:cc1_interpreter]
|
52
|
+
interp.on_function_call_expr_evaled += T(:check)
|
53
|
+
@environ = interp.environment
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
def check(funcall_expr, fun, arg_vars, *)
|
58
|
+
if fun.named? && fun.name =~ /\A.*scanf\z/
|
59
|
+
fmt = create_format(funcall_expr, format_str_index_of(funcall_expr),
|
60
|
+
arg_vars, @environ)
|
61
|
+
return unless fmt
|
62
|
+
|
63
|
+
fmt.conversion_specifiers.each do |conv_spec|
|
64
|
+
if conv_spec.scanset && conv_spec.scanset.include?("-")
|
65
|
+
W(fmt.location)
|
66
|
+
break
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def format_str_index_of(funcall_expr)
|
73
|
+
funcall_expr.argument_expressions.index do |arg_expr|
|
74
|
+
arg_expr.kind_of?(Cc1::StringLiteralSpecifier)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def create_format(funcall_expr, fmt_str_idx, arg_vars, env)
|
79
|
+
if fmt_str_idx
|
80
|
+
fmt_str = funcall_expr.argument_expressions[fmt_str_idx]
|
81
|
+
if fmt_str && fmt_str.literal.value =~ /\AL?"(.*)"\z/i
|
82
|
+
trailing_args = arg_vars[(fmt_str_idx + 1)..-1] || []
|
83
|
+
return Cc1::ScanfFormat.new($1, fmt_str.location, trailing_args, env)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
nil
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class W0606 < PassiveCodeCheck
|
91
|
+
def_registrant_phase Cc1::Prepare2Phase
|
92
|
+
|
93
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
94
|
+
# step-in analysis is supported.
|
95
|
+
mark_as_unique
|
96
|
+
|
97
|
+
def initialize(phase_ctxt)
|
98
|
+
super
|
99
|
+
visitor = phase_ctxt[:cc1_visitor]
|
100
|
+
visitor.enter_union_type_declaration += T(:check)
|
101
|
+
end
|
102
|
+
|
103
|
+
private
|
104
|
+
def check(node)
|
105
|
+
node.struct_declarations.each do |struct_dcl|
|
106
|
+
struct_dcl.items.each do |memb_dcl|
|
107
|
+
if memb_dcl.type.scalar? && memb_dcl.type.floating?
|
108
|
+
W(node.location)
|
109
|
+
return
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
class W0645 < PassiveCodeCheck
|
117
|
+
def_registrant_phase Cc1::Prepare2Phase
|
118
|
+
|
119
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
120
|
+
# step-in analysis is supported.
|
121
|
+
mark_as_unique
|
122
|
+
|
123
|
+
def initialize(phase_ctxt)
|
124
|
+
super
|
125
|
+
visitor = phase_ctxt[:cc1_visitor]
|
126
|
+
visitor.enter_kandr_function_definition += T(:check)
|
127
|
+
end
|
128
|
+
|
129
|
+
def check(node)
|
130
|
+
if node.type.parameter_types.any? { |type| type.void? }
|
131
|
+
W(node.location)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
class W0685 < W0573
|
137
|
+
def_registrant_phase Cc1::Prepare2Phase
|
138
|
+
|
139
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
140
|
+
# step-in analysis is supported.
|
141
|
+
mark_as_unique
|
142
|
+
|
143
|
+
def check(funcall_expr, fun, arg_vars, *)
|
144
|
+
if fun.named? && fun.name =~ /\A.*scanf\z/
|
145
|
+
fmt = create_format(funcall_expr, format_str_index_of(funcall_expr),
|
146
|
+
arg_vars, @environ)
|
147
|
+
return unless fmt
|
148
|
+
|
149
|
+
fmt.conversion_specifiers.each do |conv_spec|
|
150
|
+
if conv_spec.scanset
|
151
|
+
conv_spec.scanset.scan(/(.)-(.)/).each do |lhs, rhs|
|
152
|
+
W(fmt.location) if lhs.ord > rhs.ord
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
class W0686 < W0573
|
161
|
+
def_registrant_phase Cc1::Prepare2Phase
|
162
|
+
|
163
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
164
|
+
# step-in analysis is supported.
|
165
|
+
mark_as_unique
|
166
|
+
|
167
|
+
def check(funcall_expr, fun, arg_vars, *)
|
168
|
+
if fun.named? && fun.name =~ /\A.*scanf\z/
|
169
|
+
fmt = create_format(funcall_expr, format_str_index_of(funcall_expr),
|
170
|
+
arg_vars, @environ)
|
171
|
+
return unless fmt
|
172
|
+
|
173
|
+
fmt.conversion_specifiers.each do |conv_spec|
|
174
|
+
if conv_spec.scanset
|
175
|
+
W(fmt.location) unless conv_spec.valid_scanset?
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
class W0697 < PassiveCodeCheck
|
183
|
+
def_registrant_phase Cc1::Prepare2Phase
|
184
|
+
|
185
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
186
|
+
# step-in analysis is supported.
|
187
|
+
mark_as_unique
|
188
|
+
|
189
|
+
def initialize(phase_ctxt)
|
190
|
+
super
|
191
|
+
interp = phase_ctxt[:cc1_interpreter]
|
192
|
+
interp.on_function_started += T(:start_function)
|
193
|
+
interp.on_function_ended += T(:end_function)
|
194
|
+
interp.on_implicit_return_evaled += M(:check_implicit_return)
|
195
|
+
@cur_fun = nil
|
196
|
+
end
|
197
|
+
|
198
|
+
private
|
199
|
+
def start_function(fun_def, *)
|
200
|
+
@cur_fun = fun_def
|
201
|
+
end
|
202
|
+
|
203
|
+
def end_function(*)
|
204
|
+
@cur_fun = nil
|
205
|
+
end
|
206
|
+
|
207
|
+
def check_implicit_return(loc)
|
208
|
+
if @cur_fun && loc.in_analysis_target?(traits)
|
209
|
+
unless @cur_fun.type.return_type.void?
|
210
|
+
W(@cur_fun.location, @cur_fun.identifier.value)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
class W0698 < PassiveCodeCheck
|
217
|
+
def_registrant_phase Cc1::Prepare2Phase
|
218
|
+
|
219
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
220
|
+
# step-in analysis is supported.
|
221
|
+
mark_as_unique
|
222
|
+
|
223
|
+
def initialize(phase_ctxt)
|
224
|
+
super
|
225
|
+
visitor = phase_ctxt[:cc1_visitor]
|
226
|
+
visitor.enter_ansi_function_definition += T(:start_function)
|
227
|
+
visitor.enter_kandr_function_definition += T(:start_function)
|
228
|
+
visitor.leave_ansi_function_definition += T(:end_function)
|
229
|
+
visitor.leave_kandr_function_definition += T(:end_function)
|
230
|
+
visitor.enter_return_statement += T(:check)
|
231
|
+
@cur_fun = nil
|
232
|
+
end
|
233
|
+
|
234
|
+
private
|
235
|
+
def start_function(fun_def)
|
236
|
+
@cur_fun = fun_def
|
237
|
+
end
|
238
|
+
|
239
|
+
def end_function(*)
|
240
|
+
@cur_fun = nil
|
241
|
+
end
|
242
|
+
|
243
|
+
def check(retn_stmt)
|
244
|
+
return unless @cur_fun.explicitly_typed?
|
245
|
+
|
246
|
+
if retn_type = @cur_fun.type.return_type
|
247
|
+
if !retn_type.void? && retn_stmt.expression.nil?
|
248
|
+
W(retn_stmt.location, @cur_fun.identifier.value)
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
class W0699 < W0698
|
255
|
+
def_registrant_phase Cc1::Prepare2Phase
|
256
|
+
|
257
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
258
|
+
# step-in analysis is supported.
|
259
|
+
mark_as_unique
|
260
|
+
|
261
|
+
private
|
262
|
+
def check(retn_stmt)
|
263
|
+
return unless @cur_fun.implicitly_typed?
|
264
|
+
|
265
|
+
if retn_stmt.expression.nil?
|
266
|
+
W(retn_stmt.location, @cur_fun.identifier.value)
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
class W0700 < PassiveCodeCheck
|
272
|
+
def_registrant_phase Cc1::Prepare2Phase
|
273
|
+
|
274
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
275
|
+
# step-in analysis is supported.
|
276
|
+
mark_as_unique
|
277
|
+
|
278
|
+
def initialize(phase_ctxt)
|
279
|
+
super
|
280
|
+
interp = phase_ctxt[:cc1_interpreter]
|
281
|
+
interp.on_function_started += T(:start_function)
|
282
|
+
interp.on_function_ended += T(:end_function)
|
283
|
+
interp.on_return_stmt_evaled += T(:check_explicit_return)
|
284
|
+
interp.on_implicit_return_evaled += M(:check_implicit_return)
|
285
|
+
@cur_fun = nil
|
286
|
+
end
|
287
|
+
|
288
|
+
private
|
289
|
+
def start_function(fun_def, *)
|
290
|
+
@cur_fun = fun_def
|
291
|
+
end
|
292
|
+
|
293
|
+
def end_function(*)
|
294
|
+
@cur_fun = nil
|
295
|
+
end
|
296
|
+
|
297
|
+
def check_explicit_return(retn_stmt, *)
|
298
|
+
if @cur_fun
|
299
|
+
if @cur_fun.implicitly_typed? && retn_stmt.expression.nil?
|
300
|
+
W(@cur_fun.location, @cur_fun.identifier.value)
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
def check_implicit_return(loc)
|
306
|
+
if @cur_fun && loc.in_analysis_target?(traits)
|
307
|
+
if @cur_fun.implicitly_typed?
|
308
|
+
W(@cur_fun.location, @cur_fun.identifier.value)
|
309
|
+
end
|
310
|
+
end
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
class W0711 < PassiveCodeCheck
|
315
|
+
def_registrant_phase Cc1::Prepare2Phase
|
316
|
+
|
317
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
318
|
+
# step-in analysis is supported.
|
319
|
+
mark_as_unique
|
320
|
+
|
321
|
+
def initialize(phase_ctxt)
|
322
|
+
super
|
323
|
+
visitor = phase_ctxt[:cc1_visitor]
|
324
|
+
visitor.enter_relational_expression += T(:check)
|
325
|
+
end
|
326
|
+
|
327
|
+
private
|
328
|
+
def check(expr)
|
329
|
+
if !expr.lhs_operand.logical? && expr.rhs_operand.logical?
|
330
|
+
W(expr.rhs_operand.location)
|
331
|
+
end
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
class W0712 < W0711
|
336
|
+
def_registrant_phase Cc1::Prepare2Phase
|
337
|
+
|
338
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
339
|
+
# step-in analysis is supported.
|
340
|
+
mark_as_unique
|
341
|
+
|
342
|
+
private
|
343
|
+
def check(expr)
|
344
|
+
if expr.lhs_operand.logical? && !expr.rhs_operand.logical?
|
345
|
+
W(expr.lhs_operand.location)
|
346
|
+
end
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
class W0713 < W0711
|
351
|
+
def_registrant_phase Cc1::Prepare2Phase
|
352
|
+
|
353
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
354
|
+
# step-in analysis is supported.
|
355
|
+
mark_as_unique
|
356
|
+
|
357
|
+
private
|
358
|
+
def check(expr)
|
359
|
+
if expr.lhs_operand.logical? && expr.rhs_operand.logical?
|
360
|
+
W(expr.location)
|
361
|
+
end
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
class W0714 < PassiveCodeCheck
|
366
|
+
def_registrant_phase Cc1::Prepare2Phase
|
367
|
+
|
368
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
369
|
+
# step-in analysis is supported.
|
370
|
+
mark_as_unique
|
371
|
+
|
372
|
+
def initialize(phase_ctxt)
|
373
|
+
super
|
374
|
+
visitor = phase_ctxt[:cc1_visitor]
|
375
|
+
visitor.enter_and_expression += T(:check)
|
376
|
+
end
|
377
|
+
|
378
|
+
private
|
379
|
+
def check(expr)
|
380
|
+
if expr.lhs_operand.logical? && expr.rhs_operand.logical?
|
381
|
+
W(expr.location)
|
382
|
+
end
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
class W0715 < PassiveCodeCheck
|
387
|
+
def_registrant_phase Cc1::Prepare2Phase
|
388
|
+
|
389
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
390
|
+
# step-in analysis is supported.
|
391
|
+
mark_as_unique
|
392
|
+
|
393
|
+
def initialize(phase_ctxt)
|
394
|
+
super
|
395
|
+
visitor = phase_ctxt[:cc1_visitor]
|
396
|
+
visitor.enter_inclusive_or_expression += T(:check)
|
397
|
+
end
|
398
|
+
|
399
|
+
private
|
400
|
+
def check(expr)
|
401
|
+
if expr.lhs_operand.logical? && expr.rhs_operand.logical?
|
402
|
+
W(expr.location)
|
403
|
+
end
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
class W0716 < PassiveCodeCheck
|
408
|
+
def_registrant_phase Cc1::Prepare2Phase
|
409
|
+
|
410
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
411
|
+
# step-in analysis is supported.
|
412
|
+
mark_as_unique
|
413
|
+
|
414
|
+
def initialize(phase_ctxt)
|
415
|
+
super
|
416
|
+
visitor = phase_ctxt[:cc1_visitor]
|
417
|
+
visitor.enter_additive_expression += T(:check)
|
418
|
+
visitor.enter_multiplicative_expression += T(:check)
|
419
|
+
visitor.enter_shift_expression += T(:check)
|
420
|
+
visitor.enter_and_expression += T(:check)
|
421
|
+
visitor.enter_exclusive_or_expression += T(:check)
|
422
|
+
visitor.enter_inclusive_or_expression += T(:check)
|
423
|
+
visitor.enter_compound_assignment_expression += T(:check)
|
424
|
+
end
|
425
|
+
|
426
|
+
private
|
427
|
+
def check(expr)
|
428
|
+
if expr.lhs_operand.logical? && expr.rhs_operand.logical?
|
429
|
+
W(expr.location)
|
430
|
+
end
|
431
|
+
end
|
432
|
+
end
|
433
|
+
|
434
|
+
class W0717 < W0716
|
435
|
+
def_registrant_phase Cc1::Prepare2Phase
|
436
|
+
|
437
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
438
|
+
# step-in analysis is supported.
|
439
|
+
mark_as_unique
|
440
|
+
|
441
|
+
private
|
442
|
+
def check(expr)
|
443
|
+
if expr.lhs_operand.logical? && !expr.rhs_operand.logical?
|
444
|
+
W(expr.lhs_operand.location)
|
445
|
+
end
|
446
|
+
end
|
447
|
+
end
|
448
|
+
|
449
|
+
class W0718 < W0716
|
450
|
+
def_registrant_phase Cc1::Prepare2Phase
|
451
|
+
|
452
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
453
|
+
# step-in analysis is supported.
|
454
|
+
mark_as_unique
|
455
|
+
|
456
|
+
private
|
457
|
+
def check(expr)
|
458
|
+
if !expr.lhs_operand.logical? && expr.rhs_operand.logical?
|
459
|
+
W(expr.rhs_operand.location)
|
460
|
+
end
|
461
|
+
end
|
462
|
+
end
|
463
|
+
|
464
|
+
class W0726 < W0698
|
465
|
+
def_registrant_phase Cc1::Prepare2Phase
|
466
|
+
|
467
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
468
|
+
# step-in analysis is supported.
|
469
|
+
mark_as_unique
|
470
|
+
|
471
|
+
private
|
472
|
+
def check(retn_stmt)
|
473
|
+
if retn_stmt.expression
|
474
|
+
if retn_type = @cur_fun.type.return_type
|
475
|
+
if retn_type.void? && (retn_type.const? || retn_type.volatile?)
|
476
|
+
W(retn_stmt.location, @cur_fun.identifier.value)
|
477
|
+
end
|
478
|
+
end
|
479
|
+
end
|
480
|
+
end
|
481
|
+
end
|
482
|
+
|
483
|
+
class W0732 < PassiveCodeCheck
|
484
|
+
def_registrant_phase Cc1::Prepare2Phase
|
485
|
+
|
486
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
487
|
+
# step-in analysis is supported.
|
488
|
+
mark_as_unique
|
489
|
+
|
490
|
+
def initialize(phase_ctxt)
|
491
|
+
super
|
492
|
+
visitor = phase_ctxt[:cc1_visitor]
|
493
|
+
visitor.enter_logical_and_expression += T(:check)
|
494
|
+
end
|
495
|
+
|
496
|
+
private
|
497
|
+
def check(expr)
|
498
|
+
if expr.lhs_operand.arithmetic? || expr.lhs_operand.bitwise?
|
499
|
+
if expr.rhs_operand.arithmetic? || expr.rhs_operand.bitwise?
|
500
|
+
W(expr.location)
|
501
|
+
end
|
502
|
+
end
|
503
|
+
end
|
504
|
+
end
|
505
|
+
|
506
|
+
class W0733 < PassiveCodeCheck
|
507
|
+
def_registrant_phase Cc1::Prepare2Phase
|
508
|
+
|
509
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
510
|
+
# step-in analysis is supported.
|
511
|
+
mark_as_unique
|
512
|
+
|
513
|
+
def initialize(phase_ctxt)
|
514
|
+
super
|
515
|
+
visitor = phase_ctxt[:cc1_visitor]
|
516
|
+
visitor.enter_logical_or_expression += T(:check)
|
517
|
+
end
|
518
|
+
|
519
|
+
private
|
520
|
+
def check(expr)
|
521
|
+
if expr.lhs_operand.arithmetic? || expr.lhs_operand.bitwise?
|
522
|
+
if expr.rhs_operand.arithmetic? || expr.rhs_operand.bitwise?
|
523
|
+
W(expr.location)
|
524
|
+
end
|
525
|
+
end
|
526
|
+
end
|
527
|
+
end
|
528
|
+
|
529
|
+
class W0734 < PassiveCodeCheck
|
530
|
+
def_registrant_phase Cc1::Prepare2Phase
|
531
|
+
|
532
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
533
|
+
# step-in analysis is supported.
|
534
|
+
mark_as_unique
|
535
|
+
|
536
|
+
def initialize(phase_ctxt)
|
537
|
+
super
|
538
|
+
visitor = phase_ctxt[:cc1_visitor]
|
539
|
+
visitor.enter_logical_and_expression += T(:check)
|
540
|
+
visitor.enter_logical_or_expression += T(:check)
|
541
|
+
end
|
542
|
+
|
543
|
+
private
|
544
|
+
def check(expr)
|
545
|
+
if expr.lhs_operand.arithmetic? || expr.lhs_operand.bitwise?
|
546
|
+
unless expr.rhs_operand.arithmetic? || expr.rhs_operand.bitwise?
|
547
|
+
W(expr.lhs_operand.location)
|
548
|
+
end
|
549
|
+
end
|
550
|
+
end
|
551
|
+
end
|
552
|
+
|
553
|
+
class W0735 < W0734
|
554
|
+
def_registrant_phase Cc1::Prepare2Phase
|
555
|
+
|
556
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
557
|
+
# step-in analysis is supported.
|
558
|
+
mark_as_unique
|
559
|
+
|
560
|
+
private
|
561
|
+
def check(expr)
|
562
|
+
if expr.rhs_operand.arithmetic? || expr.rhs_operand.bitwise?
|
563
|
+
unless expr.lhs_operand.arithmetic? || expr.lhs_operand.bitwise?
|
564
|
+
W(expr.rhs_operand.location)
|
565
|
+
end
|
566
|
+
end
|
567
|
+
end
|
568
|
+
end
|
569
|
+
|
570
|
+
class W0781 < PassiveCodeCheck
|
571
|
+
def_registrant_phase Cc1::Prepare2Phase
|
572
|
+
|
573
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
574
|
+
# step-in analysis is supported.
|
575
|
+
mark_as_unique
|
576
|
+
|
577
|
+
def initialize(phase_ctxt)
|
578
|
+
super
|
579
|
+
visitor = phase_ctxt[:cc1_visitor]
|
580
|
+
visitor.enter_switch_statement += T(:enter_switch_statement)
|
581
|
+
visitor.leave_switch_statement += T(:check)
|
582
|
+
visitor.enter_case_labeled_statement += T(:add_exec_path)
|
583
|
+
visitor.enter_default_labeled_statement += T(:add_exec_path)
|
584
|
+
@exec_path_nums = []
|
585
|
+
end
|
586
|
+
|
587
|
+
private
|
588
|
+
def enter_switch_statement(*)
|
589
|
+
@exec_path_nums.push(0)
|
590
|
+
end
|
591
|
+
|
592
|
+
def check(node)
|
593
|
+
if exec_path_num = @exec_path_nums.last and exec_path_num < 2
|
594
|
+
W(node.location)
|
595
|
+
end
|
596
|
+
@exec_path_nums.pop
|
597
|
+
end
|
598
|
+
|
599
|
+
def add_exec_path(node)
|
600
|
+
@exec_path_nums[-1] += 1 if node.executed?
|
601
|
+
end
|
602
|
+
end
|
603
|
+
|
604
|
+
class W0801 < PassiveCodeCheck
|
605
|
+
def_registrant_phase Cc1::Prepare2Phase
|
606
|
+
|
607
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
608
|
+
# step-in analysis is supported.
|
609
|
+
mark_as_unique
|
610
|
+
|
611
|
+
def initialize(phase_ctxt)
|
612
|
+
super
|
613
|
+
visitor = phase_ctxt[:cc1_visitor]
|
614
|
+
visitor.enter_struct_type_declaration += T(:check)
|
615
|
+
visitor.enter_union_type_declaration += T(:check)
|
616
|
+
end
|
617
|
+
|
618
|
+
private
|
619
|
+
def check(node)
|
620
|
+
W(node.location) if node.type.members.empty?
|
621
|
+
end
|
622
|
+
end
|
623
|
+
|
624
|
+
class W0809 < PassiveCodeCheck
|
625
|
+
def_registrant_phase Cc1::Prepare2Phase
|
626
|
+
|
627
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
628
|
+
# step-in analysis is supported.
|
629
|
+
mark_as_unique
|
630
|
+
|
631
|
+
def initialize(phase_ctxt)
|
632
|
+
super
|
633
|
+
visitor = phase_ctxt[:cc1_visitor]
|
634
|
+
visitor.enter_function_declaration += T(:check_function_name)
|
635
|
+
visitor.enter_variable_declaration += T(:check_variable_name)
|
636
|
+
visitor.enter_variable_definition += T(:check_variable_name)
|
637
|
+
visitor.enter_parameter_definition += T(:check_variable_name)
|
638
|
+
visitor.enter_typedef_declaration += T(:check_typedef_name)
|
639
|
+
visitor.enter_struct_type_declaration += T(:check_tag_name)
|
640
|
+
visitor.enter_union_type_declaration += T(:check_tag_name)
|
641
|
+
visitor.enter_enum_type_declaration += T(:check_tag_name)
|
642
|
+
visitor.enter_enumerator += T(:check_enumerator_name)
|
643
|
+
visitor.enter_kandr_function_definition += T(:enter_function)
|
644
|
+
visitor.enter_ansi_function_definition += T(:enter_function)
|
645
|
+
visitor.leave_kandr_function_definition += T(:leave_function)
|
646
|
+
visitor.leave_ansi_function_definition += T(:leave_function)
|
647
|
+
@function_def_level = 0
|
648
|
+
end
|
649
|
+
|
650
|
+
private
|
651
|
+
def check_function_name(fun_dcl)
|
652
|
+
check_object_name(fun_dcl)
|
653
|
+
end
|
654
|
+
|
655
|
+
def check_variable_name(var_dcl_or_def)
|
656
|
+
check_object_name(var_dcl_or_def)
|
657
|
+
end
|
658
|
+
|
659
|
+
def check_typedef_name(typedef_dcl)
|
660
|
+
if typedef_dcl.identifier
|
661
|
+
case name = typedef_dcl.identifier.value
|
662
|
+
when /\A__/, /\A_[A-Z]/, /\A_/
|
663
|
+
W(typedef_dcl.location, name)
|
664
|
+
end
|
665
|
+
end
|
666
|
+
end
|
667
|
+
|
668
|
+
def check_tag_name(type_dcl)
|
669
|
+
if type_dcl.identifier
|
670
|
+
case name = type_dcl.identifier.value
|
671
|
+
when /\A__adlint/
|
672
|
+
# NOTE: To ignore AdLint internal tag names.
|
673
|
+
when /\A__/, /\A_[A-Z]/, /\A_/
|
674
|
+
W(type_dcl.location, name)
|
675
|
+
end
|
676
|
+
end
|
677
|
+
end
|
678
|
+
|
679
|
+
def check_enumerator_name(enum)
|
680
|
+
if enum.identifier
|
681
|
+
case name = enum.identifier.value
|
682
|
+
when /\A__/, /\A_[A-Z]/, /\A_/
|
683
|
+
W(enum.location, name)
|
684
|
+
end
|
685
|
+
end
|
686
|
+
end
|
687
|
+
|
688
|
+
def enter_function(node)
|
689
|
+
check_object_name(node)
|
690
|
+
@function_def_level += 1
|
691
|
+
end
|
692
|
+
|
693
|
+
def leave_function(node)
|
694
|
+
@function_def_level -= 1
|
695
|
+
end
|
696
|
+
|
697
|
+
def check_object_name(dcl_or_def)
|
698
|
+
if dcl_or_def.identifier
|
699
|
+
case name = dcl_or_def.identifier.value
|
700
|
+
when /\A__/, /\A_[A-Z]/
|
701
|
+
W(dcl_or_def.location, name)
|
702
|
+
when /\A_/
|
703
|
+
check_filelocal_object_name(name, dcl_or_def)
|
704
|
+
end
|
705
|
+
end
|
706
|
+
end
|
707
|
+
|
708
|
+
def check_filelocal_object_name(name, dcl_or_def)
|
709
|
+
if @function_def_level == 0
|
710
|
+
if sc_spec = dcl_or_def.storage_class_specifier
|
711
|
+
if sc_spec.type == :STATIC
|
712
|
+
W(dcl_or_def.location, name)
|
713
|
+
end
|
714
|
+
end
|
715
|
+
end
|
716
|
+
end
|
717
|
+
end
|
718
|
+
|
719
|
+
class W1030 < PassiveCodeCheck
|
720
|
+
def_registrant_phase Cc1::Prepare2Phase
|
721
|
+
|
722
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
723
|
+
# step-in analysis is supported.
|
724
|
+
mark_as_unique
|
725
|
+
|
726
|
+
def initialize(phase_ctxt)
|
727
|
+
super
|
728
|
+
visitor = phase_ctxt[:cc1_visitor]
|
729
|
+
visitor.enter_generic_labeled_statement += T(:check)
|
730
|
+
visitor.enter_ansi_function_definition += T(:enter_function)
|
731
|
+
visitor.leave_ansi_function_definition += T(:leave_function)
|
732
|
+
visitor.enter_kandr_function_definition += T(:enter_function)
|
733
|
+
visitor.leave_kandr_function_definition += T(:leave_function)
|
734
|
+
@labels = nil
|
735
|
+
end
|
736
|
+
|
737
|
+
private
|
738
|
+
def check(labeled_stmt)
|
739
|
+
if @labels
|
740
|
+
if @labels.include?(labeled_stmt.label.value)
|
741
|
+
W(labeled_stmt.label.location, labeled_stmt.label.value)
|
742
|
+
else
|
743
|
+
@labels.add(labeled_stmt.label.value)
|
744
|
+
end
|
745
|
+
end
|
746
|
+
end
|
747
|
+
|
748
|
+
def enter_function(*)
|
749
|
+
@labels = Set.new
|
750
|
+
end
|
751
|
+
|
752
|
+
def leave_function(*)
|
753
|
+
@labels = nil
|
754
|
+
end
|
755
|
+
end
|
756
|
+
|
757
|
+
class W1033 < PassiveCodeCheck
|
758
|
+
def_registrant_phase Cc1::Prepare2Phase
|
759
|
+
|
760
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
761
|
+
# step-in analysis is supported.
|
762
|
+
mark_as_unique
|
763
|
+
|
764
|
+
def initialize(phase_ctxt)
|
765
|
+
super
|
766
|
+
visitor = phase_ctxt[:cc1_visitor]
|
767
|
+
visitor.enter_ansi_function_definition += T(:check)
|
768
|
+
visitor.enter_kandr_function_definition += T(:check)
|
769
|
+
visitor.enter_function_declaration += T(:check)
|
770
|
+
end
|
771
|
+
|
772
|
+
private
|
773
|
+
def check(dcl_or_def)
|
774
|
+
if retn_type = dcl_or_def.type.return_type
|
775
|
+
if retn_type.const? || retn_type.volatile?
|
776
|
+
W(dcl_or_def.location)
|
777
|
+
end
|
778
|
+
end
|
779
|
+
end
|
780
|
+
end
|
781
|
+
|
782
|
+
class W1066 < PassiveCodeCheck
|
783
|
+
def_registrant_phase Cc1::Prepare2Phase
|
784
|
+
|
785
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
786
|
+
# step-in analysis is supported.
|
787
|
+
mark_as_unique
|
788
|
+
|
789
|
+
def initialize(phase_ctxt)
|
790
|
+
super
|
791
|
+
@interp = phase_ctxt[:cc1_interpreter]
|
792
|
+
@interp.on_explicit_conv_performed += T(:check)
|
793
|
+
@interp.on_function_started += T(:clear_rvalues)
|
794
|
+
@interp.on_additive_expr_evaled += T(:handle_additive)
|
795
|
+
@interp.on_multiplicative_expr_evaled += T(:handle_multiplicative)
|
796
|
+
@rvalues = nil
|
797
|
+
end
|
798
|
+
|
799
|
+
private
|
800
|
+
def check(*, org_var, res_var)
|
801
|
+
if @rvalues && org_var.type.floating?
|
802
|
+
case expr = @rvalues[org_var]
|
803
|
+
when Cc1::AdditiveExpression, Cc1::MultiplicativeExpression
|
804
|
+
if org_var.type.same_as?(from_type) && res_var.type.same_as?(to_type)
|
805
|
+
W(expr.location)
|
806
|
+
end
|
807
|
+
end
|
808
|
+
end
|
809
|
+
end
|
810
|
+
|
811
|
+
def clear_rvalues(*)
|
812
|
+
@rvalues = {}
|
813
|
+
end
|
814
|
+
|
815
|
+
def handle_additive(expr, *, res_var)
|
816
|
+
memorize_rvalue_derivation(res_var, expr)
|
817
|
+
end
|
818
|
+
|
819
|
+
def handle_multiplicative(expr, *, res_var)
|
820
|
+
unless expr.operator.type == "%"
|
821
|
+
memorize_rvalue_derivation(res_var, expr)
|
822
|
+
end
|
823
|
+
end
|
824
|
+
|
825
|
+
def memorize_rvalue_derivation(rvalue_holder, expr)
|
826
|
+
@rvalues[rvalue_holder] = expr if @rvalues
|
827
|
+
end
|
828
|
+
|
829
|
+
def from_type
|
830
|
+
@interp.float_t
|
831
|
+
end
|
832
|
+
|
833
|
+
def to_type
|
834
|
+
@interp.double_t
|
835
|
+
end
|
836
|
+
end
|
837
|
+
|
838
|
+
class W1067 < W1066
|
839
|
+
def_registrant_phase Cc1::Prepare2Phase
|
840
|
+
|
841
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
842
|
+
# step-in analysis is supported.
|
843
|
+
mark_as_unique
|
844
|
+
|
845
|
+
private
|
846
|
+
def from_type
|
847
|
+
@interp.float_t
|
848
|
+
end
|
849
|
+
|
850
|
+
def to_type
|
851
|
+
@interp.long_double_t
|
852
|
+
end
|
853
|
+
end
|
854
|
+
|
855
|
+
class W1068 < W1066
|
856
|
+
def_registrant_phase Cc1::Prepare2Phase
|
857
|
+
|
858
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
859
|
+
# step-in analysis is supported.
|
860
|
+
mark_as_unique
|
861
|
+
|
862
|
+
private
|
863
|
+
def from_type
|
864
|
+
@interp.double_t
|
865
|
+
end
|
866
|
+
|
867
|
+
def to_type
|
868
|
+
@interp.long_double_t
|
869
|
+
end
|
870
|
+
end
|
871
|
+
|
872
|
+
class W1069 < PassiveCodeCheck
|
873
|
+
def_registrant_phase Cc1::Prepare2Phase
|
874
|
+
|
875
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
876
|
+
# step-in analysis is supported.
|
877
|
+
mark_as_unique
|
878
|
+
|
879
|
+
def initialize(phase_ctxt)
|
880
|
+
super
|
881
|
+
visitor = phase_ctxt[:cc1_visitor]
|
882
|
+
visitor.enter_ansi_function_definition += T(:enter_function)
|
883
|
+
visitor.enter_kandr_function_definition += T(:enter_function)
|
884
|
+
visitor.enter_compound_statement += T(:enter_compound_stmt)
|
885
|
+
visitor.leave_compound_statement += T(:leave_compound_stmt)
|
886
|
+
visitor.enter_if_else_statement += T(:enter_if_else_stmt)
|
887
|
+
visitor.leave_if_else_statement += T(:leave_if_else_stmt)
|
888
|
+
@if_else_stmt_chain_stack = []
|
889
|
+
end
|
890
|
+
|
891
|
+
private
|
892
|
+
def enter_function(*)
|
893
|
+
@if_else_stmt_chain_stack = []
|
894
|
+
end
|
895
|
+
|
896
|
+
def enter_compound_stmt(*)
|
897
|
+
@if_else_stmt_chain_stack.push([])
|
898
|
+
end
|
899
|
+
|
900
|
+
def leave_compound_stmt(*)
|
901
|
+
@if_else_stmt_chain_stack.pop
|
902
|
+
end
|
903
|
+
|
904
|
+
def enter_if_else_stmt(node)
|
905
|
+
@if_else_stmt_chain_stack.last.push(node)
|
906
|
+
if node.else_statement.kind_of?(Cc1::IfStatement)
|
907
|
+
W(@if_else_stmt_chain_stack.last.first.location)
|
908
|
+
end
|
909
|
+
end
|
910
|
+
|
911
|
+
def leave_if_else_stmt(*)
|
912
|
+
@if_else_stmt_chain_stack.last.pop
|
913
|
+
end
|
914
|
+
end
|
915
|
+
|
916
|
+
class W1070 < W0781
|
917
|
+
def_registrant_phase Cc1::Prepare2Phase
|
918
|
+
|
919
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
920
|
+
# step-in analysis is supported.
|
921
|
+
mark_as_unique
|
922
|
+
|
923
|
+
private
|
924
|
+
def check(node)
|
925
|
+
if exec_path_num = @exec_path_nums.last and exec_path_num == 2
|
926
|
+
W(node.location)
|
927
|
+
end
|
928
|
+
@exec_path_nums.pop
|
929
|
+
end
|
930
|
+
|
931
|
+
def add_exec_path(*)
|
932
|
+
@exec_path_nums[-1] += 1
|
933
|
+
end
|
934
|
+
end
|
935
|
+
|
936
|
+
class W1072 < PassiveCodeCheck
|
937
|
+
def_registrant_phase Cc1::Prepare2Phase
|
938
|
+
|
939
|
+
# NOTE: All messages of cc1-phase code check should be unique till function
|
940
|
+
# step-in analysis is supported.
|
941
|
+
mark_as_unique
|
942
|
+
|
943
|
+
def initialize(phase_ctxt)
|
944
|
+
super
|
945
|
+
visitor = phase_ctxt[:cc1_visitor]
|
946
|
+
visitor.enter_goto_statement += T(:warn_goto)
|
947
|
+
end
|
948
|
+
|
949
|
+
private
|
950
|
+
def warn_goto(node)
|
951
|
+
W(node.location)
|
952
|
+
end
|
953
|
+
end
|
954
|
+
|
955
|
+
end
|
956
|
+
end
|
957
|
+
end
|