On Friday, 5 February 2016 at 03:46:37 UTC, Chris Wright wrote:
On Fri, 05 Feb 2016 01:10:53 +0000, tsbockman wrote:
The compiler doesn't have all the information you need. You
could add it to the build system or the linker as well as the
compiler. Adding it to the linker is almost identical to my
previous suggestion of adding optional name mangling to C.
What information, specifically, is the compiler missing?
The compiler already computes the name and type signature of each
function. As far as I can see, all that is necessary is to:
1) Insert that information (together with what file and line
number it came from) into a big list in a temporary file.
2) After all modules have been compiled, go back and sort the
list by function name.
3) Finally, scan the list for entries that share the same name,
but have incompatible type signatures. Emit warning messages as
needed. (The compiler should be used for this step, because it
already has a lot of information about C's type system built into
it that can help define "incompatible" sensibly.)
As far as I can see, this requires an extra pass, but no
additional information. What am I missing?