shithub: scc

Download patch

ref: c863f70762d5c00224431259e92b0eb5114b2b61
parent: a639f3f1bf3ee7a1645eddac929afc4a253e0c84
author: Roberto E. Vargas Caballero <[email protected]>
date: Sat Jun 18 05:15:20 EDT 2022

cc1: Accept casts in sizeof expressions

Casts can be used in sizeof expressions and it means that
we have to call to cast() instead of calling unary() in
sizeexp().

--- a/src/cmd/cc/cc1/expr.c
+++ b/src/cmd/cc/cc1/expr.c
@@ -739,8 +739,6 @@
 	return node(op, rettype, np, par);
 }
 
-static Node *unary(void);
-
 static Type *
 typeof(Node *np)
 {
@@ -759,6 +757,8 @@
 	return tp;
 }
 
+static Node *cast(void);
+
 static Type *
 sizeexp(void)
 {
@@ -771,7 +771,7 @@
 		tp = typename();
 		break;
 	default:
-		tp = typeof(unary());
+		tp = typeof(cast());
 		break;
 	}
 	expect(')');
@@ -813,8 +813,6 @@
 		}
 	}
 }
-
-static Node *cast(void);
 
 static Node *
 unary(void)