1. Building a script that triggers all warnings
- Posted by SDPringle Apr 13, 2018
- 1015 views
In order to see which warnings are really enabled, a script is needed that triggers all warnings. Here is what I have so far:
-- warning_file( "warnings_issued.txt" ) type boolean(integer x) return x = x * x end type global integer foo -- expect resolution warning here if resolution is enabled {resolution} include dependency.e integer a1 = 1 -- expect short-circut warning here if short-circut is enabled {short_circuit} function increment_a1() a1 += 1 return a1 end function -- do warn here because increment_a1() has a side-effect if a1 and increment_a1() then -- do nothing end if -- do not expect short-circut warning here though even if short-circut is enabled if a1 and time() then -- do nothing end if -- do warn here that puts is being overridden {override} override procedure puts(integer fd, sequence s) boolean must_recurse = 0 for i = 1 to length(s) do if not integer(s[i]) or s[i] < 0 or s[i] > 255 then must_recurse = 1 end if end for if must_recurse then eu:puts(fd, "{ ") for i = 1 to length(s) do puts(fd, "\"" & s[i] & "\", ") end for eu:puts(fd, " }") else eu:puts(fd, s) end if end procedure puts(1, "") global procedure printf(integer fd, sequence fmt, sequence s) --eu:printf(fd, fmt, s) end procedure -- warn about builtin_chosen printf(1, "", {}) procedure bar() integer unused = 5 end procedure -- war about not_used bar() -- warn about no_value procedure baz() integer no_value end procedure baz() -- warn about useless code {custom} warning("Useless code") abort(0) -- Code {not_reached} a1 = 1 -- {translator} warning must be issued from the command line arguments : An option was given to the translator, but this option is not recognized as valid for the C compiler being used. -- {cmdline} is an anachronism ifdef not LINUX then -- {mixed_profile} with profile_time with profile end ifdef switch 4 without fallthru do case 0 then -- {empty_case} case 1 then print(1, "one") -- no case else {default_case} end switch |