commit 8964018d89e7405c5a16d32b994738ba10d73f9e
Author:     Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Wed Aug 5 22:36:24 2015 +0200
Commit:     Roberto E. Vargas Caballero <[email protected]>
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
@@ -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);
                }

Reply via email to