adlint 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/AUTHORS +3 -2
  2. data/ChangeLog +208 -63
  3. data/MANIFEST +4 -0
  4. data/NEWS +24 -5
  5. data/etc/conf.d/fallback/traits.erb +1 -1
  6. data/etc/conf.d/i686-cygwin/traits-gcc_4.3.4.erb +1 -1
  7. data/etc/conf.d/i686-devkit/traits-gcc_4.5.2.erb +1 -1
  8. data/etc/conf.d/i686-linux/traits-gcc_4.5.1.erb +1 -1
  9. data/etc/conf.d/i686-mingw/traits-gcc_4.6.1.erb +1 -1
  10. data/etc/mesg.d/en_US/messages.yml +3 -3
  11. data/etc/mesg.d/ja_JP/messages.yml +4 -4
  12. data/lib/adlint/c/builtin.rb +3 -3
  13. data/lib/adlint/c/ctrlexpr.rb +7 -11
  14. data/lib/adlint/c/expr.rb +548 -363
  15. data/lib/adlint/c/interp.rb +233 -525
  16. data/lib/adlint/c/mediator.rb +1 -0
  17. data/lib/adlint/c/message.rb +144 -1
  18. data/lib/adlint/c/object.rb +15 -6
  19. data/lib/adlint/c/parser.rb +170 -128
  20. data/lib/adlint/c/parser.y +36 -0
  21. data/lib/adlint/c/phase.rb +4 -0
  22. data/lib/adlint/c/seqp.rb +72 -0
  23. data/lib/adlint/c/syntax.rb +254 -3
  24. data/lib/adlint/c.rb +1 -0
  25. data/lib/adlint/cpp/code.rb +2 -2
  26. data/lib/adlint/cpp/eval.rb +29 -13
  27. data/lib/adlint/cpp/message.rb +71 -70
  28. data/lib/adlint/cpp/message_shima.rb +100 -0
  29. data/lib/adlint/cpp/phase.rb +4 -0
  30. data/lib/adlint/cpp/syntax.rb +5 -1
  31. data/lib/adlint/cpp.rb +1 -0
  32. data/lib/adlint/message.rb +6 -3
  33. data/lib/adlint/traits.rb +1 -1
  34. data/lib/adlint/version.rb +5 -5
  35. data/share/demo/Makefile +3 -1
  36. data/share/demo/bad_line/bad_line.c +27 -0
  37. data/share/demo/sequence_point/sequence_point.c +31 -0
  38. data/share/doc/adlint_on_vim_en.png +0 -0
  39. data/share/doc/adlint_on_vim_ja.png +0 -0
  40. data/share/doc/developers_guide_ja.html +3 -3
  41. data/share/doc/developers_guide_ja.texi +1 -1
  42. data/share/doc/users_guide_en.html +3118 -41
  43. data/share/doc/users_guide_en.texi +3090 -37
  44. data/share/doc/users_guide_ja.html +3120 -47
  45. data/share/doc/users_guide_ja.texi +3106 -65
  46. data/share/sample/ctags-5.8/adlint/GNUmakefile +13 -1
  47. data/share/sample/ctags-5.8/adlint/adlint_cinit.h +14 -2
  48. data/share/sample/ctags-5.8/adlint/adlint_pinit.h +14 -4
  49. data/share/sample/ctags-5.8/adlint/adlint_traits.yml +14 -1
  50. data/share/sample/flex-2.5.35/adlint/GNUmakefile +13 -1
  51. data/share/sample/flex-2.5.35/adlint/adlint_cinit.h +14 -2
  52. data/share/sample/flex-2.5.35/adlint/adlint_pinit.h +14 -4
  53. data/share/sample/flex-2.5.35/adlint/adlint_traits.yml +14 -1
  54. metadata +6 -2
@@ -377,9 +377,9 @@ module Cpp #:nodoc:
377
377
  unless new_line = context.next_token and new_line.type == :NEW_LINE
378
378
  return nil
379
379
  end
