shithub: scc

Download patch

ref: 4b7c7bc9c581cd8305bd2b7f9741c25f6ec5943f
parent: 3b828bbd092e2bcdc06371f6cdb915c1fa49a6ff
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Apr 22 13:10:40 EDT 2014

Forbid modify a void expression

A void expression cannot be modified, so this check
must be explicitily done.

--- a/expr.c
+++ b/expr.c
@@ -331,6 +331,8 @@
 
 	if (!np->b.lvalue)
 		goto nolvalue;
+	if (np->utype == voidtype)
+		goto voidassign;
 	if (isconst(tp->op))
 		goto const_mod;
 
@@ -344,6 +346,9 @@
 		goto bad_type;
 	}
 
+voidassign:
+	err = "invalid use of void expression";
+	goto error;
 nolvalue:
 	err = "lvalue required in operation";
 	goto error;
@@ -720,11 +725,16 @@
 		}
 		if (!np->b.lvalue)
 			goto nolvalue;
+		if (np->utype == voidtype)
+			goto voidassign;
 		if (isconst(np->type->op))
 			goto const_mod;
 		next();
 		np = (fun)(op, np, eval(assign()));
 	}
+voidassign:
+	err = "invalid use of void expression";
+	goto error;
 const_mod:
 	err = "const value modified";
 	goto error;