Re: Improved C warning messages

gopi@sankhya.com
26 Apr 1999 02:03:18 -0400

          From comp.compilers

Related articles
Improved C warning messages mikov@usa.net (Tzvetan Mikov) (1999-04-22)
Re: Improved C warning messages jejones@microware.com (James Jones) (1999-04-26)
Re: Improved C warning messages gopi@sankhya.com (1999-04-26)
Re: Improved C warning messages rinie4384@my-dejanews.com (1999-04-26)
Re: Improved C warning messages fjh@cs.mu.OZ.AU (1999-04-29)
Re: Improved C warning messages mikov@usa.net (Tzvetan Mikov) (1999-04-29)
Re: Improved C warning messages mikov@usa.net (Tzvetan Mikov) (1999-04-29)
Re: Improved C warning messages saroj@bear.com (1999-04-30)
| List of all articles for this month |
From: gopi@sankhya.com
Newsgroups: comp.compilers
Date: 26 Apr 1999 02:03:18 -0400
Organization: Deja News - The Leader in Internet Discussion
References: 99-04-080
Keywords: C, errors

    "Tzvetan Mikov" <mikov@usa.net> wrote:
> I am developing an ANSI C compiler and here is a problem I stumbled upon
> recently. It is not of great importance for the code generation, but it is
> interesting and I would appreciate any ideas or pointers for a clean
> solution.


In the parse tree at each node, you could maintain in addition to the type of
the expression, the smallest data type that is known to hold the value without
losing any information. This can then be used to decide on whether or not
a particular warning should be issued.


> unsigned u;
> short s;
> ....
> s = u >> 16; // must not produce warning about assigning int to short


Assuming u is 32-bit int, the above can in fact be a correct worning -- unless
the shift value is >= 17. (0xffffffff >> 16) != (short)0xffff


> abstracted the front end from the target CPU. It operates with
> variable type sizes (e.g. "int" might be or might not be equal to
> "long", etc.) It gets even more interesting if signed and unsigned
> bitfields are involved.


I believe a conservative use of the above method would result in an elegant
solution.


Best Regards,
gopi
---


Gopi Kumar Bulusu bulusu@giasmd01.vsnl.net.in
Sankhya Technologies Private Ltd. http://www.sankhya.com
+91 44 822 7357 GMT + 5:30


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.