adlint 3.2.12 → 3.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa76355096835da637b733c8206bf5d759f01147
4
- data.tar.gz: 8fa414fe9df4b715c950d45c07ace9d5a1356ac4
3
+ metadata.gz: 19b04362c16725a14ece81a1a134249d5c2a40b7
4
+ data.tar.gz: 88a544e882ba9894ee16157877c87012d0bd1b56
5
5
  SHA512:
6
- metadata.gz: eb322d1d2e7d67215b23706ba00f3509386f2ba06f661816001867fa7513d63e34498afbb4cb1824591871b91a3ae3d4119ed6dd3127491719030c98e33c291c
7
- data.tar.gz: 19c980d7ef83983142b54430609941a6fefec254cbb674f3dac9041db64bcd093b60081ca555b4d887cd4e55ff87b395c0155b684a8fb6de75f13f65f8846db3
6
+ metadata.gz: 09541b8c4bbbd384a19abc83492cbbc0daf5715d869275bf88bb76e3eebd1392d2c252368a55790e9bd0fce10eb46e322a702214a734300f72d0437d156cc78c
7
+ data.tar.gz: 83cd114a46a2e0e494116ea0544fd494d558aa58cd15458f9e03405ce6f0ee48d4adddc2853d28dc97e24998f391f58b8a7fe132df3503aaf298aa510aecd900
data/ChangeLog CHANGED
@@ -1,3 +1,30 @@
1
+ Sat May 10 22:31:55 2014 Yutaka Yanoh <yanoh@users.sourceforge.net>
2
+
3
+ * release.ga : 3.2.14
4
+ - Support function-like macro replacement with variable arguments.
5
+
6
+ Sat May 10 22:07:09 2014 Yutaka Yanoh <yanoh@users.sourceforge.net>
7
+
8
+ * lib/adlint/cpp/macro.rb : Revise behavior of function-like macro
9
+ replacement in order to enforce the replacement even if the number of
10
+ arguments is less than the number of parameters.
11
+ * features/code_check/W0830.feature : Ditto.
12
+
13
+ Sat May 10 13:58:35 2014 Yutaka Yanoh <yanoh@users.sourceforge.net>
14
+
15
+ * release.rc : 3.2.13
16
+ - Support function-like macro replacement with variable arguments.
17
+
18
+ Sat May 10 12:44:20 2014 Yutaka Yanoh <yanoh@users.sourceforge.net>
19
+
20
+ * lib/adlint/cpp/macro.rb : Support function-like macro replacement
21
+ with variable arguments.
22
+ * lib/adlint/cpp/eval.rb : Ditto.
23
+
24
+ * features/code_check/W0835.feature : Add scenario to check that the
25
+ function-like macro with __VA_ARGS__ can be replaced correctly.
26
+ * MANIFEST : Ditto.
27
+
1
28
  Sat Apr 12 09:08:17 2014 Yutaka Yanoh <yanoh@users.sourceforge.net>
2
29
 
3
30
  * release.ga : 3.2.12
data/MANIFEST CHANGED
@@ -329,6 +329,7 @@ features/code_check/W0811.feature
329
329
  features/code_check/W0830.feature
330
330
  features/code_check/W0833.feature
331
331
  features/code_check/W0834.feature
332
+ features/code_check/W0835.feature
332
333
  features/code_check/W1026.feature
333
334
  features/code_check/W1030.feature
334
335
  features/code_check/W1031.feature
data/NEWS CHANGED
@@ -21,6 +21,15 @@
21
21
 
22
22
  ++
23
23
 
