adlint 1.8.10 → 1.10.0
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.
- data/ChangeLog +261 -3
- data/MANIFEST +25 -1
- data/NEWS +25 -5
- data/Rakefile +11 -0
- data/TODO +0 -1
- data/etc/mesg.d/en_US/messages.yml +1 -1
- data/etc/mesg.d/ja_JP/messages.yml +1 -1
- data/features/message_detection/W0001.feature +41 -0
- data/features/message_detection/W0002.feature +68 -0
- data/features/message_detection/W0003.feature +134 -0
- data/features/message_detection/W0007.feature +264 -0
- data/features/message_detection/W0010.feature +75 -0
- data/features/message_detection/W0013.feature +189 -0
- data/features/message_detection/W0109.feature +50 -0
- data/features/message_detection/W0583.feature +30 -0
- data/features/message_detection/W0606.feature +20 -0
- data/features/message_detection/W0698.feature +20 -0
- data/features/message_detection/W0699.feature +21 -0
- data/features/message_detection/W0703.feature +73 -0
- data/features/message_detection/W0716.feature +67 -0
- data/features/message_detection/W0717.feature +64 -0
- data/features/message_detection/W0718.feature +64 -0
- data/features/message_detection/W0723.feature +18 -0
- data/features/message_detection/W1031.feature +328 -0
- data/features/step_definitions/message_detection_steps.rb +45 -0
- data/features/support/env.rb +58 -0
- data/lib/adlint/c/branch.rb +16 -23
- data/lib/adlint/c/code.rb +1 -12
- data/lib/adlint/c/conv.rb +4 -4
- data/lib/adlint/c/ctrlexpr.rb +10 -6
- data/lib/adlint/c/domain.rb +2 -2
- data/lib/adlint/c/expr.rb +11 -33
- data/lib/adlint/c/format.rb +6 -6
- data/lib/adlint/c/interp.rb +137 -80
- data/lib/adlint/c/mediator.rb +5 -2
- data/lib/adlint/c/message.rb +123 -140
- data/lib/adlint/c/message_shima.rb +44 -0
- data/lib/adlint/c/object.rb +93 -26
- data/lib/adlint/c/option.rb +53 -0
- data/lib/adlint/c/phase.rb +4 -1
- data/lib/adlint/c/type.rb +112 -46
- data/lib/adlint/c.rb +1 -0
- data/lib/adlint/version.rb +3 -3
- data/share/doc/developers_guide_ja.html +3 -3
- data/share/doc/developers_guide_ja.texi +1 -1
- data/share/doc/users_guide_en.html +35 -28
- data/share/doc/users_guide_en.texi +30 -22
- data/share/doc/users_guide_ja.html +35 -31
- data/share/doc/users_guide_ja.texi +30 -24
- data/spec/adlint/c/type_spec.rb +110 -0
- data/spec/conf.d/default_traits.yml +216 -0
- data/spec/conf.d/empty_cinit.h +11 -0
- data/spec/conf.d/empty_pinit.h +11 -0
- data/spec/spec_helper.rb +49 -0
- metadata +27 -3
- data/spec/MUST_WRITE_SPECS_WITH_RSPEC +0 -0
data/lib/adlint/c/object.rb
CHANGED
@@ -100,20 +100,23 @@ module C #:nodoc:
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def declared_as_extern?
|
103
|
-
|
104
|
-
|
103
|
+
first_sc_spec = first_storage_class_specifier
|
104
|
+
first_sc_spec.nil? || first_sc_spec.type == :EXTERN
|
105
105
|
end
|
106
106
|
|
107
107
|
def declared_as_static?
|
108
|
-
|
108
|
+
first_sc_spec = first_storage_class_specifier and
|
109
|
+
first_sc_spec.type == :STATIC
|
109
110
|
end
|
110
111
|
|
111
112
|
def declared_as_auto?
|
112
|
-
|
113
|
+
first_sc_spec = first_storage_class_specifier and
|
114
|
+
first_sc_spec.type == :AUTO
|
113
115
|
end
|
114
116
|
|
115
117
|
def declared_as_register?
|
116
|
-
|
118
|
+
first_sc_spec = first_storage_class_specifier and
|
119
|
+
first_sc_spec.type == :REGISTER
|
117
120
|
end
|
118
121
|
|
119
122
|
def designated_by_lvalue?
|
@@ -135,6 +138,15 @@ module C #:nodoc:
|
|
135
138
|
def variable?
|
136
139
|
subclass_responsibility
|
137
140
|
end
|
141
|
+
|
142
|
+
private
|
143
|
+
def first_storage_class_specifier
|
144
|
+
if @declarations_and_definitions.empty?
|
145
|
+
nil
|
146
|
+
else
|
147
|
+
@declarations_and_definitions.first.storage_class_specifier
|
148
|
+
end
|
149
|
+
end
|
138
150
|
end
|
139
151
|
|
140
152
|
class TypedObject < Object
|
@@ -263,7 +275,8 @@ module C #:nodoc:
|
|
263
275
|
if @scope.global?
|
264
276
|
super
|
265
277
|
else
|
266
|
-
|
278
|
+
first_sc_spec = first_storage_class_specifier and
|
279
|
+
first_sc_spec.type == :EXTERN
|
267
280
|
end
|
268
281
|
end
|
269
282
|
|
@@ -271,8 +284,8 @@ module C #:nodoc:
|
|
271
284
|
if @scope.global?
|
272
285
|
super
|
273
286
|
else
|
274
|
-
|
275
|
-
|
287
|
+
first_sc_spec = first_storage_class_specifier
|
288
|
+
first_sc_spec.nil? || first_sc_spec.type == :AUTO
|
276
289
|
end
|
277
290
|
end
|
278
291
|
end
|
@@ -595,8 +608,8 @@ module C #:nodoc:
|
|
595
608
|
end
|
596
609
|
|
597
610
|
def define(definition, init_value = nil)
|
598
|
-
if
|
599
|
-
# NOTE: Value of the
|
611
|
+
if storage_duration_of(definition) == :static
|
612
|
+
# NOTE: Value of the static duration object should be arbitrary because
|
600
613
|
# execution of its accessors are out of order.
|
601
614
|
# So, a value of the initializer should be ignored.
|
602
615
|
init_value = definition.type.arbitrary_value
|
@@ -614,8 +627,8 @@ module C #:nodoc:
|
|
614
627
|
|
615
628
|
# NOTE: Domain of the init-value will be restricted by type's min-max in
|
616
629
|
# define_variable.
|
617
|
-
define_variable(definition, definition.type,
|
618
|
-
init_value)
|
630
|
+
define_variable(definition, definition.type,
|
631
|
+
allocate_memory(definition), init_value)
|
619
632
|
end
|
620
633
|
|
621
634
|
def define_temporary(type, init_value)
|
@@ -667,6 +680,63 @@ module C #:nodoc:
|
|
667
680
|
end
|
668
681
|
end
|
669
682
|
|
683
|
+
def storage_duration_of(declaration_or_definition)
|
684
|
+
# NOTE: The ISO C99 standard saids;
|
685
|
+
#
|
686
|
+
# 6.2.2 Linkages of identifiers
|
687
|
+
#
|
688
|
+
# 1 An identifier declared in different scopes or in the same scope more
|
689
|
+
# than once can be made to refer to the same object or function by a
|
690
|
+
# process called linkage. There are three kinds of linkage: external,
|
691
|
+
# internal, and none.
|
692
|
+
#
|
693
|
+
# 3 If the declaration of a file scope identifier for an object or a
|
694
|
+
# function contains the storage-class specifier static, the identifier
|
695
|
+
# has internal linkage.
|
696
|
+
#
|
697
|
+
# 4 For an identifier declared with the storage-class specifier extern in
|
698
|
+
# a scope in which a prior declaration of that identifier is visible,
|
699
|
+
# if the prior declaration specifies internal or external linkage, the
|
700
|
+
# linkage of the identifier at the later declaration is the same as the
|
701
|
+
# linkage specified at the prior declaration. If no prior declaration
|
702
|
+
# is visible, or if the prior declaration specifies no linkage, then
|
703
|
+
# the identifier has external linkage.
|
704
|
+
#
|
705
|
+
# 5 If the declaration of an identifier for a function has no
|
706
|
+
# storage-class specifier, its linkage is determined exactly as if it
|
707
|
+
# were declared with the storage-class specifier extern. If the
|
708
|
+
# declaration of an identifier for an object has file scope and no
|
709
|
+
# storage-class specifier, its linkage is external.
|
710
|
+
#
|
711
|
+
# 6 The following identifiers have no linkage: an identifier declared to
|
712
|
+
# be anything other than an object or a function; an identifier
|
713
|
+
# declared to be a function parameter; a block scope identifier for an
|
714
|
+
# object declared without the storage-class specifier extern.
|
715
|
+
#
|
716
|
+
# 6.2.4 Storage durations of objects
|
717
|
+
#
|
718
|
+
# 1 An object has a storage duration that determines its lifetime. There
|
719
|
+
# are three storage durations: static, automatic, and allocated.
|
720
|
+
# Allocated storage is described in 7.20.3.
|
721
|
+
#
|
722
|
+
# 3 An object whose identifier is declared with external or internal
|
723
|
+
# linkage, or with the storage-class specifier static has static
|
724
|
+
# storage duration. Its lifetime is the entire execution of the program
|
725
|
+
# and its stored value is initialized only once, prior to program
|
726
|
+
# startup.
|
727
|
+
#
|
728
|
+
# 4 An object whose identifier is declared with no linkage and without
|
729
|
+
# the storage-class specifier static has automatic storage duration.
|
730
|
+
|
731
|
+
sc_specifier = declaration_or_definition.storage_class_specifier
|
732
|
+
if sc_specifier &&
|
733
|
+
(sc_specifier.type == :EXTERN || sc_specifier.type == :STATIC)
|
734
|
+
:static
|
735
|
+
else
|
736
|
+
current_scope.global? ? :static : :automatic
|
737
|
+
end
|
738
|
+
end
|
739
|
+
|
670
740
|
private
|
671
741
|
def define_variable(declaration_or_definition, type, memory, init_value)
|
672
742
|
variable = create_variable(declaration_or_definition, type, memory)
|
@@ -683,25 +753,13 @@ module C #:nodoc:
|
|
683
753
|
|
684
754
|
def allocate_memory(declaration_or_definition)
|
685
755
|
byte_size = declaration_or_definition.type.aligned_byte_size
|
686
|
-
if
|
756
|
+
if storage_duration_of(declaration_or_definition) == :static
|
687
757
|
@memory_pool.allocate_static(byte_size)
|
688
758
|
else
|
689
759
|
@memory_pool.allocate_dynamic(byte_size)
|
690
760
|
end
|
691
761
|
end
|
692
762
|
|
693
|
-
def storage_class_of(declaration_or_definition)
|
694
|
-
storage_class_specifier =
|
695
|
-
declaration_or_definition.storage_class_specifier
|
696
|
-
if storage_class_specifier &&
|
697
|
-
(storage_class_specifier.type == :EXTERN ||
|
698
|
-
storage_class_specifier.type == :STATIC)
|
699
|
-
:static
|
700
|
-
else
|
701
|
-
current_scope.global? ? :static : :dynamic
|
702
|
-
end
|
703
|
-
end
|
704
|
-
|
705
763
|
def create_variable(declaration_or_definition, type, memory)
|
706
764
|
if declaration_or_definition
|
707
765
|
NamedVariable.new(memory, declaration_or_definition, current_scope)
|
@@ -797,7 +855,7 @@ module C #:nodoc:
|
|
797
855
|
when arg.type.function? && param_type.pointer?
|
798
856
|
arg_value = interpreter.pointer_value_of(arg)
|
799
857
|
converted = interpreter.temporary_variable(param_type, arg_value)
|
800
|
-
when arg.variable? && !
|
858
|
+
when arg.variable? && !arg.type.same_as?(param_type)
|
801
859
|
converted =
|
802
860
|
interpreter.do_conversion(arg, param_type) ||
|
803
861
|
interpreter.temporary_variable(param_type)
|
@@ -960,6 +1018,15 @@ module C #:nodoc:
|
|
960
1018
|
@scope_stack.pop
|
961
1019
|
end
|
962
1020
|
|
1021
|
+
def declare(declaration)
|
1022
|
+
if function = lookup(declaration.identifier.value)
|
1023
|
+
function.declarations_and_definitions.push(declaration)
|
1024
|
+
return function
|
1025
|
+
end
|
1026
|
+
|
1027
|
+
define(ExplicitFunction.new(declaration))
|
1028
|
+
end
|
1029
|
+
|
963
1030
|
def define(function)
|
964
1031
|
# NOTE: A function has a starting address in the TEXT segment.
|
965
1032
|
# This is ad-hoc implementation, but it's enough for analysis.
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# Miscellaneous option constants.
|
2
|
+
#
|
3
|
+
# Author:: Yutaka Yanoh <mailto:yanoh@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:: Yutaka Yanoh <mailto:yanoh@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
|
+
module AdLint #:nodoc:
|
33
|
+
module C #:nodoc:
|
34
|
+
|
35
|
+
module InterpreterOptions
|
36
|
+
QUIET = :quiet
|
37
|
+
end
|
38
|
+
|
39
|
+
module BranchOptions
|
40
|
+
NARROWING = :narrowing
|
41
|
+
WIDENING = :widening
|
42
|
+
FIRST = :first
|
43
|
+
FINAL = :final
|
44
|
+
SMOTHER_BREAK = :smother_break
|
45
|
+
IMPLICIT_CONDITION = :implicit_condition
|
46
|
+
end
|
47
|
+
|
48
|
+
module BranchGroupOptions
|
49
|
+
COMPLETE = :complete
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
data/lib/adlint/c/phase.rb
CHANGED
@@ -641,6 +641,9 @@ module C #:nodoc:
|
|
641
641
|
W0713.new(context),
|
642
642
|
W0714.new(context),
|
643
643
|
W0715.new(context),
|
644
|
+
W0716.new(context),
|
645
|
+
W0717.new(context),
|
646
|
+
W0718.new(context),
|
644
647
|
W0720.new(context),
|
645
648
|
W0721.new(context),
|
646
649
|
W0722.new(context),
|
@@ -747,7 +750,7 @@ module C #:nodoc:
|
|
747
750
|
private
|
748
751
|
def do_execute(context)
|
749
752
|
monitored_region("int") do
|
750
|
-
context[:c_interpreter]
|
753
|
+
Program.new(context[:c_interpreter], context[:c_syntax_tree]).execute
|
751
754
|
ValueDomain.clear_memo
|
752
755
|
end
|
753
756
|
ensure
|
data/lib/adlint/c/type.rb
CHANGED
@@ -35,6 +35,7 @@ require "adlint/c/syntax"
|
|
35
35
|
require "adlint/c/scope"
|
36
36
|
require "adlint/c/object"
|
37
37
|
require "adlint/c/conv"
|
38
|
+
require "adlint/c/option"
|
38
39
|
|
39
40
|
module AdLint #:nodoc:
|
40
41
|
module C #:nodoc:
|
@@ -200,14 +201,22 @@ module C #:nodoc:
|
|
200
201
|
subclass_responsibility
|
201
202
|
end
|
202
203
|
|
203
|
-
def compatible?(
|
204
|
+
def compatible?(to_type)
|
204
205
|
subclass_responsibility
|
205
206
|
end
|
206
207
|
|
207
|
-
def coercible?(
|
208
|
+
def coercible?(to_type)
|
208
209
|
subclass_responsibility
|
209
210
|
end
|
210
211
|
|
212
|
+
def convertible?(to_type)
|
213
|
+
self.same_as?(to_type)
|
214
|
+
end
|
215
|
+
|
216
|
+
def more_cv_qualified?(than_type)
|
217
|
+
false
|
218
|
+
end
|
219
|
+
|
211
220
|
def same_as?(type)
|
212
221
|
self.real_type.unqualify == type.real_type.unqualify
|
213
222
|
end
|
@@ -667,11 +676,15 @@ module C #:nodoc:
|
|
667
676
|
true
|
668
677
|
end
|
669
678
|
|
670
|
-
def compatible?(
|
679
|
+
def compatible?(to_type)
|
671
680
|
false
|
672
681
|
end
|
673
682
|
|
674
|
-
def coercible?(
|
683
|
+
def coercible?(to_type)
|
684
|
+
false
|
685
|
+
end
|
686
|
+
|
687
|
+
def convertible?(to_type)
|
675
688
|
false
|
676
689
|
end
|
677
690
|
|
@@ -1187,11 +1200,15 @@ module C #:nodoc:
|
|
1187
1200
|
true
|
1188
1201
|
end
|
1189
1202
|
|
1190
|
-
def compatible?(
|
1203
|
+
def compatible?(to_type)
|
1191
1204
|
false
|
1192
1205
|
end
|
1193
1206
|
|
1194
|
-
def coercible?(
|
1207
|
+
def coercible?(to_type)
|
1208
|
+
false
|
1209
|
+
end
|
1210
|
+
|
1211
|
+
def convertible?(to_type)
|
1195
1212
|
false
|
1196
1213
|
end
|
1197
1214
|
|
@@ -1709,12 +1726,34 @@ module C #:nodoc:
|
|
1709
1726
|
@base_type.incomplete?
|
1710
1727
|
end
|
1711
1728
|
|
1712
|
-
def compatible?(
|
1713
|
-
@base_type.compatible?(
|
1729
|
+
def compatible?(to_type)
|
1730
|
+
@base_type.compatible?(to_type)
|
1714
1731
|
end
|
1715
1732
|
|
1716
|
-
def coercible?(
|
1717
|
-
@base_type.coercible?(
|
1733
|
+
def coercible?(to_type)
|
1734
|
+
@base_type.coercible?(to_type)
|
1735
|
+
end
|
1736
|
+
|
1737
|
+
def more_cv_qualified?(than_type)
|
1738
|
+
# NOTE: The term `more cv-qualified' means:
|
1739
|
+
# const > none
|
1740
|
+
# volatile > none
|
1741
|
+
# const volatile > none
|
1742
|
+
# const volatile > const
|
1743
|
+
# const volatile > volatile
|
1744
|
+
if than_type.qualified?
|
1745
|
+
if than_type.const? && than_type.volatile?
|
1746
|
+
false
|
1747
|
+
else
|
1748
|
+
if self.const? && self.volatile?
|
1749
|
+
true
|
1750
|
+
else
|
1751
|
+
false
|
1752
|
+
end
|
1753
|
+
end
|
1754
|
+
else
|
1755
|
+
true
|
1756
|
+
end
|
1718
1757
|
end
|
1719
1758
|
|
1720
1759
|
def scalar?
|
@@ -2014,16 +2053,20 @@ module C #:nodoc:
|
|
2014
2053
|
true
|
2015
2054
|
end
|
2016
2055
|
|
2017
|
-
def compatible?(
|
2056
|
+
def compatible?(to_type)
|
2018
2057
|
false
|
2019
2058
|
end
|
2020
2059
|
|
2021
|
-
def coercible?(
|
2060
|
+
def coercible?(to_type)
|
2022
2061
|
false
|
2023
2062
|
end
|
2024
2063
|
|
2064
|
+
def convertible?(to_type)
|
2065
|
+
to_type.void?
|
2066
|
+
end
|
2067
|
+
|
2025
2068
|
def same_as?(type)
|
2026
|
-
|
2069
|
+
false
|
2027
2070
|
end
|
2028
2071
|
|
2029
2072
|
def scalar?
|
@@ -2538,19 +2581,19 @@ module C #:nodoc:
|
|
2538
2581
|
@parameter_types.any? { |type| type.incomplete? }
|
2539
2582
|
end
|
2540
2583
|
|
2541
|
-
def compatible?(
|
2542
|
-
return false unless
|
2584
|
+
def compatible?(to_type)
|
2585
|
+
return false unless to_type.function?
|
2543
2586
|
|
2544
2587
|
lhs_params = @parameter_types
|
2545
|
-
rhs_params =
|
2588
|
+
rhs_params = to_type.parameter_types
|
2546
2589
|
|
2547
|
-
@return_type.compatible?(
|
2590
|
+
@return_type.compatible?(to_type.return_type) &&
|
2548
2591
|
lhs_params.size == rhs_params.size &&
|
2549
2592
|
lhs_params.zip(rhs_params).all? { |lhs, rhs| lhs.compatible?(rhs) } &&
|
2550
|
-
@have_va_list ==
|
2593
|
+
@have_va_list == to_type.have_va_list?
|
2551
2594
|
end
|
2552
2595
|
|
2553
|
-
def coercible?(
|
2596
|
+
def coercible?(to_type)
|
2554
2597
|
false
|
2555
2598
|
end
|
2556
2599
|
|
@@ -3087,12 +3130,12 @@ module C #:nodoc:
|
|
3087
3130
|
self
|
3088
3131
|
end
|
3089
3132
|
|
3090
|
-
def compatible?(
|
3133
|
+
def compatible?(to_type)
|
3091
3134
|
subclass_responsibility
|
3092
3135
|
end
|
3093
3136
|
|
3094
|
-
def coercible?(
|
3095
|
-
|
3137
|
+
def coercible?(to_type)
|
3138
|
+
to_type.scalar?
|
3096
3139
|
end
|
3097
3140
|
|
3098
3141
|
def scalar?
|
@@ -3483,9 +3526,10 @@ module C #:nodoc:
|
|
3483
3526
|
nil
|
3484
3527
|
end
|
3485
3528
|
|
3486
|
-
def compatible?(
|
3487
|
-
|
3488
|
-
|
3529
|
+
def compatible?(to_type)
|
3530
|
+
to_type.integer? &&
|
3531
|
+
to_type.min_value <= self.min_value &&
|
3532
|
+
self.max_value <= to_type.max_value
|
3489
3533
|
end
|
3490
3534
|
|
3491
3535
|
def integer?
|
@@ -4877,9 +4921,10 @@ module C #:nodoc:
|
|
4877
4921
|
false
|
4878
4922
|
end
|
4879
4923
|
|
4880
|
-
def compatible?(
|
4924
|
+
def compatible?(to_type)
|
4881
4925
|
type.floating? &&
|
4882
|
-
|
4926
|
+
to_type.min_value <= self.min_value &&
|
4927
|
+
self.max_value <= to_type.max_value
|
4883
4928
|
end
|
4884
4929
|
|
4885
4930
|
def integer?
|
@@ -5338,15 +5383,18 @@ module C #:nodoc:
|
|
5338
5383
|
false
|
5339
5384
|
end
|
5340
5385
|
|
5341
|
-
def
|
5386
|
+
def convertible?(to_type)
|
5342
5387
|
lhs_unqualified = self.real_type.unqualify
|
5343
|
-
rhs_unqualified =
|
5388
|
+
rhs_unqualified = to_type.real_type.unqualify
|
5389
|
+
|
5390
|
+
if rhs_unqualified.pointer? || rhs_unqualified.array?
|
5391
|
+
lhs_base = lhs_unqualified.base_type
|
5392
|
+
rhs_base = rhs_unqualified.base_type
|
5344
5393
|
|
5345
|
-
|
5346
|
-
|
5347
|
-
true
|
5394
|
+
unless lhs_base.more_cv_qualified?(rhs_base)
|
5395
|
+
lhs_base.void? || lhs_base.convertible?(rhs_base)
|
5348
5396
|
else
|
5349
|
-
|
5397
|
+
false
|
5350
5398
|
end
|
5351
5399
|
else
|
5352
5400
|
false
|
@@ -5536,13 +5584,31 @@ module C #:nodoc:
|
|
5536
5584
|
@base_type.incomplete? || @length.nil?
|
5537
5585
|
end
|
5538
5586
|
|
5539
|
-
def compatible?(
|
5540
|
-
|
5541
|
-
@length ==
|
5587
|
+
def compatible?(to_type)
|
5588
|
+
to_type.array? &&
|
5589
|
+
@length == to_type.length && @base_type.compatible?(to_type.base_type)
|
5590
|
+
end
|
5591
|
+
|
5592
|
+
def coercible?(to_type)
|
5593
|
+
to_type.array? && @base_type.coercible?(to_type.base_type)
|
5542
5594
|
end
|
5543
5595
|
|
5544
|
-
def
|
5545
|
-
|
5596
|
+
def convertible?(to_type)
|
5597
|
+
lhs_unqualified = self.real_type.unqualify
|
5598
|
+
rhs_unqualified = to_type.real_type.unqualify
|
5599
|
+
|
5600
|
+
if rhs_unqualified.pointer? || rhs_unqualified.array?
|
5601
|
+
lhs_base = lhs_unqualified.base_type
|
5602
|
+
rhs_base = rhs_unqualified.base_type
|
5603
|
+
|
5604
|
+
unless lhs_base.more_cv_qualified?(rhs_base)
|
5605
|
+
lhs_base.convertible?(rhs_base)
|
5606
|
+
else
|
5607
|
+
false
|
5608
|
+
end
|
5609
|
+
else
|
5610
|
+
false
|
5611
|
+
end
|
5546
5612
|
end
|
5547
5613
|
|
5548
5614
|
def same_as?(type)
|
@@ -6118,15 +6184,15 @@ module C #:nodoc:
|
|
6118
6184
|
declarations.all? { |decl| decl.struct_declarations.nil? }
|
6119
6185
|
end
|
6120
6186
|
|
6121
|
-
def compatible?(
|
6122
|
-
|
6123
|
-
@members.size ==
|
6124
|
-
@members.zip(
|
6187
|
+
def compatible?(to_type)
|
6188
|
+
to_type.composite? &&
|
6189
|
+
@members.size == to_type.members.size &&
|
6190
|
+
@members.zip(to_type.members).all? { |lhs, rhs| lhs.compatible?(rhs) }
|
6125
6191
|
end
|
6126
6192
|
|
6127
|
-
def coercible?(
|
6128
|
-
|
6129
|
-
@members.zip(
|
6193
|
+
def coercible?(to_type)
|
6194
|
+
to_type.composite? &&
|
6195
|
+
@members.zip(to_type.members).all? { |lhs_member, rhs_member|
|
6130
6196
|
rhs_member && lhs_member.type.coercible?(rhs_member.type)
|
6131
6197
|
}
|
6132
6198
|
end
|
@@ -7228,7 +7294,7 @@ module C #:nodoc:
|
|
7228
7294
|
else
|
7229
7295
|
if interpreter
|
7230
7296
|
object = interpreter.execute(first_type_specifier.expression,
|
7231
|
-
|
7297
|
+
InterpreterOptions::QUIET)
|
7232
7298
|
return object.type
|
7233
7299
|
else
|
7234
7300
|
return nil
|
data/lib/adlint/c.rb
CHANGED
data/lib/adlint/version.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
<html lang="ja">
|
2
2
|
<head>
|
3
|
-
<title>AdLint 1.
|
3
|
+
<title>AdLint 1.10.0 開発者ガイド</title>
|
4
4
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
5
|
-
<meta name="description" content="AdLint 1.
|
5
|
+
<meta name="description" content="AdLint 1.10.0 開発者ガイド">
|
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 1.
|
47
|
+
<h1 class="settitle">AdLint 1.10.0 開発者ガイド</h1>
|
48
48
|
<div class="contents">
|
49
49
|
<h2>Table of Contents</h2>
|
50
50
|
<ul>
|