[hackers] [scc] [cc1] Add warnings about promotable types in va_arg() || Roberto E. Vargas Caballero
commit dd272d82cb84240d799c8af078cb995415bef0f0
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Feb 13 09:13:10 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Feb 13 09:13:10 2017 +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.
diff --git a/cc1/builtin.c b/cc1/builtin.c
index d2b3068..49eab2a 100644
--- a/cc1/builtin.c
+++ b/cc1/builtin.c
_AT_@ -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->flags & TSIGNED) ? inttype : uinttype;
+ }
np = node(OBUILTIN, tp, ap, NULL);
np->sym = sym;
Received on Mon Feb 13 2017 - 09:17:40 CET
This archive was generated by hypermail 2.3.0
: Mon Feb 13 2017 - 09:24:18 CET