This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Request for a compiler feature



> >> I'd like the compiler to generate error messages based on the typedefs
> >> used in the code, not the actual underlying types.
> 
> > This is a good request.  When we get a little time, I'm sure someone
> > will get it implemented.
> 
> A good start would be checking all the uses of TYPE_MAIN_DECL.  Now that
> typedef types refer to the typedef, we shouldn't throw that information
> away by using TYPE_MAIN_DECL; we should grab the typedef instead in most
> cases.

Sounds good, but:

Warning: while 95% of the time, outputting the typedef types will be a big
improvement, there are a number of errors that the user will have
difficulty resolving without seeing the expanded types.  These are cases
where the error is that a typedef is set to the wrong value; in this case
the true error will be hidden.  These types of errors are likely to occur
for people developing STL-compatible containers, or for some uses of such
containers.

Example: I might accidentally write something like

typedef pair<Key,const Value> MyMapType;

and then later try to use this in conjunction with a map<Key,Value> -- the
error is that Key should be const and Value non-const.  If I then get
a bunch of errors about its use, it might take a bit of code-reading to
track down the error (though maybe that code reading wouldn't be too
difficult).

I hate to propose yet another flag, but at least on a temporary basis, if
this is done, I suggest a flag that would cause errors to be output the
"old" way, with the default being to output the typedef types.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]