[hackers] [scc] Check format of enum constant || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Fri, 7 Aug 2015 09:15:47 +0200 (CEST)

commit 8964018d89e7405c5a16d32b994738ba10d73f9e
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Wed Aug 5 22:36:24 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Wed Aug 5 22:36:24 2015 +0200

    Check format of enum constant

diff --git a/cc1/decl.c b/cc1/decl.c
index 3c782fa..5247887 100644
--- a/cc1/decl.c
+++ b/cc1/decl.c
_AT_@ -327,12 +327,10 @@ enumdcl(void)
                 sym->flags |= ISCONSTANT;
                 sym->type = inttype;
                 if (accept('=')) {
- Node *np = constexpr();
- /*
- * TODO: check that the type of the constant
- * expression is the correct, that in this
- * case should be int
- */
+ Node *np = iconstexpr();
+
+ if (np == NULL)
+ error("invalid enumeration value");
                         val = np->sym->u.i;
                         freetree(np);
                 }
Received on Fri Aug 07 2015 - 09:15:47 CEST

This archive was generated by hypermail 2.3.0 : Fri Aug 07 2015 - 09:24:12 CEST