Re: No warnings for unreferenced code in eu40b2 build r3025
- Posted by Spock Jan 05, 2010
- 984 views
I'm not sure that I agree with Derek that even "one routine_id() whose argument is not a literal" automatically means that "any routine could be called" thus defeating a check for unreferenced code. This is because routine_id() can only reach as far as it's scope allows - anything outside that is fair game for analysis.
While that is true, it's actually the call_proc() that is in question here. For example, a call to routine_id() can fetch a valid ID value then pass that value to another routine that in turn runs call_proc().
Derek,
I think you're missing the point. Any module not part of the scope of a routine_id() call could potentially have non-referenced routines in it that a parser can detect and ignore. Let's consider your very own example with a small adjustment:
A library file ...
--- filea.e procedure PROC_foo() puts(1, "called\n") end procedure public function getrid( sequence name) return routine_id("PROC_" & name) end function ---- end of filea.e ---
The app file ...
-- myapp.ex include filea.e integer rid sequence cmds procedure nop() -- redundant routine return end procedure cmds = command_line() rid = getrid(cmds[3]) call_proc( rid,{}) -- end of myapp.ex
In this case nop() is not in the scope of routine_id. It is also not called directly from anywhere in the code. Logically it could be omitted from the compiler output and have no impact whatsoever on the program execution.
How would nop() be called inadvertently? No routine_id() can see it to pass its' id to another part of the cade to be called indirectly. And it's not called directly either. So, how?
regards,
Mike