scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 4626414db8c5ae6f8b65054d74465626be2a4fc1
parent 545b4aacc0f5f08df8c2a75c77ef02287127c098
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 13 Feb 2017 09:13:10 +0100

[cc1] Add warnings about promotable types in va_arg()

Bool, char  and short are promoted to int when they are passed through ...,
and it means that it is impossible to have them in a stack created by a
variadic function. This patch warns to the user about it and correct
the type to int.

Diffstat:
Mcc1/builtin.c | 6++++++
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/cc1/builtin.c b/cc1/builtin.c @@ -20,6 +20,12 @@ builtin_va_arg(Symbol *sym) errorp("incorrect parameters for va_arg"); return constnode(zero); } + if (tp == booltype || + tp == chartype || tp == uchartype || tp == schartype || + tp == shortype || tp == ushortype) { + warn("bool, char and short are promoted to int when passed through '...'"); + tp = (tp->prop & TSIGNED) ? inttype : uinttype; + } np = node(OBUILTIN, tp, ap, NULL); np->sym = sym;