[hackers] [scc] [cc1] Add warnings about promotable types in va_arg() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Mon, 13 Feb 2017 11:35:43 +0100 (CET)

commit 4626414db8c5ae6f8b65054d74465626be2a4fc1
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 11:35:31 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..275bdaf 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->prop & TSIGNED) ? inttype : uinttype;
+ }
 
         np = node(OBUILTIN, tp, ap, NULL);
         np->sym = sym;
Received on Mon Feb 13 2017 - 11:35:43 CET

This archive was generated by hypermail 2.3.0 : Mon Feb 13 2017 - 11:36:15 CET