adlint 3.0.8 → 3.0.10
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 +295 -0
- data/MANIFEST +9 -0
- data/NEWS +25 -4
- data/etc/mesg.d/c_builtin/en_US/messages.yml +1 -1
- data/etc/mesg.d/c_builtin/ja_JP/messages.yml +1 -1
- data/etc/mesg.d/core/en_US/messages.yml +1 -1
- data/etc/mesg.d/core/ja_JP/messages.yml +1 -1
- data/features/code_check/E0008.feature +20 -0
- data/features/code_check/W0093.feature +1 -1
- data/features/code_check/W0097.feature +30 -0
- data/features/code_check/W0100.feature +66 -0
- data/features/code_check/W0422.feature +157 -0
- data/features/code_check/W0459.feature +118 -0
- data/features/code_check/W0461.feature +115 -0
- data/features/code_check/W0610.feature +59 -0
- data/features/code_check/W0612.feature +29 -0
- data/features/code_check/W0613.feature +33 -0
- data/features/code_check/W0704.feature +25 -0
- data/features/code_check/W0705.feature +33 -0
- data/features/code_check/W1050.feature +43 -0
- data/features/code_check/W1071.feature +30 -0
- data/features/code_check/W9001.feature +24 -0
- data/lib/adlint/cc1/branch.rb +32 -9
- data/lib/adlint/cc1/builtin.rb +2 -2
- data/lib/adlint/cc1/conv.rb +33 -33
- data/lib/adlint/cc1/ctrlexpr.rb +30 -30
- data/lib/adlint/cc1/domain.rb +12 -4
- data/lib/adlint/cc1/environ.rb +2 -1
- data/lib/adlint/cc1/expr.rb +135 -125
- data/lib/adlint/cc1/format.rb +3 -3
- data/lib/adlint/cc1/interp.rb +123 -109
- data/lib/adlint/cc1/lexer.rb +44 -40
- data/lib/adlint/cc1/mediator.rb +2 -2
- data/lib/adlint/cc1/object.rb +121 -36
- data/lib/adlint/cc1/option.rb +1 -0
- data/lib/adlint/cc1/parser.rb +874 -845
- data/lib/adlint/cc1/parser.y +22 -2
- data/lib/adlint/cc1/syntax.rb +37 -18
- data/lib/adlint/cc1/type.rb +3 -3
- data/lib/adlint/cc1/value.rb +58 -50
- data/lib/adlint/cpp/lexer.rb +5 -1
- data/lib/adlint/cpp/macro.rb +30 -30
- data/lib/adlint/cpp/subst.rb +4 -4
- data/lib/adlint/exam/c_builtin/cc1_check.rb +172 -172
- data/lib/adlint/exam/c_builtin/cc1_check_shima.rb +11 -11
- data/lib/adlint/exam/c_builtin/cpp_check.rb +2 -2
- data/lib/adlint/memo.rb +13 -13
- data/lib/adlint/prelude.rb +2 -2
- data/lib/adlint/version.rb +2 -2
- data/share/doc/developers_guide_ja.html +7 -5
- data/share/doc/developers_guide_ja.texi +5 -3
- data/share/doc/users_guide_en.html +3 -3
- data/share/doc/users_guide_en.texi +1 -1
- data/share/doc/users_guide_ja.html +3 -3
- data/share/doc/users_guide_ja.texi +1 -1
- metadata +11 -2
    
        data/lib/adlint/cpp/lexer.rb
    CHANGED
    
    | @@ -297,7 +297,11 @@ module Cpp #:nodoc: | |
| 297 297 | 
             
                def next_token
         | 
| 298 298 | 
             
                  # NOTE: An escaped newline may appear at the line above a preprocessing
         | 
| 299 299 | 
             
                  #       directive line.
         | 
| 300 | 
            -
                   | 
| 300 | 
            +
                  loop do
         | 
| 301 | 
            +
                    unless discard_heading_comments || scan_escaped_newline(@lexer.content)
         | 
| 302 | 
            +
                      break
         | 
| 303 | 
            +
                    end
         | 
| 304 | 
            +
                  end
         | 
| 301 305 |  | 
| 302 306 | 
             
                  case
         | 