24
+ === \AdLint 3.2.14 is released (2014-05-10)
25
+
26
+ ==== Changes since the 3.2.12 release
27
+
28
+ * Support function-like macro replacement with variable arguments.
29
+
30
+ See the file {ChangeLog}[https://github.com/yanoh/adlint/blob/master/ChangeLog]
31
+ for more details.
32
+
24
33
  === \AdLint 3.2.12 is released (2014-04-12)
25
34
 
26
35
  ==== Changes since the 3.2.10 release
@@ -31,9 +40,6 @@
31
40
  * Revise behavior of the CMA code structure collection so that an optional
32
41
  examination package can output its own special met-records
33
42
 
34
- See the file {ChangeLog}[https://github.com/yanoh/adlint/blob/master/ChangeLog]
35
- for more details.
36
-
37
43
  === \AdLint 3.2.10 is released (2014-02-17)
38
44
 
39
45
  ==== Changes since the 3.2.8 release
@@ -49,7 +49,7 @@
49
49
  # - "ERR:X99"
50
50
  # format: "Your custom message for the error of E9999."
51
51
 
52
- version: "3.2.12"
52
+ version: "3.2.14"
53
53
 
54
54
  message_definition:
55
55
  W0001:
@@ -49,7 +49,7 @@
49
49
  # - "ERR:X99"
50
50
  # format: "Your custom message for the error of E9999."
51
51
 
52
- version: "3.2.12"
52
+ version: "3.2.14"
53
53
 
54
54
  message_definition:
55
55
  W0001:
@@ -49,7 +49,7 @@
49
49
  # - "ERR:X99"
50
50
  # format: "Your custom message for the error of E9999."
51
51
 
52
- version: "3.2.12"
52
+ version: "3.2.14"
53
53
 
54
54
  message_definition:
55
55
  X0001:
@@ -49,7 +49,7 @@
49
49
  # - "ERR:X99"
50
50
  # format: "Your custom message for the error of E9999."
51
51
 
52
- version: "3.2.12"
52
+ version: "3.2.14"
53
53
 
54
54
  message_definition:
55
55
  X0001:
@@ -0,0 +1,127 @@
1
+ Feature: W0835
2
+
3
+ W0835 detects that a function like macro with variable arguments is defined.
4
+
5
+ Scenario: function declaration helper macro
6
+ Given a target source named "fixture.c" with:
7
+ """
8
+ #define defun(type, name, ...) /* W0835 has not been implemented yet */ \
9
+ extern type builtin_##name(__VA_ARGS__)
10
+
11
+ defun(int, foo, int);
12
+ defun(long, bar, int, long);
13
+ defun(int, baz);
14
+ """
15
+ When I successfully run `adlint fixture.c` on noarch
16
+ Then the output should exactly match with:
17
+ | mesg | line | column |
18
+ | W0442 | 1 | 1 |
19
+ | W0549 | 2 | 12 |
20
+ | W0118 | 4 | 1 |
21
+ | W0118 | 5 | 1 |
22
+ | W0118 | 6 | 1 |
23
+ | W0478 | 1 | 1 |
24
+ | W0078 | 6 | 1 |
25
+
26
+ Scenario: initializer generator macro
27
+ Given a target source named "fixture.c" with:
28
+ """
29
+ #define init(...) /* W0835 has not been implemented yet */ \
30
+ { 0, __VA_ARGS__, -1 }
31
+
32
+ int a[] = init(1, 2, 3);
33
+ """
34
+ When I successfully run `adlint fixture.c` on noarch
35
+ Then the output should exactly match with:
36
+ | mesg | line | column |
37
+ | W0442 | 1 | 1 |
38
+ | W0117 | 4 | 5 |
39
+
40
+ Scenario: initializer generator macro with ## operator
41
+ Given a target source named "fixture.c" with:
42
+ """
43
+ #define init(...) /* W0835 has not been implemented yet */ \
44
+ { 0, ## __VA_ARGS__, -1 }
45
+
46
+ int a[] = init(1, 2, 3);
47
+ """
48
+ When I successfully run `adlint fixture.c` on noarch
49
+ Then the output should exactly match with:
50
+ | mesg | line | column |
51
+ | W0442 | 1 | 1 |
52
+ | W0691 | 4 | 11 |
53
+ | W0117 | 4 | 5 |
54
+
55
+ Scenario: interface to a varg function
56
+ Given a target source named "fixture.c" with:
57
+ """
58
+ extern int printf(const char *, ...);
59
+ extern const char *mesg(int);
60
+
61
+ #define msg(n) mesg(100 + (n))
62
+ #define log(fmt, ...) /* W0835 has not been implemented yet */ \
63
+ (void) printf((fmt), __VA_ARGS__)
64
+
65
+ static void func(void)
66
+ {
67
+ log("%d %d", 1, 2);
68
+ log("%d %s %s", 1, msg(1), msg(1 + 2));
69
+ }
70
+ """
71
+ When I successfully run `adlint fixture.c` on noarch
72
+ Then the output should exactly match with:
73
+ | mesg | line | column |
74
+ | W0442 | 4 | 1 |
75
+ | W0442 | 5 | 1 |
76
+ | W0118 | 1 | 12 |
77
+ | W0118 | 2 | 20 |
78
+ | W1076 | 8 | 13 |
79
+ | W0629 | 8 | 13 |
80
+ | W0443 | 4 | 1 |
81
+ | W0628 | 8 | 13 |
82
+
83
+ Scenario: interface to a varg function with ## operator
84
+ Given a target source named "fixture.c" with:
85
+ """
86
+ extern int printf(const char *, ...);
87
+ extern const char *mesg(int);
88
+
89
+ #define msg(n) mesg(100 + (n))
90
+ #define log(fmt, ...) /* W0835 has not been implemented yet */ \
91
+ (void) printf((fmt), ##__VA_ARGS__)
92
+
93
+ static void func(void)
94
+ {
95
+ log("%d %d", 1, 2);
96
+ log("%d %s %s", 1, msg(1), msg(1 + 2));
97
+ }
98
+ """
99
+ When I successfully run `adlint fixture.c` on noarch
100
+ Then the output should exactly match with:
101
+ | mesg | line | column |
102
+ | W0442 | 4 | 1 |
103
+ | W0442 | 5 | 1 |
104
+ | W0691 | 10 | 5 |
105
+ | W0691 | 11 | 5 |
106
+ | W0118 | 1 | 12 |
107
+ | W0118 | 2 | 20 |
108
+ | W1076 | 8 | 13 |
109
+ | W0629 | 8 | 13 |
110
+ | W0443 | 4 | 1 |
111
+ | W0628 | 8 | 13 |
112
+
113
+ Scenario: ill-formed macro call with too few arguments
114
+ Given a target source named "fixture.c" with:
115
+ """
116
+ #define init(a, b, ...) { 0, a, b, __VA_ARGS__ }
117
+ int a[] = init(1);
118
+ """
119
+ When I successfully run `adlint fixture.c` on noarch
120
+ Then the output should exactly match with:
121
+ | mesg | line | column |
122
+ | W0442 | 1 | 1 |
123
+ | W0549 | 1 | 30 |
124
+ | W0549 | 1 | 33 |
125
+ | W0109 | 2 | 11 |
126
+ | W9003 | 2 | 11 |
127
+ | W0117 | 2 | 5 |
@@ -441,13 +441,13 @@ module Cpp #:nodoc:
441
441
  repl_list = replacement_list(pp_ctxt)
442
442
  discard_extra_tokens_until_newline(pp_ctxt)
443
443
  if ellipsis
444
- define_line = VaFunctionLikeDefineLine.new(keyword, id, id_list,
445
- repl_list, sym)
446
- macro = FunctionLikeMacro.new(define_line)
444
+ define_line =
445
+ VaFunctionLikeDefineLine.new(keyword, id, id_list, repl_list, sym)
446
+ macro = VaFunctionLikeMacro.new(define_line)
447
447
  notify_va_function_like_macro_defined(define_line, macro)
448
448
  else
449
- define_line = FunctionLikeDefineLine.new(keyword, id, id_list,
450
- repl_list, sym)
449
+ define_line =
450
+ FunctionLikeDefineLine.new(keyword, id, id_list, repl_list, sym)
451
451
  macro = FunctionLikeMacro.new(define_line)
452
452
  notify_function_like_macro_defined(define_line, macro)
453
453
  end
@@ -109,16 +109,16 @@ module Cpp #:nodoc:
109
109
  attr_reader :parameter_names
110
110
 
111
111
  def replaceable_size(toks)
112
- return 0 unless name.value == toks.first.value
113
- args, idx = parse_arguments(toks, 1)
114
- case
115
- when args && @parameter_names.empty?
116
- idx + 1
117
- when args && @parameter_names.size >= args.size
118
- idx + 1
119
- else
120
- 0
112
+ if name.value == toks.first.value
113
+ args, idx = parse_arguments(toks, 1)
114
+ case
115
+ when args && @parameter_names.empty?
116
+ return idx + 1
117
+ when args && @parameter_names.size >= args.size
118
+ return idx + 1
119
+ end
121
120
  end
121
+ 0
122
122
  end
123
123
 
124
124
  def expand(toks, macro_tbl, repl_ctxt)
@@ -394,6 +394,45 @@ module Cpp #:nodoc:
394
394
  end
395
395
  end
396
396
 
397
+ class VaFunctionLikeMacro < FunctionLikeMacro
398
+ def replaceable_size(toks)
399
+ if name.value == toks.first.value
400
+ args, idx = parse_arguments(toks, 1)
401
+ args ? idx + 1 : 0
402
+ else
403
+ 0
404
+ end
405
+ end
406
+
407
+ def expand(toks, macro_tbl, repl_ctxt)
408
+ super
409
+
410
+ all_args, * = parse_arguments(toks, 1)
411
+ args = all_args.shift(@parameter_names.size)
412
+ rest_args = all_args
413
+
414
+ args_hash =
415
+ @parameter_names.zip(args).each_with_object({}) { |(param, arg), hash|
416
+ hash[param] = arg
417
+ }
418
+
419
+ va_args = args_hash["__VA_ARGS__"] = []
420
+ unless rest_args.empty?
421
+ va_args.concat(rest_args.shift)
422
+ rest_args.each do |arg|
423
+ va_args.push(ReplacedToken.new(:PP_TOKEN, ",", Location.new))
424
+ va_args.concat(arg)
425
+ end
426
+ end
427
+
428
+ rslt_toks = expand_replacement_list(args_hash, toks.first.location,
429
+ macro_tbl, repl_ctxt)
430
+ macro_tbl.notify_function_like_macro_replacement(self, toks, args,
431
+ rslt_toks)
432
+ rslt_toks
433
+ end
434
+ end
435
+
397
436
  class SpecialMacro < ObjectLikeMacro
398
437
  def initialize(name_str)
399
438
  super(PseudoObjectLikeDefineLine.new(name_str))
@@ -33,8 +33,8 @@ module AdLint #:nodoc:
33
33
 
34
34
  MAJOR_VERSION = 3
35
35
  MINOR_VERSION = 2
36
- PATCH_VERSION = 12
37
- RELEASE_DATE = "2014-04-12"
36
+ PATCH_VERSION = 14
37
+ RELEASE_DATE = "2014-05-10"
38
38
 
39
39
  TRAITS_SCHEMA_VERSION = "3.0.0"
40
40
 
@@ -1,8 +1,8 @@
1
1
  <html lang="ja">
2
2
  <head>
3
- <title>AdLint 3.2.12 開発者ガイド</title>
3
+ <title>AdLint 3.2.14 開発者ガイド</title>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
- <meta name="description" content="AdLint 3.2.12 開発者ガイド">
5
+ <meta name="description" content="AdLint 3.2.14 開発者ガイド">
6
6
  <meta name="generator" content="makeinfo 4.13">
7
7
  <link title="Top" rel="top" href="#Top">
8
8
  <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
@@ -44,7 +44,7 @@ td { border: 1px solid black; }
44
44
  --></style>
45
45
  </head>
46
46
  <body>
47
- <h1 class="settitle">AdLint 3.2.12 開発者ガイド</h1>
47
+ <h1 class="settitle">AdLint 3.2.14 開発者ガイド</h1>
48
48
  <div class="contents">
49
49
  <h2>Table of Contents</h2>
50
50
  <ul>
@@ -2,7 +2,7 @@
2
2
  @setfilename developers_guide_ja.info
3
3
  @documentlanguage ja
4
4
  @documentencoding utf-8
5
- @settitle AdLint 3.2.12 開発者ガイド
5
+ @settitle AdLint 3.2.14 開発者ガイド
6
6
 
7
7
  @copying
8
8
  Copyright (C) 2010-2014, OGIS-RI Co.,Ltd.
@@ -1,8 +1,8 @@
1
1
  <html lang="en">
2
2
  <head>
3
- <title>AdLint 3.2.12 User's Guide</title>
3
+ <title>AdLint 3.2.14 User's Guide</title>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
- <meta name="description" content="AdLint 3.2.12 User's Guide">
5
+ <meta name="description" content="AdLint 3.2.14 User's Guide">
6
6
  <meta name="generator" content="makeinfo 4.13">
7
7
  <link title="Top" rel="top" href="#Top">
8
8
  <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
@@ -44,7 +44,7 @@ td { border: 1px solid black; }
44
44
  --></style>
45
45
  </head>
46
46
  <body>
47
- <h1 class="settitle">AdLint 3.2.12 User's Guide</h1>
47
+ <h1 class="settitle">AdLint 3.2.14 User's Guide</h1>
48
48
  <div class="node">
49
49
  <a name="Top"></a>
50
50
  <p><hr>
@@ -2,7 +2,7 @@
2
2
  @setfilename users_guide_en.info
3
3
  @documentlanguage en
4
4
  @documentencoding utf-8
5
- @settitle AdLint 3.2.12 User's Guide
5
+ @settitle AdLint 3.2.14 User's Guide
6
6
 
7
7
  @copying
8
8
  Copyright (C) 2010-2014, OGIS-RI Co.,Ltd.
@@ -1,8 +1,8 @@
1
1
  <html lang="ja">
2
2
  <head>
3
- <title>AdLint 3.2.12 利用者ガイド</title>
3
+ <title>AdLint 3.2.14 利用者ガイド</title>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
- <meta name="description" content="AdLint 3.2.12 利用者ガイド">
5
+ <meta name="description" content="AdLint 3.2.14 利用者ガイド">
6
6
  <meta name="generator" content="makeinfo 4.13">
7
7
  <link title="Top" rel="top" href="#Top">
8
8
  <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
@@ -44,7 +44,7 @@ td { border: 1px solid black; }
44
44
  --></style>
45
45
  </head>
46
46
  <body>
47
- <h1 class="settitle">AdLint 3.2.12 利用者ガイド</h1>
47
+ <h1 class="settitle">AdLint 3.2.14 利用者ガイド</h1>
48
48
  <div class="node">
49
49
  <a name="Top"></a>
50
50
  <p><hr>
@@ -2,7 +2,7 @@
2
2
  @setfilename users_guide_ja.info
3
3
  @documentlanguage ja
4
4
  @documentencoding utf-8
5
- @settitle AdLint 3.2.12 利用者ガイド
5
+ @settitle AdLint 3.2.14 利用者ガイド
6
6
 
7
7
  @copying
8
8
  Copyright (C) 2010-2014, OGIS-RI Co.,Ltd.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adlint
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.12
4
+ version: 3.2.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yutaka Yanoh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-12 00:00:00.000000000 Z
11
+ date: 2014-05-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  AdLint is a source code static analyzer.
@@ -356,6 +356,7 @@ files:
356
356
  - features/code_check/W0830.feature
357
357
  - features/code_check/W0833.feature
358
358
  - features/code_check/W0834.feature
359
+ - features/code_check/W0835.feature
359
360
  - features/code_check/W1026.feature
360
361
  - features/code_check/W1030.feature
361
362
  - features/code_check/W1031.feature