ref: 32f48f63b7269aa19307f9a973d326e7b32ebad4
parent: 7611e66c4a272e9e4ada31a6996670298a476dff
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Nov 5 00:15:41 EDT 2021
cc1: Simplify Return()
--- a/src/cmd/cc/cc1/stmt.c
+++ b/src/cmd/cc/cc1/stmt.c
@@ -170,22 +170,23 @@
static void
Return(Symbol *lbreak, Symbol *lcont, Switch *lswitch)
{- Node *np;
+ Node *np = NULL;
Type *tp = curfun->type->type;
expect(RETURN);
- np = (yytoken != ';') ? decay(expr()) : NULL;
+ if (yytoken != ';')
+ np = decay(expr());
expect(';');- if (!np) {- if (tp != voidtype)
- warn("function returning non void returns no value");- tp = voidtype;
- } else if (np->type != tp) {+
+ if (!np && tp != voidtype)
+ warn("function returning non void returns no value");+ else if (np && np->type != tp) {if (tp == voidtype)
warn("function returning void returns a value");else if ((np = convert(np, tp, 0)) == NULL)
errorp("incorrect type in return");}
+
emit(ORET, NULL);
emit(OEXPR, np);
}
--
⑨