[hackers] [scc] Do not recover in arguments() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Mon, 2 Nov 2015 17:46:22 +0100 (CET)

commit 5248a9060ab850caff27bdefc8faf609ffe4f2c5
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Nov 2 17:43:52 2015 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Nov 2 17:46:10 2015 +0100

    Do not recover in arguments()
    
    There was a call to error() when () was used in something
    that was not a function, but this error is a semantic error
    where it is easy do not recover.

diff --git a/cc1/expr.c b/cc1/expr.c
index e5b7aea..124dc31 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
_AT_@ -561,22 +561,26 @@ static Node *assign(void);
 static Node *
 arguments(Node *np)
 {
- int toomany;;
- TINT n;
+ int toomany, n;
         Node *par = NULL, *arg;
- Type *argtype, **targs, *tp = np->type;
+ Type *argtype, **targs, *tp = np->type, *rettype;
 
         if (tp->op == PTR && tp->type->op == FTN) {
                 np = content(OPTR, np);
                 tp = np->type;
         }
- if (tp->op != FTN)
- error("function or function pointer expected");
- targs = tp->p.pars;
+ if (tp->op != FTN) {
+ targs = (Type *[]) {ellipsistype};
+ n = 1;
+ rettype = inttype;
+ errorp("function or function pointer expected");
+ } else {
+ targs = tp->p.pars;
+ n = tp->n.elem;
+ rettype = tp->type;
+ }
 
         expect('(');
-
- n = tp->n.elem;
         if (yytoken == ')')
                 goto no_pars;
         toomany = 0;
_AT_@ -618,7 +622,7 @@ no_pars:
                 errorp("too few arguments in function call");
 
         expect(')');
- return node(OCALL, np->type->type, np, par);
+ return node(OCALL, rettype, np, par);
 }
 
 static Node *
Received on Mon Nov 02 2015 - 17:46:22 CET

This archive was generated by hypermail 2.3.0 : Mon Nov 02 2015 - 17:48:12 CET