380
- tokens = PPTokensNormalizer.normalize(pp_tokens, context)
381
- return nil if tokens.empty?
382
- case parameter = tokens.map { |t| t.value }.join
380
+ PPTokensNormalizer.normalize(pp_tokens, context)
381
+ return nil if pp_tokens.tokens.empty?
382
+ case parameter = pp_tokens.tokens.map { |t| t.value }.join
383
383
  when /\A".*"\z/
384
384
  user_include_line = UserIncludeLine.new(
385
385
  keyword, Token.new(:USR_HEADER_NAME, parameter,
@@ -405,9 +405,9 @@ module Cpp #:nodoc:
405
405
  unless new_line = context.next_token and new_line.type == :NEW_LINE
406
406
  return nil
407
407
  end
408
- tokens = PPTokensNormalizer.normalize(pp_tokens, context)
409
- return nil if tokens.empty?
410
- case parameter = tokens.map { |t| t.value }.join
408
+ PPTokensNormalizer.normalize(pp_tokens, context)
409
+ return nil if pp_tokens.tokens.empty?
410
+ case parameter = pp_tokens.tokens.map { |t| t.value }.join
411
411
  when /\A".*"\z/
412
412
  user_include_next_line = UserIncludeNextLine.new(
413
413
  keyword, Token.new(:USR_HEADER_NAME, parameter,
@@ -498,12 +498,27 @@ module Cpp #:nodoc:
498
498
 
499
499
  def line_line(context)
500
500
  keyword = context.next_token
501
- unless pp_tokens = pp_tokens(context)
502
- return nil
503
- end
501
+ pp_tokens = pp_tokens(context)
504
502
  unless new_line = context.next_token and new_line.type == :NEW_LINE
505
503
  return nil
506
504
  end
505
+
506
+ # NOTE: The ISO C99 standard saids;
507
+ #
508
+ # 6.10.4 Line control
509
+ #
510
+ # Semantics
511
+ #
512
+ # 5 A preprocessing directive of the form
513
+ # # line pp-tokens new-line
514
+ # that does not match one of the two previous forms is permitted. The
515
+ # preprocessing tokens after line on the directive are processed just
516
+ # as in normal text (each identifier currently defined as a macro name
517
+ # is replaced by its replacement list of preprocessing tokens). The
518
+ # directive resulting after all replacements shall match one of the two
519
+ # previous forms and is then processed as appropriate.
520
+ PPTokensNormalizer.normalize(pp_tokens, context) if pp_tokens
521
+
507
522
  LineLine.new(keyword, pp_tokens)
508
523
  end
509
524
 
@@ -523,7 +538,8 @@ module Cpp #:nodoc:
523
538
  return nil
524
539
  end
525
540
  pragma_line = PragmaLine.new(keyword, pp_tokens)
526
- if pp_tokens.tokens.size == 1 && pp_tokens.tokens.first.value == "once"
541
+ if pp_tokens && pp_tokens.tokens.size == 1 &&
542
+ pp_tokens.tokens.first.value == "once"
527
543
  context.once_set.add(keyword.location.fpath)
528
544
  else
529
545
  notify_unknown_pragma_evaled(pragma_line)
@@ -912,15 +928,15 @@ module Cpp #:nodoc:
912
928
  module PPTokensNormalizer
913
929
  def normalize(pp_tokens, context)
914
930
  context.macro_table.replace(pp_tokens.tokens)
915
- pp_tokens.tokens
931
+ pp_tokens
916
932
  end
917
933
  module_function :normalize
918
934
  end
919
935
 
920
936
  module ExpressionNormalizer
921
937
  def normalize(pp_tokens, context, preprocessor = nil)
922
- tokens = PPTokensNormalizer.normalize(pp_tokens, context)
923
- const_expr = ConstantExpression.new(context, tokens)
938
+ PPTokensNormalizer.normalize(pp_tokens, context)
939
+ const_expr = ConstantExpression.new(context, pp_tokens.tokens)
924
940
  if preprocessor
925
941
  const_expr.on_illformed_defined_op_found +=
926
942
  preprocessor.method(:notify_illformed_defined_op_found)
@@ -37,8 +37,8 @@ module AdLint #:nodoc:
37
37
  module Cpp #:nodoc:
38
38
 
39
39
  class W0001 < PassiveMessageDetection
40
- # NOTE: W0001 may be duplicative when the source file includes the same
41
- # header which has the deeply grouped expression.
40
+ # NOTE: W0001 may be duplicative when the same header which has the deeply
41
+ # grouped expression is included twice or more.
42
42
  ensure_uniqueness_of :W0001
43
43
 
44
44
  def initialize(context)
@@ -190,8 +190,8 @@ module Cpp #:nodoc:
190
190
  end
191
191
 
192
192
  class W0056 < PassiveMessageDetection
193
- # NOTE: W0056 may be duplicative when the source file includes the same
194
- # header which has macro definition with too many parameters.
193
+ # NOTE: W0056 may be duplicative when the same header which has macro
194
+ # definition with too many parameters is included twice or more.
195
195
  ensure_uniqueness_of :W0056
196
196
 
197
197
  def initialize(context)
@@ -210,8 +210,8 @@ module Cpp #:nodoc:
210
210
  end
211
211
 
212
212
  class W0057 < PassiveMessageDetection
213
- # NOTE: W0057 may be duplicative when the source file includes the same
214
- # header which has macro call with too many arguments.
213
+ # NOTE: W0057 may be duplicative when the same header which has macro call
214
+ # with too many arguments is included twice or more.
215
215
  ensure_uniqueness_of :W0057
216
216
 
217
217
  def initialize(context)
@@ -227,8 +227,8 @@ module Cpp #:nodoc:
227
227
  end
228
228
 
229
229
  class W0059 < PassiveMessageDetection
230
- # NOTE: W0059 may be duplicative when the source file includes the same
231
- # header which has carriage return at end of lines.
230
+ # NOTE: W0059 may be duplicative when the same header which has carriage
231
+ # return at end of lines is included twice or more.
232
232
  ensure_uniqueness_of :W0059
233
233
 
234
234
  def initialize(context)
@@ -239,8 +239,8 @@ module Cpp #:nodoc:
239
239
  end
240
240
 
241
241
  class W0060 < PassiveMessageDetection
242
- # NOTE: W0060 may be duplicative when the source file includes the same
243
- # header with the end-of-file mark.
242
+ # NOTE: W0060 may be duplicative when the same header which has the
243
+ # end-of-file mark is included twice or more.
244
244
  ensure_uniqueness_of :W0060
245
245
 
246
246
  def initialize(context)
@@ -251,9 +251,9 @@ module Cpp #:nodoc:
251
251
  end
252
252
 
253
253
  class W0061 < PassiveMessageDetection
254
- # NOTE: W0061 may be duplicative when the source file includes the same
255
- # header which has the token sequence of the compiler specific
256
- # extension.
254
+ # NOTE: W0061 may be duplicative when the same header which has the token
255
+ # sequence of the compiler specific extension is included twice or
256
+ # more.
257
257
  ensure_uniqueness_of :W0061
258
258
 
259
259
  def initialize(context)
@@ -264,8 +264,8 @@ module Cpp #:nodoc:
264
264
  end
265
265
 
266
266
  class W0069 < PassiveMessageDetection
267
- # NOTE: W0069 may be duplicative when the source file includes the same
268
- # header which has the nested block comment.
267
+ # NOTE: W0069 may be duplicative when the same header which has the nested
268
+ # block comment is included twice or more.
269
269
  ensure_uniqueness_of :W0069
270
270
 
271
271
  def initialize(context)
@@ -276,9 +276,9 @@ module Cpp #:nodoc:
276
276
  end
277
277
 
278
278
  class W0072 < PassiveMessageDetection
279
- # NOTE: W0072 may be duplicative when the source file includes the same
280
- # header which has non basic-source-character in the #include
281
- # directive.
279
+ # NOTE: W0072 may be duplicative when the same header which has non
280
+ # basic-source-character in the #include directive is included twice
281
+ # or more.
282
282
  ensure_uniqueness_of :W0072
283
283
 
284
284
  def initialize(context)
@@ -303,8 +303,8 @@ module Cpp #:nodoc:
303
303
  end
304
304
 
305
305
  class W0073 < PassiveMessageDetection
306
- # NOTE: W0073 may be duplicative when the source file includes the same
307
- # header without the include-guard.
306
+ # NOTE: W0073 may be duplicative when the same header without the
307
+ # include-guard is included twice or more.
308
308
  ensure_uniqueness_of :W0073
309
309
 
310
310
  def initialize(context)
@@ -381,8 +381,8 @@ module Cpp #:nodoc:
381
381
  end
382
382
 
383
383
  class W0442 < PassiveMessageDetection
384
- # NOTE: W0442 may be duplicative when the source file includes the same
385
- # header which has function-like macro definitions.
384
+ # NOTE: W0442 may be duplicative when the same header which has
385
+ # function-like macro definitions is included twice or more.
386
386
  ensure_uniqueness_of :W0442
387
387
 
388
388
  def initialize(context)
@@ -410,8 +410,9 @@ module Cpp #:nodoc:
410
410
  end
411
411
 
412
412
  class W0443 < PassiveMessageDetection
413
- # NOTE: W0443 may be duplicative when the source file includes the same
414
- # header which has functionizable function-like macro definitions.
413
+ # NOTE: W0443 may be duplicative when the same header which has
414
+ # functionizable function-like macro definitions is included twice or
415
+ # more.
415
416
  ensure_uniqueness_of :W0443
416
417
 
417
418
  def initialize(context)
@@ -475,9 +476,9 @@ module Cpp #:nodoc:
475
476
  end
476
477
 
477
478
  class W0444 < PassiveMessageDetection
478
- # NOTE: W0444 may be duplicative when the source file includes the same
479
- # header which has the function-like macro definition with `#' and
480
- # `##' operators.
479
+ # NOTE: W0444 may be duplicative when the same header which has the
480
+ # function-like macro definition with `#' and `##' operators is
481
+ # included twice or more.
481
482
  ensure_uniqueness_of :W0444
482
483
 
483
484
  def initialize(context)
@@ -510,9 +511,9 @@ module Cpp #:nodoc:
510
511
  end
511
512
 
512
513
  class W0445 < PassiveMessageDetection
513
- # NOTE: W0445 may be duplicative when the source file includes the same
514
- # header which has the function-like macro definition with two or
515
- # more `##' operators.
514
+ # NOTE: W0445 may be duplicative when the same header which has the
515
+ # function-like macro definition with two or more `##' operators is
516
+ # included twice or more.
516
517
  ensure_uniqueness_of :W0445
517
518
 
518
519
  def initialize(context)
@@ -541,9 +542,9 @@ module Cpp #:nodoc:
541
542
  end
542
543
 
543
544
  class W0477 < PassiveMessageDetection
544
- # NOTE: W0477 may be duplicative when the source file includes the same
545
- # header which has the macro definition with unbalanced grouping
546
- # tokens.
545
+ # NOTE: W0477 may be duplicative when the same header which has the macro
546
+ # definition with unbalanced grouping tokens is included twice or
547
+ # more.
547
548
  ensure_uniqueness_of :W0477
548
549
 
549
550
  def initialize(context)
@@ -585,8 +586,8 @@ module Cpp #:nodoc:
585
586
  end
586
587
 
587
588
  class W0478 < PassiveMessageDetection
588
- # NOTE: W0478 may be duplicative when the source file includes the same
589
- # header which has this warning.
589
+ # NOTE: W0478 may be duplicative when the same header which causes this
590
+ # warning is included twice or more.
590
591
  ensure_uniqueness_of :W0478
591
592
 
592
593
  def initialize(context)
@@ -614,8 +615,8 @@ module Cpp #:nodoc:
614
615
  end
615
616
 
616
617
  class W0479 < PassiveMessageDetection
617
- # NOTE: W0479 may be duplicative when the source file includes the same
618
- # header which has typdef-able macro definition.
618
+ # NOTE: W0479 may be duplicative when the same header which has
619
+ # typedef-able macro definition is included twice or more.
619
620
  ensure_uniqueness_of :W0479
620
621
 
621
622
  def initialize(context)
@@ -635,8 +636,8 @@ module Cpp #:nodoc:
635
636
  end
636
637
 
637
638
  class W0480 < PassiveMessageDetection
638
- # NOTE: W0480 may be duplicative when the source file includes the same
639
- # header which has this warning.
639
+ # NOTE: W0480 may be duplicative when the same header which causes this
640
+ # warning is included twice or more.
640
641
  ensure_uniqueness_of :W0480
641
642
 
642
643
  def initialize(context)
@@ -659,8 +660,8 @@ module Cpp #:nodoc:
659
660
  end
660
661
 
661
662
  class W0481 < PassiveMessageDetection
662
- # NOTE: W0481 may be duplicative when the source file includes the same
663
- # header which has this warning.
663
+ # NOTE: W0481 may be duplicative when the same header which causes this
664
+ # warning is included twice or more.
664
665
  ensure_uniqueness_of :W0481
665
666
 
666
667
  def initialize(context)
@@ -681,8 +682,8 @@ module Cpp #:nodoc:
681
682
  end
682
683
 
683
684
  class W0482 < PassiveMessageDetection
684
- # NOTE: W0482 may be duplicative when the source file includes the same
685
- # header which has this warning.
685
+ # NOTE: W0482 may be duplicative when the same header which causes this
686
+ # warning is included twice or more.
686
687
  ensure_uniqueness_of :W0482
687
688
 
688
689
  def initialize(context)
@@ -716,8 +717,8 @@ module Cpp #:nodoc:
716
717
  end
717
718
 
718
719
  class W0483 < PassiveMessageDetection
719
- # NOTE: W0483 may be duplicative when the source file includes the same
720
- # header which has this warning.
720
+ # NOTE: W0483 may be duplicative when the same header which causes this
721
+ # warning is included twice or more.
721
722
  ensure_uniqueness_of :W0483
722
723
 
723
724
  def initialize(context)
@@ -737,8 +738,8 @@ module Cpp #:nodoc:
737
738
  end
738
739
 
739
740
  class W0511 < PassiveMessageDetection
740
- # NOTE: W0511 may be duplicative when the source file includes the same
741
- # header which has line comments.
741
+ # NOTE: W0511 may be duplicative when the same header which causes this
742
+ # warning is included twice or more.
742
743
  ensure_uniqueness_of :W0511
743
744
 
744
745
  def initialize(context)
@@ -749,8 +750,8 @@ module Cpp #:nodoc:
749
750
  end
750
751
 
751
752
  class W0528 < PassiveMessageDetection
752
- # NOTE: W0528 may be duplicative when the source file includes the same
753
- # header which has this warning.
753
+ # NOTE: W0528 may be duplicative when the same header which causes this
754
+ # warning is included twice or more.
754
755
  ensure_uniqueness_of :W0528
755
756
 
756
757
  def initialize(context)
@@ -771,8 +772,8 @@ module Cpp #:nodoc:
771
772
  end
772
773
 
773
774
  class W0549 < PassiveMessageDetection
774
- # NOTE: W0549 may be duplicative when the source file includes the same
775
- # header which has this warning.
775
+ # NOTE: W0549 may be duplicative when the same header which causes this
776
+ # warning is included twice or more.
776
777
  ensure_uniqueness_of :W0549
777
778
 
778
779
  def initialize(context)
@@ -811,8 +812,8 @@ module Cpp #:nodoc:
811
812
  end
812
813
 
813
814
  class W0554 < PassiveMessageDetection
814
- # NOTE: W0554 may be duplicative when the source file includes the same
815
- # header which has this warning.
815
+ # NOTE: W0554 may be duplicative when the same header which causes this
816
+ # warning is included twice or more.
816
817
  ensure_uniqueness_of :W0554
817
818
 
818
819
  def initialize(context)
@@ -824,13 +825,13 @@ module Cpp #:nodoc:
824
825
  private
825
826
  def check(pragma_line)
826
827
  W(:W0554, pragma_line.location,
827
- pragma_line.pp_tokens.tokens.map { |token| token.value }.join(" "))
828
+ pragma_line.pp_tokens ? pragma_line.pp_tokens.to_s : "")
828
829
  end
829
830
  end
830
831
 
831
832
  class W0574 < PassiveMessageDetection
832
- # NOTE: W0574 may be duplicative when the source file includes the same
833
- # header which has this warning.
833
+ # NOTE: W0574 may be duplicative when the same header which causes this
834
+ # warning is included twice or more.
834
835
  ensure_uniqueness_of :W0574
835
836
 
836
837
  def initialize(context)
@@ -859,8 +860,8 @@ module Cpp #:nodoc:
859
860
  end
860
861
 
861
862
  class W0575 < PassiveMessageDetection
862
- # NOTE: W0575 may be duplicative when the source file includes the same
863
- # header which has this warning.
863
+ # NOTE: W0575 may be duplicative when the same header which causes this
864
+ # warning is included twice or more.
864
865
  ensure_uniqueness_of :W0575
865
866
 
866
867
  def initialize(context)
@@ -889,8 +890,8 @@ module Cpp #:nodoc:
889
890
  end
890
891
 
891
892
  class W0576 < PassiveMessageDetection
892
- # NOTE: W0576 may be duplicative when the source file includes the same
893
- # header which has this warning.
893
+ # NOTE: W0576 may be duplicative when the same header which causes this
894
+ # warning is included twice or more.
894
895
  ensure_uniqueness_of :W0576
895
896
 
896
897
  def initialize(context)
@@ -914,8 +915,8 @@ module Cpp #:nodoc:
914
915
  end
915
916
 
916
917
  class W0577 < PassiveMessageDetection
917
- # NOTE: W0577 may be duplicative when the source file includes the same
918
- # header which has this warning.
918
+ # NOTE: W0577 may be duplicative when the same header which causes this
919
+ # warning is included twice or more.
919
920
  ensure_uniqueness_of :W0577
920
921
 
921
922
  def initialize(context)
@@ -935,8 +936,8 @@ module Cpp #:nodoc:
935
936
  end
936
937
 
937
938
  class W0696 < PassiveMessageDetection
938
- # NOTE: W0696 may be duplicative when the source file includes the same
939
- # header which has references to the undefined macro.
939
+ # NOTE: W0696 may be duplicative when the same header which has references
940
+ # to the undefined macro is included twice or more.
940
941
  ensure_uniqueness_of :W0696
941
942
 
942
943
  def initialize(context)
@@ -948,8 +949,8 @@ module Cpp #:nodoc:
948
949
  end
949
950
 
950
951
  class W0804 < PassiveMessageDetection
951
- # NOTE: W0804 may be duplicative when the source file includes the same
952
- # header which has this warning.
952
+ # NOTE: W0804 may be duplicative when the same header which causes this
953
+ # warning is included twice or more.
953
954
  ensure_uniqueness_of :W0804
954
955
 
955
956
  def initialize(context)
@@ -960,8 +961,8 @@ module Cpp #:nodoc:
960
961
  end
961
962
 
962
963
  class W0831 < PassiveMessageDetection
963
- # NOTE: W0831 may be duplicative when the source file includes the same
964
- # header which has this warning.
964
+ # NOTE: W0831 may be duplicative when the same header which causes this
965
+ # warning is included twice or more.
965
966
  ensure_uniqueness_of :W0831
966
967
 
967
968
  def initialize(context)
@@ -977,8 +978,8 @@ module Cpp #:nodoc:
977
978
  end
978
979
 
979
980
  class W9002 < PassiveMessageDetection
980
- # NOTE: W9002 may be duplicative when the source file includes the same
981
- # header which has no newline at end of the file.
981
+ # NOTE: W9002 may be duplicative when the same header which has no newline
982
+ # at end of the file is included twice or more.
982
983
  ensure_uniqueness_of :W9002
983
984
 
984
985
  def initialize(context)
@@ -0,0 +1,100 @@
1
+ # Message detection classes for C preprocessor language.
2
+ #
3
+ # Author:: Rie Shima <mailto:rkakuuchi@users.sourceforge.net>
4
+ # Copyright:: Copyright (C) 2010-2012, 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-2012, 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/report"
33
+ require "adlint/message"
34
+
35
+ module AdLint #:nodoc:
36
+ module Cpp #:nodoc:
37
+
38
+ class W0688 < PassiveMessageDetection
39
+ # NOTE: W0688 may be duplicative when the same header which causes this
40
+ # warning is included twice or more.
41
+ ensure_uniqueness_of :W0688
42
+
43
+ def initialize(context)
44
+ super
45
+ visitor = context[:cpp_visitor]
46
+ visitor.enter_line_line += method(:check)
47
+ end
48
+
49
+ private
50
+ def check(line_line)
51
+ if line_no_arg = line_no_argument(line_line)
52
+ line_no = Integer(line_no_arg.value)
53
+ unless line_no > 0 && line_no < 32768
54
+ W(:W0688, line_no_arg.location)
55
+ end
56
+ end
57
+ rescue
58
+ end
59
+
60
+ def line_no_argument(line_line)
61
+ line_line.pp_tokens ? line_line.pp_tokens.tokens.first : nil
62
+ end
63
+ end
64
+
65
+ class W0689 < W0688
66
+ # NOTE: W0689 may be duplicative when the same header which causes this
67
+ # warning is included twice or more.
68
+ ensure_uniqueness_of :W0689
69
+
70
+ private
71
+ def check(line_line)
72
+ if fname_arg = file_name_argument(line_line)
73
+ unless fname_arg.value =~ /\A".*"\z/
74
+ W(:W0689, fname_arg.location)
75
+ end
76
+ end
77
+ end
78
+
79
+ def file_name_argument(line_line)
80
+ line_line.pp_tokens ? line_line.pp_tokens.tokens[1] : nil
81
+ end
82
+ end
83
+
84
+ class W0690 < W0688
85
+ # NOTE: W0690 may be duplicative when the same header which causes this
86
+ # warning is included twice or more.
87
+ ensure_uniqueness_of :W0690
88
+
89
+ private
90
+ def check(line_line)
91
+ if line_no_arg = line_no_argument(line_line)
92
+ Integer(line_no_arg.value)
93
+ end
94
+ rescue
95
+ W(:W0690, line_no_arg.location)
96
+ end
97
+ end
98
+
99
+ end
100
+ end
@@ -35,6 +35,7 @@ require "adlint/cpp/lexer"
35
35
  require "adlint/cpp/eval"
36
36
  require "adlint/cpp/code"
37
37
  require "adlint/cpp/message"
38
+ require "adlint/cpp/message_shima"
38
39
  require "adlint/cpp/util"
39
40
 
40
41
  module AdLint #:nodoc:
@@ -99,6 +100,9 @@ module Cpp #:nodoc:
99
100
  W0575.new(context),
100
101
  W0576.new(context),
101
102
  W0577.new(context),
103
+ W0688.new(context),
104
+ W0689.new(context),
105
+ W0690.new(context),
102
106
  W0696.new(context),
103
107
  W0804.new(context),
104
108
  W0831.new(context),
@@ -678,8 +678,12 @@ module Cpp #:nodoc:
678
678
  end
679
679
  end
680
680
 
681
+ def to_s
682
+ @tokens.map { |t| t.value }.join(" ")
683
+ end
684
+
681
685
  def inspect(indent = 0)
682
- " " * indent + @tokens.map { |t| t.value }.join(" ")
686
+ " " * indent + self.to_s
683
687
  end
684
688
  end
685
689
 
data/lib/adlint/cpp.rb CHANGED
@@ -35,6 +35,7 @@ require "adlint/cpp/constexpr"
35
35
  require "adlint/cpp/lexer"
36
36
  require "adlint/cpp/macro"
37
37
  require "adlint/cpp/message"
38
+ require "adlint/cpp/message_shima"
38
39
  require "adlint/cpp/phase"
39
40
  require "adlint/cpp/scanner"
40
41
  require "adlint/cpp/source"
@@ -312,9 +312,12 @@ module AdLint #:nodoc:
312
312
  # === RETURN VALUE
313
313
  # None.
314
314
  def validate_version(version)
315
- version =~ SCHEMA_VERSION_RE or
316
- raise "invalid version of the message definition file."
317
- nil
315
+ # NOTE: Version field of the message catalog does not mean the schema
316
+ # version of the catalog file, but a revision number of the catalog
317
+ # contents.
318
+ # When AdLint is installed normally, the schema version of the
319
+ # catalog is always valid. So, schema version validation is
320
+ # unnecessary.
318
321
  end
319
322
  end
320
323
 
data/lib/adlint/traits.rb CHANGED
@@ -94,7 +94,7 @@ module AdLint #:nodoc:
94
94
 
95
95
  private
96
96
  def validate_version(version)
97
- version =~ SCHEMA_VERSION_RE or
97
+ version == TRAITS_SCHEMA_VERSION or
98
98
  raise "invalid version of the trailts file."
99
99
  end
100
100
  end
@@ -32,16 +32,16 @@
32
32
  module AdLint #:nodoc:
33
33
 
34
34
  MAJOR_VERSION = 1
35
- MINOR_VERSION = 0
35
+ MINOR_VERSION = 2
36
36
  PATCH_VERSION = 0
37
- RELEASE_DATE = "2012-02-28"
37
+ RELEASE_DATE = "2012-03-21"
38
+
39
+ TRAITS_SCHEMA_VERSION = "1.0.0"
38
40
 
39
41
  SHORT_VERSION = "#{MAJOR_VERSION}.#{MINOR_VERSION}.#{PATCH_VERSION}"
40
42
 
41
43
  VERSION = "#{SHORT_VERSION} (#{RELEASE_DATE})"
42
44
 
43
- SCHEMA_VERSION_RE = /\A#{MAJOR_VERSION}\.#{MINOR_VERSION}\.\d+\z/
44
-
45
45
  COPYRIGHT = <<EOS
46
46
  ___ ____ __ ___ _________
47
47
  / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
@@ -64,7 +64,7 @@ module AdLint #:nodoc:
64
64
  EOS
65
65
 
66
66
  AUTHOR = <<EOS
67
- Written by Yutaka Yanoh and Code Quality Assessment Team of OGIS-RI Co.,Ltd.
67
+ Written by Yutaka Yanoh, Rie Shima and Code Quality Assessment Team of OGIS-RI Co.,Ltd.
68
68
 
69
69
  EOS
70
70
 
data/share/demo/Makefile CHANGED
@@ -10,6 +10,7 @@ bad_const \
10
10
  bad_conv \
11
11
  bad_indent \
12
12
  bad_init \
13
+ bad_line \
13
14
  bad_macro \
14
15
  bitwise_expr \
15
16
  call_by_value \
@@ -25,8 +26,8 @@ funptr_cast \
25
26
  goto_stmt \
26
27
  id_hiding \
27
28
  ill_defined \
28
- implicit_int \
29
29
  implicit_conv \
30
+ implicit_int \
30
31
  incomplete_type \
31
32
  indirect_recur \
32
33
  intro_demo \
@@ -58,6 +59,7 @@ output_by_param \
58
59
  overflow \
59
60
  press_release \
60
61
  retn_lvar_addr \
62
+ sequence_point \
61
63
  shift_expr \
62
64
  should_be_typedef \
63
65
  static_paths \