| 303 307 | 
             
                  when @lexer.content.check(/[ \t]*#/)
         | 
    
        data/lib/adlint/cpp/macro.rb
    CHANGED
    
    | @@ -82,15 +82,15 @@ module Cpp #:nodoc: | |
| 82 82 |  | 
| 83 83 | 
             
                  if repl_list = self.replacement_list
         | 
| 84 84 | 
             
                    loc = toks.first.location
         | 
| 85 | 
            -
                     | 
| 85 | 
            +
                    rslt_toks = repl_list.tokens.map { |tok|
         | 
| 86 86 | 
             
                      ReplacedToken.new(tok.type, tok.value, loc, tok.type_hint, false)
         | 
| 87 87 | 
             
                    }
         | 
| 88 88 | 
             
                  else
         | 
| 89 | 
            -
                     | 
| 89 | 
            +
                    rslt_toks = []
         | 
| 90 90 | 
             
                  end
         | 
| 91 91 |  | 
| 92 | 
            -
                  macro_tbl.notify_object_like_macro_replacement(self, toks,  | 
| 93 | 
            -
                   | 
| 92 | 
            +
                  macro_tbl.notify_object_like_macro_replacement(self, toks, rslt_toks)
         | 
| 93 | 
            +
                  rslt_toks
         | 
| 94 94 | 
             
                end
         | 
| 95 95 |  | 
| 96 96 | 
             
                def function_like?; false end
         | 
| @@ -131,11 +131,11 @@ module Cpp #:nodoc: | |
| 131 131 | 
             
                      hash[param] = arg
         | 
| 132 132 | 
             
                    }
         | 
| 133 133 |  | 
| 134 | 
            -
                   | 
| 135 | 
            -
             | 
| 134 | 
            +
                  rslt_toks = expand_replacement_list(args_hash, toks.first.location,
         | 
| 135 | 
            +
                                                      macro_tbl, repl_ctxt)
         | 
| 136 136 | 
             
                  macro_tbl.notify_function_like_macro_replacement(self, toks, args,
         | 
| 137 | 
            -
                                                                    | 
| 138 | 
            -
                   | 
| 137 | 
            +
                                                                   rslt_toks)
         | 
| 138 | 
            +
                  rslt_toks
         | 
| 139 139 | 
             
                end
         | 
| 140 140 |  | 
| 141 141 | 
             
                def function_like?; true end
         | 
| @@ -200,44 +200,44 @@ module Cpp #:nodoc: | |
| 200 200 | 
             
                    return []
         | 
| 201 201 | 
             
                  end
         | 
| 202 202 |  | 
| 203 | 
            -
                   | 
| 203 | 
            +
                  rslt_toks = []
         | 
| 204 204 | 
             
                  idx = 0
         | 
| 205 205 | 
             
                  while cur_tok = repl_list.tokens[idx]
         | 
| 206 206 | 
             
                    nxt_tok = repl_list.tokens[idx + 1]
         | 
| 207 207 |  | 
| 208 208 | 
             
                    case
         | 
| 209 209 | 
             
                    when arg = args[cur_tok.value]
         | 
| 210 | 
            -
                      substitute_argument(cur_tok, nxt_tok, arg, loc,  | 
| 210 | 
            +
                      substitute_argument(cur_tok, nxt_tok, arg, loc, rslt_toks, macro_tbl,
         | 
| 211 211 | 
             
                                          repl_ctxt)
         | 
| 212 212 | 
             
                    when cur_tok.value == "#"
         | 
| 213 213 | 
             
                      if nxt_tok
         | 
| 214 214 | 
             
                        tok = stringize_argument(args[nxt_tok.value], loc, macro_tbl)
         | 
| 215 | 
            -
                         | 
| 215 | 
            +
                        rslt_toks.push(tok)
         | 
| 216 216 | 
             
                        idx += 1
         | 
| 217 217 | 
             
                      end
         | 
| 218 218 | 
             
                    when cur_tok.value == "##" && nxt_tok.value == "#"
         | 
| 219 219 | 
             
                      if nxt_nxt_tok = repl_list.tokens[idx + 2]
         | 
| 220 220 | 
             
                        tok = stringize_argument(args[nxt_nxt_tok.value], loc, macro_tbl)
         | 
| 221 | 
            -
                        concat_with_last_token([tok], loc,  | 
| 221 | 
            +
                        concat_with_last_token([tok], loc, rslt_toks, macro_tbl)
         | 
| 222 222 | 
             
                        idx += 2
         | 
| 223 223 | 
             
                      end
         | 
| 224 224 | 
             
                    when cur_tok.value == "##"
         | 
| 225 225 | 
             
                      if nxt_tok and arg = args[nxt_tok.value]
         | 
| 226 | 
            -
                        concat_with_last_token(arg, loc,  | 
| 226 | 
            +
                        concat_with_last_token(arg, loc, rslt_toks, macro_tbl)
         | 
| 227 227 | 
             
                      else
         | 
| 228 | 
            -
                        concat_with_last_token([nxt_tok], loc,  | 
| 228 | 
            +
                        concat_with_last_token([nxt_tok], loc, rslt_toks, macro_tbl)
         | 
| 229 229 | 
             
                      end
         | 
| 230 230 | 
             
                      idx += 1
         | 
| 231 231 | 
             
                    else
         | 
| 232 | 
            -
                       | 
| 233 | 
            -
             | 
| 232 | 
            +
                      rslt_toks.push(ReplacedToken.new(cur_tok.type, cur_tok.value, loc,
         | 
| 233 | 
            +
                                                       cur_tok.type_hint, false))
         | 
| 234 234 | 
             
                    end
         | 
| 235 235 | 
             
                    idx += 1
         | 
| 236 236 | 
             
                  end
         | 
| 237 | 
            -
                   | 
| 237 | 
            +
                  rslt_toks
         | 
| 238 238 | 
             
                end
         | 
| 239 239 |  | 
| 240 | 
            -
                def substitute_argument(param_tok, nxt_tok, arg, loc,  | 
| 240 | 
            +
                def substitute_argument(param_tok, nxt_tok, arg, loc, rslt_toks, macro_tbl,
         | 
| 241 241 | 
             
                                        repl_ctxt)
         | 
| 242 242 | 
             
                  # NOTE: The ISO C99 standard says;
         | 
| 243 243 | 
             
                  #
         | 
| @@ -253,12 +253,12 @@ module Cpp #:nodoc: | |
| 253 253 | 
             
                  #   the preprocessing file; no other preprocessing tokens are available.
         | 
| 254 254 |  | 
| 255 255 | 
             
                  if nxt_tok && nxt_tok.value == "##"
         | 
| 256 | 
            -
                     | 
| 256 | 
            +
                    rslt_toks.concat(arg.map { |tok|
         | 
| 257 257 | 
             
                      ReplacedToken.new(tok.type, tok.value, loc, tok.type_hint, false)
         | 
| 258 258 | 
             
                    })
         | 
| 259 259 | 
             
                  else
         | 
| 260 260 | 
             
                    macro_tbl.replace(arg, repl_ctxt)
         | 
| 261 | 
            -
                     | 
| 261 | 
            +
                    rslt_toks.concat(arg.map { |tok|
         | 
| 262 262 | 
             
                      ReplacedToken.new(tok.type, tok.value, loc, tok.type_hint, true)
         | 
| 263 263 | 
             
                    })
         | 
| 264 264 | 
             
                  end
         | 
| @@ -310,7 +310,7 @@ module Cpp #:nodoc: | |
| 310 310 | 
             
                                    expansion_loc, :STRING_LITERAL, false)
         | 
| 311 311 | 
             
                end
         | 
| 312 312 |  | 
| 313 | 
            -
                def concat_with_last_token(arg_toks, expansion_loc,  | 
| 313 | 
            +
                def concat_with_last_token(arg_toks, expansion_loc, rslt_toks, macro_tbl)
         | 
| 314 314 | 
             
                  # NOTE: The ISO C99 standard says;
         | 
| 315 315 | 
             
                  #
         | 
| 316 316 | 
             
                  # 6.10.3.3 The ## operator
         | 
| @@ -342,7 +342,7 @@ module Cpp #:nodoc: | |
| 342 342 | 
             
                  #   The resulting token is available for further macro replacement.  The
         | 
| 343 343 | 
             
                  #   order of evaluation of ## operators is unspecified.
         | 
| 344 344 |  | 
| 345 | 
            -
                  if lhs =  | 
| 345 | 
            +
                  if lhs = rslt_toks.pop
         | 
| 346 346 | 
             
                    unless arg_toks.empty?
         | 
| 347 347 | 
             
                      # NOTE: To avoid syntax error when the concatenated token can be
         | 
| 348 348 | 
             
                      #       retokenize to two or more tokens.
         | 
| @@ -352,7 +352,7 @@ module Cpp #:nodoc: | |
| 352 352 | 
             
                        ReplacedToken.new(tok.type, tok.value, expansion_loc,
         | 
| 353 353 | 
             
                                          tok.type_hint, false)
         | 
| 354 354 | 
             
                      end
         | 
| 355 | 
            -
                       | 
| 355 | 
            +
                      rslt_toks.concat(new_toks)
         | 
| 356 356 |  | 
| 357 357 | 
             
                      macro_tbl.notify_sharpsharp_operator_evaled(
         | 
| 358 358 | 
             
                        lhs, Token.new(:MACRO_ARG, unlexed_arg, arg_toks.first.location),
         | 
| @@ -360,7 +360,7 @@ module Cpp #:nodoc: | |
| 360 360 | 
             
                    else
         | 
| 361 361 | 
             
                      new_toks = [ReplacedToken.new(lhs.type, lhs.value, expansion_loc,
         | 
| 362 362 | 
             
                                                    lhs.type_hint, false)]
         | 
| 363 | 
            -
                       | 
| 363 | 
            +
                      rslt_toks.concat(new_toks)
         | 
| 364 364 | 
             
                    end
         | 
| 365 365 | 
             
                  end
         | 
| 366 366 | 
             
                end
         | 
| @@ -648,9 +648,9 @@ module Cpp #:nodoc: | |
| 648 648 | 
             
                  @hide_sets = Hash.new { |hash, key| hash[key] = Set.new }
         | 
| 649 649 | 
             
                end
         | 
| 650 650 |  | 
| 651 | 
            -
                def add_to_hide_set( | 
| 651 | 
            +
                def add_to_hide_set(orig_tok, new_toks, macro_name)
         | 
| 652 652 | 
             
                  new_toks.each do |new_tok|
         | 
| 653 | 
            -
                    @hide_sets[new_tok].merge(@hide_sets[ | 
| 653 | 
            +
                    @hide_sets[new_tok].merge(@hide_sets[orig_tok])
         | 
| 654 654 | 
             
                    @hide_sets[new_tok].add(macro_name)
         | 
| 655 655 | 
             
                  end
         | 
| 656 656 | 
             
                end
         | 
| @@ -713,14 +713,14 @@ module Cpp #:nodoc: | |
| 713 713 | 
             
                  replaced
         | 
| 714 714 | 
             
                end
         | 
| 715 715 |  | 
| 716 | 
            -
                def notify_object_like_macro_replacement(macro, replacing_toks,  | 
| 717 | 
            -
                  on_object_like_macro_replacement.invoke(macro, replacing_toks,  | 
| 716 | 
            +
                def notify_object_like_macro_replacement(macro, replacing_toks, rslt_toks)
         | 
| 717 | 
            +
                  on_object_like_macro_replacement.invoke(macro, replacing_toks, rslt_toks)
         | 
| 718 718 | 
             
                end
         | 
| 719 719 |  | 
| 720 720 | 
             
                def notify_function_like_macro_replacement(macro, replacing_toks, args,
         | 
| 721 | 
            -
                                                            | 
| 721 | 
            +
                                                           rslt_toks)
         | 
| 722 722 | 
             
                  on_function_like_macro_replacement.invoke(macro, replacing_toks, args,
         | 
| 723 | 
            -
                                                             | 
| 723 | 
            +
                                                            rslt_toks)
         | 
| 724 724 | 
             
                end
         | 
| 725 725 |  | 
| 726 726 | 
             
                def notify_sharpsharp_operator_evaled(lhs_tok, rhs_tok, new_toks)
         | 
    
        data/lib/adlint/cpp/subst.rb
    CHANGED
    
    | @@ -47,23 +47,23 @@ module Cpp #:nodoc: | |
| 47 47 | 
             
                def_plugin :on_substitution
         | 
| 48 48 |  | 
| 49 49 | 
             
                def execute(toks)
         | 
| 50 | 
            -
                   | 
| 50 | 
            +
                  rslt_toks = []
         | 
| 51 51 | 
             
                  idx = 0
         | 
| 52 52 | 
             
                  while first_tok = toks[idx]
         | 
| 53 53 | 
             
                    matcher = Matcher.new(@pattern)
         | 
| 54 54 | 
             
                    matched_len = matcher.match(toks, idx)
         | 
| 55 55 | 
             
                    if matcher.accepted? || idx + matched_len == toks.size
         | 
| 56 56 | 
             
                      notify_substitution(toks, idx, matched_len)
         | 
| 57 | 
            -
                       | 
| 57 | 
            +
                      rslt_toks.concat(@replacement.map { |tok|
         | 
| 58 58 | 
             
                        Token.new(tok.type, tok.value, first_tok.location, tok.type_hint)
         | 
| 59 59 | 
             
                      })
         | 
| 60 60 | 
             
                      idx += matched_len
         | 
| 61 61 | 
             
                    else
         | 
| 62 | 
            -
                       | 
| 62 | 
            +
                      rslt_toks.push(first_tok)
         | 
| 63 63 | 
             
                      idx += 1
         | 
| 64 64 | 
             
                    end
         | 
| 65 65 | 
             
                  end
         | 
| 66 | 
            -
                   | 
| 66 | 
            +
                  rslt_toks
         | 
| 67 67 | 
             
                end
         | 
| 68 68 |  | 
| 69 69 | 
             
                private
         | 
| @@ -383,12 +383,12 @@ module CBuiltin #:nodoc: | |
| 383 383 | 
             
                end
         | 
| 384 384 |  | 
| 385 385 | 
             
                private
         | 
| 386 | 
            -
                def check_explicit_conversion(expr,  | 
| 387 | 
            -
                   | 
| 388 | 
            -
                   | 
| 386 | 
            +
                def check_explicit_conversion(expr, orig_var, rslt_var)
         | 
| 387 | 
            +
                  orig_type = orig_var.type
         | 
| 388 | 
            +
                  rslt_type = rslt_var.type
         | 
| 389 389 |  | 
| 390 | 
            -
                  if  | 
| 391 | 
            -
                       | 
| 390 | 
            +
                  if orig_type.pointer? && orig_type.unqualify.base_type.const? &&
         | 
| 391 | 
            +
                      rslt_type.pointer? && !rslt_type.unqualify.base_type.const?
         | 
| 392 392 | 
             
                    W(expr.location)
         | 
| 393 393 | 
             
                  end
         | 
| 394 394 | 
             
                end
         | 
| @@ -408,12 +408,12 @@ module CBuiltin #:nodoc: | |
| 408 408 | 
             
                end
         | 
| 409 409 |  | 
| 410 410 | 
             
                private
         | 
| 411 | 
            -
                def check_explicit_conversion(expr,  | 
| 412 | 
            -
                   | 
| 413 | 
            -
                   | 
| 411 | 
            +
                def check_explicit_conversion(expr, orig_var, rslt_var)
         | 
| 412 | 
            +
                  orig_type = orig_var.type
         | 
| 413 | 
            +
                  rslt_type = rslt_var.type
         | 
| 414 414 |  | 
| 415 | 
            -
                  if  | 
| 416 | 
            -
                       | 
| 415 | 
            +
                  if orig_type.pointer? && orig_type.unqualify.base_type.volatile? &&
         | 
| 416 | 
            +
                      rslt_type.pointer? && !rslt_type.unqualify.base_type.volatile?
         | 
| 417 417 | 
             
                    W(expr.location)
         | 
| 418 418 | 
             
                  end
         | 
| 419 419 | 
             
                end
         | 
| @@ -605,8 +605,8 @@ module CBuiltin #:nodoc: | |
| 605 605 | 
             
                  end
         | 
| 606 606 | 
             
                end
         | 
| 607 607 |  | 
| 608 | 
            -
                def check_unary_prefix(expr, ope_var,  | 
| 609 | 
            -
                  type, val = ope_var.type,  | 
| 608 | 
            +
                def check_unary_prefix(expr, ope_var, orig_val)
         | 
| 609 | 
            +
                  type, val = ope_var.type, orig_val
         | 
| 610 610 |  | 
| 611 611 | 
             
                  if @interp.constant_expression?(expr.operand) && type.pointer? &&
         | 
| 612 612 | 
             
                      val.must_be_equal_to?(@interp.scalar_value_of(0))
         | 
| @@ -2442,9 +2442,9 @@ module CBuiltin #:nodoc: | |
| 2442 2442 | 
             
                  end
         | 
| 2443 2443 | 
             
                end
         | 
| 2444 2444 |  | 
| 2445 | 
            -
                def handle_array_subscript(expr, ary_or_ptr, *,  | 
| 2445 | 
            +
                def handle_array_subscript(expr, ary_or_ptr, *, rslt_var)
         | 
| 2446 2446 | 
             
                  if @var_relationship && ary_or_ptr.type.pointer?
         | 
| 2447 | 
            -
                    @var_relationship[ | 
| 2447 | 
            +
                    @var_relationship[rslt_var] = ary_or_ptr
         | 
| 2448 2448 | 
             
                  end
         | 
| 2449 2449 | 
             
                end
         | 
| 2450 2450 |  | 
| @@ -8383,8 +8383,8 @@ module CBuiltin #:nodoc: | |
| 8383 8383 | 
             
                  end
         | 
| 8384 8384 | 
             
                end
         | 
| 8385 8385 |  | 
| 8386 | 
            -
                def check_unary_prefix(expr, ope_var,  | 
| 8387 | 
            -
                  type, val = ope_var.type,  | 
| 8386 | 
            +
                def check_unary_prefix(expr, ope_var, orig_val)
         | 
| 8387 | 
            +
                  type, val = ope_var.type, orig_val
         | 
| 8388 8388 |  | 
| 8389 8389 | 
             
                  if type.pointer? && val.must_be_equal_to?(@interp.scalar_value_of(0))
         | 
| 8390 8390 | 
             
                    W(expr.operand.location)
         | 
| @@ -8440,8 +8440,8 @@ module CBuiltin #:nodoc: | |
| 8440 8440 | 
             
                  end
         | 
| 8441 8441 | 
             
                end
         | 
| 8442 8442 |  | 
| 8443 | 
            -
                def check_unary_prefix(expr, ope_var,  | 
| 8444 | 
            -
                  type, val = ope_var.type,  | 
| 8443 | 
            +
                def check_unary_prefix(expr, ope_var, orig_val)
         | 
| 8444 | 
            +
                  type, val = ope_var.type, orig_val
         | 
| 8445 8445 |  | 
| 8446 8446 | 
             
                  if type.pointer? &&
         | 
| 8447 8447 | 
             
                      !val.must_be_equal_to?(@interp.scalar_value_of(0)) &&
         | 
| @@ -8558,9 +8558,9 @@ module CBuiltin #:nodoc: | |
| 8558 8558 | 
             
                  def visit_if_else_statement(node)
         | 
| 8559 8559 | 
             
                    if node.analysis_target?(traits)
         | 
| 8560 8560 | 
             
                      check_dcl_or_stmt(node)
         | 
| 8561 | 
            -
                       | 
| 8561 | 
            +
                      orig_loc = @lst_dcl_or_stmt_loc
         | 
| 8562 8562 | 
             
                      node.then_statement.accept(self)
         | 
| 8563 | 
            -
                      @lst_dcl_or_stmt_loc =  | 
| 8563 | 
            +
                      @lst_dcl_or_stmt_loc = orig_loc
         | 
| 8564 8564 | 
             
                      node.else_statement.accept(self)
         | 
| 8565 8565 | 
             
                      @lst_dcl_or_stmt_loc = node.location
         | 
| 8566 8566 | 
             
                    end
         | 
| @@ -12510,9 +12510,9 @@ module CBuiltin #:nodoc: | |
| 12510 12510 | 
             
                end
         | 
| 12511 12511 |  | 
| 12512 12512 | 
             
                private
         | 
| 12513 | 
            -
                def check(expr,  | 
| 12514 | 
            -
                  lhs_type =  | 
| 12515 | 
            -
                  rhs_type =  | 
| 12513 | 
            +
                def check(expr, orig_var, rslt_var)
         | 
| 12514 | 
            +
                  lhs_type = orig_var.type.unqualify
         | 
| 12515 | 
            +
                  rhs_type = rslt_var.type.unqualify
         | 
| 12516 12516 |  | 
| 12517 12517 | 
             
                  return unless lhs_type.pointer? && lhs_type.base_type.function?
         | 
| 12518 12518 | 
             
                  return unless rhs_type.pointer? && rhs_type.base_type.function?
         | 
| @@ -12829,9 +12829,9 @@ module CBuiltin #:nodoc: | |
| 12829 12829 | 
             
                end
         | 
| 12830 12830 |  | 
| 12831 12831 | 
             
                private
         | 
| 12832 | 
            -
                def check(expr,  | 
| 12833 | 
            -
                  lhs_type =  | 
| 12834 | 
            -
                  rhs_type =  | 
| 12832 | 
            +
                def check(expr, orig_var, rslt_var)
         | 
| 12833 | 
            +
                  lhs_type = orig_var.type.unqualify
         | 
| 12834 | 
            +
                  rhs_type = rslt_var.type.unqualify
         | 
| 12835 12835 |  | 
| 12836 12836 | 
             
                  if lhs_type.integer? && !lhs_type.pointer? &&
         | 
| 12837 12837 | 
             
                      rhs_type.pointer? && rhs_type.base_type.volatile?
         | 
| @@ -12861,9 +12861,9 @@ module CBuiltin #:nodoc: | |
| 12861 12861 | 
             
                end
         | 
| 12862 12862 |  | 
| 12863 12863 | 
             
                private
         | 
| 12864 | 
            -
                def check(expr,  | 
| 12865 | 
            -
                  lhs_type =  | 
| 12866 | 
            -
                  rhs_type =  | 
| 12864 | 
            +
                def check(expr, orig_var, rslt_var)
         | 
| 12865 | 
            +
                  lhs_type = orig_var.type.unqualify
         | 
| 12866 | 
            +
                  rhs_type = rslt_var.type.unqualify
         | 
| 12867 12867 |  | 
| 12868 12868 | 
             
                  case
         | 
| 12869 12869 | 
             
                  when lhs_type.integer? && !lhs_type.pointer? &&
         | 
| @@ -12890,9 +12890,9 @@ module CBuiltin #:nodoc: | |
| 12890 12890 | 
             
                end
         | 
| 12891 12891 |  | 
| 12892 12892 | 
             
                private
         | 
| 12893 | 
            -
                def check(expr,  | 
| 12894 | 
            -
                  lhs_type =  | 
| 12895 | 
            -
                  rhs_type =  | 
| 12893 | 
            +
                def check(expr, orig_var, rslt_var)
         | 
| 12894 | 
            +
                  lhs_type = orig_var.type.unqualify
         | 
| 12895 | 
            +
                  rhs_type = rslt_var.type.unqualify
         | 
| 12896 12896 |  | 
| 12897 12897 | 
             
                  if lhs_type.integer? && !lhs_type.pointer? &&
         | 
| 12898 12898 | 
             
                      rhs_type.pointer? && !rhs_type.base_type.volatile?
         | 
| @@ -13125,25 +13125,25 @@ module CBuiltin #:nodoc: | |
| 13125 13125 | 
             
                  @rvalues = {}
         | 
| 13126 13126 | 
             
                end
         | 
| 13127 13127 |  | 
| 13128 | 
            -
                def handle_unary(expr, *,  | 
| 13128 | 
            +
                def handle_unary(expr, *, rslt_var)
         | 
| 13129 13129 | 
             
                  if expr.operator == "~"
         | 
| 13130 | 
            -
                    memorize_rvalue_derivation( | 
| 13130 | 
            +
                    memorize_rvalue_derivation(rslt_var, expr)
         | 
| 13131 13131 | 
             
                  end
         | 
| 13132 13132 | 
             
                end
         | 
| 13133 13133 |  | 
| 13134 | 
            -
                def handle_shift(expr, *,  | 
| 13134 | 
            +
                def handle_shift(expr, *, rslt_var)
         | 
| 13135 13135 | 
             
                  if expr.operator.type == "<<"
         | 
| 13136 | 
            -
                    memorize_rvalue_derivation( | 
| 13136 | 
            +
                    memorize_rvalue_derivation(rslt_var, expr)
         | 
| 13137 13137 | 
             
                  end
         | 
| 13138 13138 | 
             
                end
         | 
| 13139 13139 |  | 
| 13140 | 
            -
                def handle_additive(expr, *,  | 
| 13141 | 
            -
                  memorize_rvalue_derivation( | 
| 13140 | 
            +
                def handle_additive(expr, *, rslt_var)
         | 
| 13141 | 
            +
                  memorize_rvalue_derivation(rslt_var, expr)
         | 
| 13142 13142 | 
             
                end
         | 
| 13143 13143 |  | 
| 13144 | 
            -
                def handle_multiplicative(expr, *,  | 
| 13144 | 
            +
                def handle_multiplicative(expr, *, rslt_var)
         | 
| 13145 13145 | 
             
                  unless expr.operator.type == "%"
         | 
| 13146 | 
            -
                    memorize_rvalue_derivation( | 
| 13146 | 
            +
                    memorize_rvalue_derivation(rslt_var, expr)
         | 
| 13147 13147 | 
             
                  end
         | 
| 13148 13148 | 
             
                end
         | 
| 13149 13149 |  | 
| @@ -13192,25 +13192,25 @@ module CBuiltin #:nodoc: | |
| 13192 13192 | 
             
                  @rvalues = {}
         | 
| 13193 13193 | 
             
                end
         | 
| 13194 13194 |  | 
| 13195 | 
            -
                def handle_unary(expr, *,  | 
| 13195 | 
            +
                def handle_unary(expr, *, rslt_var)
         | 
| 13196 13196 | 
             
                  if expr.operator == "~"
         | 
| 13197 | 
            -
                    memorize_rvalue_derivation( | 
| 13197 | 
            +
                    memorize_rvalue_derivation(rslt_var, expr)
         | 
| 13198 13198 | 
             
                  end
         | 
| 13199 13199 | 
             
                end
         | 
| 13200 13200 |  | 
| 13201 | 
            -
                def handle_shift(expr, *,  | 
| 13201 | 
            +
                def handle_shift(expr, *, rslt_var)
         | 
| 13202 13202 | 
             
                  if expr.operator.type == "<<"
         | 
| 13203 | 
            -
                    memorize_rvalue_derivation( | 
| 13203 | 
            +
                    memorize_rvalue_derivation(rslt_var, expr)
         | 
| 13204 13204 | 
             
                  end
         | 
| 13205 13205 | 
             
                end
         | 
| 13206 13206 |  | 
| 13207 | 
            -
                def handle_additive(expr, *,  | 
| 13208 | 
            -
                  memorize_rvalue_derivation( | 
| 13207 | 
            +
                def handle_additive(expr, *, rslt_var)
         | 
| 13208 | 
            +
                  memorize_rvalue_derivation(rslt_var, expr)
         | 
| 13209 13209 | 
             
                end
         | 
| 13210 13210 |  | 
| 13211 | 
            -
                def handle_multiplicative(expr, *,  | 
| 13211 | 
            +
                def handle_multiplicative(expr, *, rslt_var)
         | 
| 13212 13212 | 
             
                  unless expr.operator.type == "%"
         | 
| 13213 | 
            -
                    memorize_rvalue_derivation( | 
| 13213 | 
            +
                    memorize_rvalue_derivation(rslt_var, expr)
         | 
| 13214 13214 | 
             
                  end
         | 
| 13215 13215 | 
             
                end
         | 
| 13216 13216 |  | 
| @@ -13819,19 +13819,19 @@ module CBuiltin #:nodoc: | |
| 13819 13819 | 
             
                end
         | 
| 13820 13820 |  | 
| 13821 13821 | 
             
                private
         | 
| 13822 | 
            -
                def check(expr,  | 
| 13823 | 
            -
                   | 
| 13824 | 
            -
                   | 
| 13822 | 
            +
                def check(expr, orig_var, rslt_var)
         | 
| 13823 | 
            +
                  orig_type = orig_var.type
         | 
| 13824 | 
            +
                  rslt_type = rslt_var.type
         | 
| 13825 13825 |  | 
| 13826 | 
            -
                  unless  | 
| 13827 | 
            -
                       | 
| 13826 | 
            +
                  unless orig_type.scalar? && orig_type.integer? &&
         | 
| 13827 | 
            +
                      rslt_type.scalar? && rslt_type.integer? && rslt_type.unsigned?
         | 
| 13828 13828 | 
             
                    return
         | 
| 13829 13829 | 
             
                  end
         | 
| 13830 13830 |  | 
| 13831 | 
            -
                   | 
| 13832 | 
            -
                  return unless  | 
| 13831 | 
            +
                  orig_val = orig_var.value
         | 
| 13832 | 
            +
                  return unless orig_val.scalar?
         | 
| 13833 13833 |  | 
| 13834 | 
            -
                  lower_test =  | 
| 13834 | 
            +
                  lower_test = orig_val < @interp.scalar_value_of(0)
         | 
| 13835 13835 |  | 
| 13836 13836 | 
             
                  if lower_test.must_be_true?
         | 
| 13837 13837 | 
             
                    W(expr.location)
         | 
| @@ -13853,19 +13853,19 @@ module CBuiltin #:nodoc: | |
| 13853 13853 | 
             
                end
         | 
| 13854 13854 |  | 
| 13855 13855 | 
             
                private
         | 
| 13856 | 
            -
                def check(expr,  | 
| 13857 | 
            -
                   | 
| 13858 | 
            -
                   | 
| 13856 | 
            +
                def check(expr, orig_var, rslt_var)
         | 
| 13857 | 
            +
                  orig_type = orig_var.type
         | 
| 13858 | 
            +
                  rslt_type = rslt_var.type
         | 
| 13859 13859 |  | 
| 13860 | 
            -
                  unless  | 
| 13861 | 
            -
                       | 
| 13860 | 
            +
                  unless orig_type.scalar? && orig_type.integer? &&
         | 
| 13861 | 
            +
                      rslt_type.scalar? && rslt_type.integer? && rslt_type.unsigned?
         | 
| 13862 13862 | 
             
                    return
         | 
| 13863 13863 | 
             
                  end
         | 
| 13864 13864 |  | 
| 13865 | 
            -
                   | 
| 13866 | 
            -
                  return unless  | 
| 13865 | 
            +
                  orig_val = orig_var.value
         | 
| 13866 | 
            +
                  return unless orig_val.scalar?
         | 
| 13867 13867 |  | 
| 13868 | 
            -
                  lower_test =  | 
| 13868 | 
            +
                  lower_test = orig_val < @interp.scalar_value_of(0)
         | 
| 13869 13869 |  | 
| 13870 13870 | 
             
                  if !lower_test.must_be_true? && lower_test.may_be_true?
         | 
| 13871 13871 | 
             
                    W(expr.location)
         | 
| @@ -13899,8 +13899,8 @@ module CBuiltin #:nodoc: | |
| 13899 13899 | 
             
                end
         | 
| 13900 13900 |  | 
| 13901 13901 | 
             
                private
         | 
| 13902 | 
            -
                def check(expr, *,  | 
| 13903 | 
            -
                  if  | 
| 13902 | 
            +
                def check(expr, *, rslt_var)
         | 
| 13903 | 
            +
                  if rslt_var.value.must_be_true? && !should_not_check?(expr)
         | 
| 13904 13904 | 
             
                    W(expr.location)
         | 
| 13905 13905 | 
             
                  end
         | 
| 13906 13906 | 
             
                end
         | 
| @@ -13957,8 +13957,8 @@ module CBuiltin #:nodoc: | |
| 13957 13957 | 
             
                end
         | 
| 13958 13958 |  | 
| 13959 13959 | 
             
                private
         | 
| 13960 | 
            -
                def check(expr, *,  | 
| 13961 | 
            -
                  if  | 
| 13960 | 
            +
                def check(expr, *, rslt_var)
         | 
| 13961 | 
            +
                  if rslt_var.value.must_be_false? && !should_not_check?(expr)
         | 
| 13962 13962 | 
             
                    W(expr.location)
         | 
| 13963 13963 | 
             
                  end
         | 
| 13964 13964 | 
             
                end
         | 
| @@ -14746,9 +14746,9 @@ module CBuiltin #:nodoc: | |
| 14746 14746 | 
             
                end
         | 
| 14747 14747 |  | 
| 14748 14748 | 
             
                private
         | 
| 14749 | 
            -
                def check(expr,  | 
| 14750 | 
            -
                  lhs_type =  | 
| 14751 | 
            -
                  rhs_type =  | 
| 14749 | 
            +
                def check(expr, orig_var, rslt_var)
         | 
| 14750 | 
            +
                  lhs_type = orig_var.type.unqualify
         | 
| 14751 | 
            +
                  rhs_type = rslt_var.type.unqualify
         | 
| 14752 14752 |  | 
| 14753 14753 | 
             
                  case
         | 
| 14754 14754 | 
             
                  when lhs_type.floating? &&
         | 
| @@ -16655,20 +16655,20 @@ module CBuiltin #:nodoc: | |
| 16655 16655 | 
             
                end
         | 
| 16656 16656 |  | 
| 16657 16657 | 
             
                private
         | 
| 16658 | 
            -
                def check(expr,  | 
| 16659 | 
            -
                   | 
| 16660 | 
            -
                   | 
| 16658 | 
            +
                def check(expr, orig_var, rslt_var)
         | 
| 16659 | 
            +
                  orig_type = orig_var.type
         | 
| 16660 | 
            +
                  rslt_type = rslt_var.type
         | 
| 16661 16661 |  | 
| 16662 | 
            -
                  unless  | 
| 16663 | 
            -
                       | 
| 16662 | 
            +
                  unless orig_type.scalar? && orig_type.floating? &&
         | 
| 16663 | 
            +
                      rslt_type.scalar? && rslt_type.integer?
         | 
| 16664 16664 | 
             
                    return
         | 
| 16665 16665 | 
             
                  end
         | 
| 16666 16666 |  | 
| 16667 | 
            -
                   | 
| 16668 | 
            -
                  return unless  | 
| 16667 | 
            +
                  orig_val = orig_var.value
         | 
| 16668 | 
            +
                  return unless orig_val.scalar?
         | 
| 16669 16669 |  | 
| 16670 | 
            -
                  lower_test =  | 
| 16671 | 
            -
                  upper_test =  | 
| 16670 | 
            +
                  lower_test = orig_val < @interp.scalar_value_of(rslt_type.min - 1)
         | 
| 16671 | 
            +
                  upper_test = orig_val > @interp.scalar_value_of(rslt_type.max + 1)
         | 
| 16672 16672 |  | 
| 16673 16673 | 
             
                  if lower_test.must_be_true? || upper_test.must_be_true?
         | 
| 16674 16674 | 
             
                    W(expr.location)
         | 
| @@ -16690,15 +16690,15 @@ module CBuiltin #:nodoc: | |
| 16690 16690 | 
             
                end
         | 
| 16691 16691 |  | 
| 16692 16692 | 
             
                private
         | 
| 16693 | 
            -
                def check(expr,  | 
| 16694 | 
            -
                   | 
| 16695 | 
            -
                   | 
| 16693 | 
            +
                def check(expr, orig_var, rslt_var)
         | 
| 16694 | 
            +
                  orig_type = orig_var.type
         | 
| 16695 | 
            +
                  rslt_type = rslt_var.type
         | 
| 16696 16696 |  | 
| 16697 | 
            -
                  unless  | 
| 16697 | 
            +
                  unless orig_type.pointer? && rslt_type.scalar? && rslt_type.integer?
         | 
| 16698 16698 | 
             
                    return
         | 
| 16699 16699 | 
             
                  end
         | 
| 16700 16700 |  | 
| 16701 | 
            -
                  if  | 
| 16701 | 
            +
                  if orig_type.min < rslt_type.min || orig_type.max > rslt_type.max
         | 
| 16702 16702 | 
             
                    W(expr.location)
         | 
| 16703 16703 | 
             
                  end
         | 
| 16704 16704 | 
             
                end
         | 
| @@ -16719,7 +16719,7 @@ module CBuiltin #:nodoc: | |
| 16719 16719 | 
             
                end
         | 
| 16720 16720 |  | 
| 16721 16721 | 
             
                private
         | 
| 16722 | 
            -
                def check(expr, lhs_var, rhs_var,  | 
| 16722 | 
            +
                def check(expr, lhs_var, rhs_var, rslt_var)
         | 
| 16723 16723 | 
             
                  return unless lhs_var.type.scalar? && lhs_var.type.signed?
         | 
| 16724 16724 | 
             
                  return unless rhs_var.type.scalar? && rhs_var.type.signed?
         | 
| 16725 16725 |  | 
| @@ -16736,8 +16736,8 @@ module CBuiltin #:nodoc: | |
| 16736 16736 | 
             
                    return
         | 
| 16737 16737 | 
             
                  end
         | 
| 16738 16738 |  | 
| 16739 | 
            -
                  lower_test = unbound_val < @interp.scalar_value_of( | 
| 16740 | 
            -
                  upper_test = unbound_val > @interp.scalar_value_of( | 
| 16739 | 
            +
                  lower_test = unbound_val < @interp.scalar_value_of(rslt_var.type.min)
         | 
| 16740 | 
            +
                  upper_test = unbound_val > @interp.scalar_value_of(rslt_var.type.max)
         | 
| 16741 16741 |  | 
| 16742 16742 | 
             
                  if lower_test.must_be_true? || upper_test.must_be_true?
         | 
| 16743 16743 | 
             
                    W(expr.location)
         | 
| @@ -16760,7 +16760,7 @@ module CBuiltin #:nodoc: | |
| 16760 16760 | 
             
                end
         | 
| 16761 16761 |  | 
| 16762 16762 | 
             
                private
         | 
| 16763 | 
            -
                def check(expr, lhs_var, rhs_var,  | 
| 16763 | 
            +
                def check(expr, lhs_var, rhs_var, rslt_var)
         | 
| 16764 16764 | 
             
                  return unless lhs_var.type.scalar? && lhs_var.type.signed?
         | 
| 16765 16765 | 
             
                  return unless rhs_var.type.scalar? && rhs_var.type.signed?
         | 
| 16766 16766 |  | 
| @@ -16777,8 +16777,8 @@ module CBuiltin #:nodoc: | |
| 16777 16777 | 
             
                    return
         | 
| 16778 16778 | 
             
                  end
         | 
| 16779 16779 |  | 
| 16780 | 
            -
                  lower_test = unbound_val < @interp.scalar_value_of( | 
| 16781 | 
            -
                  upper_test = unbound_val > @interp.scalar_value_of( | 
| 16780 | 
            +
                  lower_test = unbound_val < @interp.scalar_value_of(rslt_var.type.min)
         | 
| 16781 | 
            +
                  upper_test = unbound_val > @interp.scalar_value_of(rslt_var.type.max)
         | 
| 16782 16782 |  | 
| 16783 16783 | 
             
                  if !lower_test.must_be_true? && lower_test.may_be_true? or
         | 
| 16784 16784 | 
             
                      !upper_test.must_be_true? && upper_test.may_be_true?
         | 
| @@ -16802,11 +16802,11 @@ module CBuiltin #:nodoc: | |
| 16802 16802 | 
             
                end
         | 
| 16803 16803 |  | 
| 16804 16804 | 
             
                private
         | 
| 16805 | 
            -
                def check(init_or_expr,  | 
| 16806 | 
            -
                  return unless  | 
| 16805 | 
            +
                def check(init_or_expr, orig_var, rslt_var)
         | 
| 16806 | 
            +
                  return unless rslt_var.type.enum?
         | 
| 16807 16807 |  | 
| 16808 | 
            -
                  val =  | 
| 16809 | 
            -
                  unless  | 
| 16808 | 
            +
                  val = orig_var.value.unique_sample
         | 
| 16809 | 
            +
                  unless rslt_var.type.enumerators.any? { |enum| val == enum.value }
         | 
| 16810 16810 | 
             
                    W(init_or_expr.location)
         | 
| 16811 16811 | 
             
                  end
         | 
| 16812 16812 | 
             
                end
         | 
| @@ -17026,7 +17026,7 @@ module CBuiltin #:nodoc: | |
| 17026 17026 | 
             
                end
         | 
| 17027 17027 |  | 
| 17028 17028 | 
             
                private
         | 
| 17029 | 
            -
                def check(init_or_expr,  | 
| 17029 | 
            +
                def check(init_or_expr, orig_var, rslt_var)
         | 
| 17030 17030 | 
             
                  case init_or_expr
         | 
| 17031 17031 | 
             
                  when Cc1::Initializer
         | 
| 17032 17032 | 
             
                    unless expr = init_or_expr.expression
         | 
| @@ -17038,18 +17038,18 @@ module CBuiltin #:nodoc: | |
| 17038 17038 |  | 
| 17039 17039 | 
             
                  return unless @interp.constant_expression?(expr)
         | 
| 17040 17040 |  | 
| 17041 | 
            -
                   | 
| 17042 | 
            -
                   | 
| 17041 | 
            +
                  orig_type = orig_var.type
         | 
| 17042 | 
            +
                  rslt_type = rslt_var.type
         | 
| 17043 17043 |  | 
| 17044 | 
            -
                  unless  | 
| 17045 | 
            -
                       | 
| 17044 | 
            +
                  unless orig_type.scalar? && orig_type.integer? &&
         | 
| 17045 | 
            +
                      rslt_type.scalar? && rslt_type.integer? && rslt_type.unsigned?
         | 
| 17046 17046 | 
             
                    return
         | 
| 17047 17047 | 
             
                  end
         | 
| 17048 17048 |  | 
| 17049 | 
            -
                   | 
| 17050 | 
            -
                  return unless  | 
| 17049 | 
            +
                  orig_val = orig_var.value
         | 
| 17050 | 
            +
                  return unless orig_val.scalar?
         | 
| 17051 17051 |  | 
| 17052 | 
            -
                  upper_test =  | 
| 17052 | 
            +
                  upper_test = orig_val > @interp.scalar_value_of(rslt_type.max)
         | 
| 17053 17053 |  | 
| 17054 17054 | 
             
                  W(expr.location) if upper_test.must_be_true?
         | 
| 17055 17055 | 
             
                end
         | 
| @@ -17069,7 +17069,7 @@ module CBuiltin #:nodoc: | |
| 17069 17069 | 
             
                end
         | 
| 17070 17070 |  | 
| 17071 17071 | 
             
                private
         | 
| 17072 | 
            -
                def check(expr, lhs_var, rhs_var,  | 
| 17072 | 
            +
                def check(expr, lhs_var, rhs_var, rslt_var)
         | 
| 17073 17073 | 
             
                  return unless expr.operator.type == "-"
         | 
| 17074 17074 |  | 
| 17075 17075 | 
             
                  return unless @interp.constant_expression?(expr.lhs_operand)
         | 
| @@ -17081,7 +17081,7 @@ module CBuiltin #:nodoc: | |
| 17081 17081 | 
             
                  return unless lhs_var.value.scalar? && rhs_var.value.scalar?
         | 
| 17082 17082 |  | 
| 17083 17083 | 
             
                  unbound_val = lhs_var.value - rhs_var.value
         | 
| 17084 | 
            -
                  lower_test = unbound_val < @interp.scalar_value_of( | 
| 17084 | 
            +
                  lower_test = unbound_val < @interp.scalar_value_of(rslt_var.type.min)
         | 
| 17085 17085 |  | 
| 17086 17086 | 
             
                  W(expr.location) if lower_test.must_be_true?
         | 
| 17087 17087 | 
             
                end
         | 
| @@ -17101,7 +17101,7 @@ module CBuiltin #:nodoc: | |
| 17101 17101 | 
             
                end
         | 
| 17102 17102 |  | 
| 17103 17103 | 
             
                private
         | 
| 17104 | 
            -
                def check(expr, lhs_var, rhs_var,  | 
| 17104 | 
            +
                def check(expr, lhs_var, rhs_var, rslt_var)
         | 
| 17105 17105 | 
             
                  return unless expr.operator.type == "+"
         | 
| 17106 17106 |  | 
| 17107 17107 | 
             
                  return unless @interp.constant_expression?(expr.lhs_operand)
         | 
| @@ -17113,7 +17113,7 @@ module CBuiltin #:nodoc: | |
| 17113 17113 | 
             
                  return unless lhs_var.value.scalar? && rhs_var.value.scalar?
         | 
| 17114 17114 |  | 
| 17115 17115 | 
             
                  unbound_val = lhs_var.value + rhs_var.value
         | 
| 17116 | 
            -
                  upper_test = unbound_val > @interp.scalar_value_of( | 
| 17116 | 
            +
                  upper_test = unbound_val > @interp.scalar_value_of(rslt_var.type.max)
         | 
| 17117 17117 |  | 
| 17118 17118 | 
             
                  W(expr.location) if upper_test.must_be_true?
         | 
| 17119 17119 | 
             
                end
         | 
| @@ -17133,7 +17133,7 @@ module CBuiltin #:nodoc: | |
| 17133 17133 | 
             
                end
         | 
| 17134 17134 |  | 
| 17135 17135 | 
             
                private
         | 
| 17136 | 
            -
                def check(expr, lhs_var, rhs_var,  | 
| 17136 | 
            +
                def check(expr, lhs_var, rhs_var, rslt_var)
         | 
| 17137 17137 | 
             
                  return unless expr.operator.type == "*"
         | 
| 17138 17138 |  | 
| 17139 17139 | 
             
                  return unless @interp.constant_expression?(expr.lhs_operand)
         | 
| @@ -17145,7 +17145,7 @@ module CBuiltin #:nodoc: | |
| 17145 17145 | 
             
                  return unless lhs_var.value.scalar? && rhs_var.value.scalar?
         | 
| 17146 17146 |  | 
| 17147 17147 | 
             
                  unbound_val = lhs_var.value * rhs_var.value
         | 
| 17148 | 
            -
                  upper_test = unbound_val > @interp.scalar_value_of( | 
| 17148 | 
            +
                  upper_test = unbound_val > @interp.scalar_value_of(rslt_var.type.max)
         | 
| 17149 17149 |  | 
| 17150 17150 | 
             
                  W(expr.location) if upper_test.must_be_true?
         | 
| 17151 17151 | 
             
                end
         | 
| @@ -17165,9 +17165,9 @@ module CBuiltin #:nodoc: | |
| 17165 17165 | 
             
                end
         | 
| 17166 17166 |  | 
| 17167 17167 | 
             
                private
         | 
| 17168 | 
            -
                def check(init_or_expr,  | 
| 17169 | 
            -
                  unless  | 
| 17170 | 
            -
                       | 
| 17168 | 
            +
                def check(init_or_expr, orig_var, rslt_var)
         | 
| 17169 | 
            +
                  unless orig_var.type.scalar? && rslt_var.type.scalar? &&
         | 
| 17170 | 
            +
                      orig_var.type.signed? && rslt_var.type.unsigned?
         | 
| 17171 17171 | 
             
                    return
         | 
| 17172 17172 | 
             
                  end
         | 
| 17173 17173 |  | 
| @@ -17178,7 +17178,7 @@ module CBuiltin #:nodoc: | |
| 17178 17178 | 
             
                  end
         | 
| 17179 17179 |  | 
| 17180 17180 | 
             
                  if expr && @interp.constant_expression?(expr) &&
         | 
| 17181 | 
            -
                       | 
| 17181 | 
            +
                      orig_var.value.must_be_less_than?(@interp.scalar_value_of(0))
         | 
| 17182 17182 | 
             
                    W(expr.location)
         | 
| 17183 17183 | 
             
                  end
         | 
| 17184 17184 | 
             
                end
         | 
| @@ -17198,7 +17198,7 @@ module CBuiltin #:nodoc: | |
| 17198 17198 | 
             
                end
         | 
| 17199 17199 |  | 
| 17200 17200 | 
             
                private
         | 
| 17201 | 
            -
                def check(init_or_expr,  | 
| 17201 | 
            +
                def check(init_or_expr, orig_var, rslt_var)
         | 
| 17202 17202 | 
             
                  case init_or_expr
         | 
| 17203 17203 | 
             
                  when Cc1::Initializer
         | 
| 17204 17204 | 
             
                    unless expr = init_or_expr.expression
         | 
| @@ -17210,19 +17210,19 @@ module CBuiltin #:nodoc: | |
| 17210 17210 |  | 
| 17211 17211 | 
             
                  return unless @interp.constant_expression?(expr)
         | 
| 17212 17212 |  | 
| 17213 | 
            -
                   | 
| 17214 | 
            -
                   | 
| 17213 | 
            +
                  orig_type = orig_var.type
         | 
| 17214 | 
            +
                  rslt_type = rslt_var.type
         | 
| 17215 17215 |  | 
| 17216 | 
            -
                  unless  | 
| 17217 | 
            -
                       | 
| 17216 | 
            +
                  unless orig_type.scalar? && orig_type.integer? &&
         | 
| 17217 | 
            +
                      rslt_type.scalar? && rslt_type.integer? && rslt_type.signed?
         | 
| 17218 17218 | 
             
                    return
         | 
| 17219 17219 | 
             
                  end
         | 
| 17220 17220 |  | 
| 17221 | 
            -
                   | 
| 17222 | 
            -
                  return unless  | 
| 17221 | 
            +
                  orig_val = orig_var.value
         | 
| 17222 | 
            +
                  return unless orig_val.scalar?
         | 
| 17223 17223 |  | 
| 17224 | 
            -
                  lower_test =  | 
| 17225 | 
            -
                  upper_test =  | 
| 17224 | 
            +
                  lower_test = orig_val < @interp.scalar_value_of(rslt_type.min)
         | 
| 17225 | 
            +
                  upper_test = orig_val > @interp.scalar_value_of(rslt_type.max)
         | 
| 17226 17226 |  | 
| 17227 17227 | 
             
                  if lower_test.must_be_true? || upper_test.must_be_true?
         | 
| 17228 17228 | 
             
                    W(expr.location)
         | 
| @@ -18103,11 +18103,11 @@ module CBuiltin #:nodoc: | |
| 18103 18103 | 
             
                end
         | 
| 18104 18104 |  | 
| 18105 18105 | 
             
                private
         | 
| 18106 | 
            -
                def check(*,  | 
| 18107 | 
            -
                  return unless @rvalues &&  | 
| 18108 | 
            -
                  case expr = @rvalues[ | 
| 18106 | 
            +
                def check(*, orig_var, rslt_var)
         | 
| 18107 | 
            +
                  return unless @rvalues && orig_var.type.floating?
         | 
| 18108 | 
            +
                  case expr = @rvalues[orig_var]
         | 
| 18109 18109 | 
             
                  when Cc1::AdditiveExpression, Cc1::MultiplicativeExpression
         | 
| 18110 | 
            -
                    if  | 
| 18110 | 
            +
                    if orig_var.type.same_as?(from_type) && rslt_var.type.same_as?(to_type)
         | 
| 18111 18111 | 
             
                      W(expr.location)
         | 
| 18112 18112 | 
             
                    end
         | 
| 18113 18113 | 
             
                  end
         | 
| @@ -18117,13 +18117,13 @@ module CBuiltin #:nodoc: | |
| 18117 18117 | 
             
                  @rvalues = {}
         | 
| 18118 18118 | 
             
                end
         | 
| 18119 18119 |  | 
| 18120 | 
            -
                def handle_additive(expr, *,  | 
| 18121 | 
            -
                  memorize_rvalue_derivation( | 
| 18120 | 
            +
                def handle_additive(expr, *, rslt_var)
         | 
| 18121 | 
            +
                  memorize_rvalue_derivation(rslt_var, expr)
         | 
| 18122 18122 | 
             
                end
         | 
| 18123 18123 |  | 
| 18124 | 
            -
                def handle_multiplicative(expr, *,  | 
| 18124 | 
            +
                def handle_multiplicative(expr, *, rslt_var)
         | 
| 18125 18125 | 
             
                  unless expr.operator.type == "%"
         | 
| 18126 | 
            -
                    memorize_rvalue_derivation( | 
| 18126 | 
            +
                    memorize_rvalue_derivation(rslt_var, expr)
         | 
| 18127 18127 | 
             
                  end
         | 
| 18128 18128 | 
             
                end
         | 
| 18129 18129 |  | 
| @@ -18220,9 +18220,9 @@ module CBuiltin #:nodoc: | |
| 18220 18220 | 
             
                end
         | 
| 18221 18221 |  | 
| 18222 18222 | 
             
                private
         | 
| 18223 | 
            -
                def check(expr,  | 
| 18224 | 
            -
                  from_type =  | 
| 18225 | 
            -
                  to_type =  | 
| 18223 | 
            +
                def check(expr, orig_var, rslt_var)
         | 
| 18224 | 
            +
                  from_type = orig_var.type.unqualify
         | 
| 18225 | 
            +
                  to_type = rslt_var.type.unqualify
         | 
| 18226 18226 |  | 
| 18227 18227 | 
             
                  return unless from_type.pointer? && to_type.pointer?
         | 
| 18228 18228 |  | 
| @@ -18636,9 +18636,9 @@ module CBuiltin #:nodoc: | |
| 18636 18636 | 
             
                end
         | 
| 18637 18637 |  | 
| 18638 18638 | 
             
                private
         | 
| 18639 | 
            -
                def check(expr,  | 
| 18640 | 
            -
                  lhs_type =  | 
| 18641 | 
            -
                  rhs_type =  | 
| 18639 | 
            +
                def check(expr, orig_var, rslt_var)
         | 
| 18640 | 
            +
                  lhs_type = orig_var.type.unqualify
         | 
| 18641 | 
            +
                  rhs_type = rslt_var.type.unqualify
         | 
| 18642 18642 |  | 
| 18643 18643 | 
             
                  case
         | 
| 18644 18644 | 
             
                  when lhs_type.floating? &&
         | 
| @@ -18665,9 +18665,9 @@ module CBuiltin #:nodoc: | |
| 18665 18665 | 
             
                end
         | 
| 18666 18666 |  | 
| 18667 18667 | 
             
                private
         | 
| 18668 | 
            -
                def check(expr,  | 
| 18669 | 
            -
                  lhs_type =  | 
| 18670 | 
            -
                  rhs_type =  | 
| 18668 | 
            +
                def check(expr, orig_var, rslt_var)
         | 
| 18669 | 
            +
                  lhs_type = orig_var.type.unqualify
         | 
| 18670 | 
            +
                  rhs_type = rslt_var.type.unqualify
         | 
| 18671 18671 |  | 
| 18672 18672 | 
             
                  if lhs_type.pointer? && rhs_type.pointer?
         | 
| 18673 18673 | 
             
                    case
         | 
| @@ -19657,20 +19657,20 @@ module CBuiltin #:nodoc: | |
| 19657 19657 | 
             
                end
         | 
| 19658 19658 |  | 
| 19659 19659 | 
             
                private
         | 
| 19660 | 
            -
                def check(expr,  | 
| 19661 | 
            -
                   | 
| 19662 | 
            -
                   | 
| 19660 | 
            +
                def check(expr, orig_var, rslt_var)
         | 
| 19661 | 
            +
                  orig_type = orig_var.type
         | 
| 19662 | 
            +
                  rslt_type = rslt_var.type
         | 
| 19663 19663 |  | 
| 19664 | 
            -
                  unless  | 
| 19665 | 
            -
                       | 
| 19664 | 
            +
                  unless orig_type.scalar? && orig_type.integer? &&
         | 
| 19665 | 
            +
                      rslt_type.scalar? && rslt_type.integer? && rslt_type.signed?
         | 
| 19666 19666 | 
             
                    return
         | 
| 19667 19667 | 
             
                  end
         | 
| 19668 19668 |  | 
| 19669 | 
            -
                   | 
| 19670 | 
            -
                  return unless  | 
| 19669 | 
            +
                  orig_val = orig_var.value
         | 
| 19670 | 
            +
                  return unless orig_val.scalar?
         | 
| 19671 19671 |  | 
| 19672 | 
            -
                  lower_test =  | 
| 19673 | 
            -
                  upper_test =  | 
| 19672 | 
            +
                  lower_test = orig_val < @interp.scalar_value_of(rslt_type.min)
         | 
| 19673 | 
            +
                  upper_test = orig_val > @interp.scalar_value_of(rslt_type.max)
         | 
| 19674 19674 |  | 
| 19675 19675 | 
             
                  if !lower_test.must_be_true? && lower_test.may_be_true? or
         | 
| 19676 19676 | 
             
                      !upper_test.must_be_true? && upper_test.may_be_true?
         | 
| @@ -19693,20 +19693,20 @@ module CBuiltin #:nodoc: | |
| 19693 19693 | 
             
                end
         | 
| 19694 19694 |  | 
| 19695 19695 | 
             
                private
         | 
| 19696 | 
            -
                def check(expr,  | 
| 19697 | 
            -
                   | 
| 19698 | 
            -
                   | 
| 19696 | 
            +
                def check(expr, orig_var, rslt_var)
         | 
| 19697 | 
            +
                  orig_type = orig_var.type
         | 
| 19698 | 
            +
                  rslt_type = rslt_var.type
         | 
| 19699 19699 |  | 
| 19700 | 
            -
                  unless  | 
| 19701 | 
            -
                       | 
| 19700 | 
            +
                  unless orig_type.scalar? && orig_type.integer? &&
         | 
| 19701 | 
            +
                      rslt_type.scalar? && rslt_type.integer? && rslt_type.signed?
         | 
| 19702 19702 | 
             
                    return
         | 
| 19703 19703 | 
             
                  end
         | 
| 19704 19704 |  | 
| 19705 | 
            -
                   | 
| 19706 | 
            -
                  return unless  | 
| 19705 | 
            +
                  orig_val = orig_var.value
         | 
| 19706 | 
            +
                  return unless orig_val.scalar?
         | 
| 19707 19707 |  | 
| 19708 | 
            -
                  lower_test =  | 
| 19709 | 
            -
                  upper_test =  | 
| 19708 | 
            +
                  lower_test = orig_val < @interp.scalar_value_of(rslt_type.min)
         | 
| 19709 | 
            +
                  upper_test = orig_val > @interp.scalar_value_of(rslt_type.max)
         | 
| 19710 19710 |  | 
| 19711 19711 | 
             
                  if lower_test.must_be_true? || upper_test.must_be_true?
         | 
| 19712 19712 | 
             
                    W(expr.location)
         | 
| @@ -19729,7 +19729,7 @@ module CBuiltin #:nodoc: | |
| 19729 19729 | 
             
                end
         | 
| 19730 19730 |  | 
| 19731 19731 | 
             
                private
         | 
| 19732 | 
            -
                def check(expr, lhs_var, rhs_var,  | 
| 19732 | 
            +
                def check(expr, lhs_var, rhs_var, rslt_var)
         | 
| 19733 19733 | 
             
                  return unless lhs_var.type.scalar? && lhs_var.type.unsigned?
         | 
| 19734 19734 | 
             
                  return unless rhs_var.type.scalar? && rhs_var.type.unsigned?
         | 
| 19735 19735 | 
             
                  return unless lhs_var.value.scalar? && rhs_var.value.scalar?
         | 
| @@ -19745,11 +19745,11 @@ module CBuiltin #:nodoc: | |
| 19745 19745 | 
             
                    return
         | 
| 19746 19746 | 
             
                  end
         | 
| 19747 19747 |  | 
| 19748 | 
            -
                  lower_test = unbound_val < @interp.scalar_value_of( | 
| 19749 | 
            -
                  upper_test = unbound_val > @interp.scalar_value_of( | 
| 19748 | 
            +
                  lower_test = unbound_val < @interp.scalar_value_of(rslt_var.type.min)
         | 
| 19749 | 
            +
                  upper_test = unbound_val > @interp.scalar_value_of(rslt_var.type.max)
         | 
| 19750 19750 |  | 
| 19751 19751 | 
             
                  if lower_test.must_be_true? || upper_test.must_be_true?
         | 
| 19752 | 
            -
                    W(expr.location,  | 
| 19752 | 
            +
                    W(expr.location, rslt_var.type.brief_image)
         | 
| 19753 19753 | 
             
                  end
         | 
| 19754 19754 | 
             
                end
         | 
| 19755 19755 | 
             
              end
         | 
| @@ -19769,7 +19769,7 @@ module CBuiltin #:nodoc: | |
| 19769 19769 | 
             
                end
         | 
| 19770 19770 |  | 
| 19771 19771 | 
             
                private
         | 
| 19772 | 
            -
                def check(expr, lhs_var, rhs_var,  | 
| 19772 | 
            +
                def check(expr, lhs_var, rhs_var, rslt_var)
         | 
| 19773 19773 | 
             
                  return unless lhs_var.type.scalar? && lhs_var.type.unsigned?
         | 
| 19774 19774 | 
             
                  return unless rhs_var.type.scalar? && rhs_var.type.unsigned?
         | 
| 19775 19775 | 
             
                  return unless lhs_var.value.scalar? && rhs_var.value.scalar?
         | 
| @@ -19785,12 +19785,12 @@ module CBuiltin #:nodoc: | |
| 19785 19785 | 
             
                    return
         | 
| 19786 19786 | 
             
                  end
         | 
| 19787 19787 |  | 
| 19788 | 
            -
                  lower_test = unbound_val < @interp.scalar_value_of( | 
| 19789 | 
            -
                  upper_test = unbound_val > @interp.scalar_value_of( | 
| 19788 | 
            +
                  lower_test = unbound_val < @interp.scalar_value_of(rslt_var.type.min)
         | 
| 19789 | 
            +
                  upper_test = unbound_val > @interp.scalar_value_of(rslt_var.type.max)
         | 
| 19790 19790 |  | 
| 19791 19791 | 
             
                  if !lower_test.must_be_true? && lower_test.may_be_true? or
         | 
| 19792 19792 | 
             
                      !upper_test.must_be_true? && upper_test.may_be_true?
         | 
| 19793 | 
            -
                    W(expr.location,  | 
| 19793 | 
            +
                    W(expr.location, rslt_var.type.brief_image)
         | 
| 19794 19794 | 
             
                  end
         | 
| 19795 19795 | 
             
                end
         | 
| 19796 19796 | 
             
              end
         | 
| @@ -20236,10 +20236,10 @@ module CBuiltin #:nodoc: | |
| 20236 20236 | 
             
                  @retn_vals = nil
         | 
| 20237 20237 | 
             
                end
         | 
| 20238 20238 |  | 
| 20239 | 
            -
                def add_return_value(expr, fun, *,  | 
| 20239 | 
            +
                def add_return_value(expr, fun, *, rslt_var)
         | 
| 20240 20240 | 
             
                  if @cur_fun
         | 
| 20241 20241 | 
             
                    unless fun.type.return_type.void?
         | 
| 20242 | 
            -
                      @retn_vals[ | 
| 20242 | 
            +
                      @retn_vals[rslt_var] = [false, expr, fun]
         | 
| 20243 20243 | 
             
                    end
         | 
| 20244 20244 | 
             
                  end
         | 
| 20245 20245 | 
             
                end
         | 
| @@ -20443,9 +20443,9 @@ module CBuiltin #:nodoc: | |
| 20443 20443 | 
             
                end
         | 
| 20444 20444 |  | 
| 20445 20445 | 
             
                private
         | 
| 20446 | 
            -
                def check(init_or_expr,  | 
| 20447 | 
            -
                  from_type =  | 
| 20448 | 
            -
                  to_type =  | 
| 20446 | 
            +
                def check(init_or_expr, orig_var, rslt_var)
         | 
| 20447 | 
            +
                  from_type = orig_var.type
         | 
| 20448 | 
            +
                  to_type = rslt_var.type
         | 
| 20449 20449 |  | 
| 20450 20450 | 
             
                  if from_type.undeclared? || from_type.unresolved? ||
         | 
| 20451 20451 | 
             
                      to_type.undeclared? || to_type.unresolved?
         | 
| @@ -20456,13 +20456,13 @@ module CBuiltin #:nodoc: | |
| 20456 20456 | 
             
                  when Cc1::Initializer
         | 
| 20457 20457 | 
             
                    expr = init_or_expr.expression
         | 
| 20458 20458 | 
             
                    if expr && @interp.constant_expression?(expr)
         | 
| 20459 | 
            -
                      if untyped_pointer_conversion?(from_type, to_type,  | 
| 20459 | 
            +
                      if untyped_pointer_conversion?(from_type, to_type, orig_var.value)
         | 
| 20460 20460 | 
             
                        return
         | 
| 20461 20461 | 
             
                      end
         | 
| 20462 20462 | 
             
                    end
         | 
| 20463 20463 | 
             
                  when Cc1::Expression
         | 
| 20464 20464 | 
             
                    if @interp.constant_expression?(init_or_expr)
         | 
| 20465 | 
            -
                      if untyped_pointer_conversion?(from_type, to_type,  | 
| 20465 | 
            +
                      if untyped_pointer_conversion?(from_type, to_type, orig_var.value)
         | 
| 20466 20466 | 
             
                        return
         | 
| 20467 20467 | 
             
                      end
         | 
| 20468 20468 | 
             
                    end
         |