This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

Re: Elimination of duplicate sign extensions


Paul Brook wrote:

> IIUC TARGET_PROMOTE_PROTOTYPES deliberately introduces an asymmetric calling 
> convention. i.e. the caller must promote the value and the callee may not 
> assume the value is promoted. From the documentation of the hook, this 
> appears to be a deliberate feature to workaround broken code with mismatches 
> prototypes.

I guess an example of where this helps is (invalid) code like this:

a.c
---
void f(char c);
void g() { f('a'); }

b.c
---
void f(short s) {}

Here, absent TPP, the char argument to "f" would not be promoted, so
we'd have a char where we want a short.  By extending in the caller, we
make sure that we get a valid value to the callee.

I still don't quite get why we need to extend in the callee, though.

Thanks,

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713


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