ref: f441e1db75872457deb4aacf39500f3cc6185554
parent: 75f3f829eaa2e72575b9e5c802b290a17d837e54
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu Jun 16 12:37:34 EDT 2022
cc1: Accept () in primary() Accepting parentheses was moved to cast() because we require a 2 token ahead, and the only possible way of doing that was accepting parenthesis there. The problems comes because unary() calls primary() and unary() is called from sizeexp() that is called from unary(). It means that a sizeof expression could not begin with 2 parenthesis (one was already removed in sizeexp()) and for that reason we have to accept parenthesis in primary().
--- a/src/cmd/cc/cc1/expr.c
+++ b/src/cmd/cc/cc1/expr.c
@@ -627,6 +627,13 @@
case DEFINED:
np = defined();
break;
+ case '(':
+ next();
+ np = xexpr();
+ expect(')');
+
+ /* do not call to next */
+ return np;
case IDEN:
assert((sym->flags & SCONSTANT) == 0);
if ((sym->flags & SDECLARED) != 0) {