pike.git/
src/
las.c
Branch:
Tag:
Non-build tags
All tags
No tags
2017-09-09
2017-09-09 10:36:40 by Marcus Comstedt <marcus@mc.pp.se>
faa94f504c5874a09e376a8a45a45a9f6a94d4b0 (
23
lines) (+
17
/-
6
)
[
Show
|
Annotate
]
Branch:
8.1
Compiler: Allow return void expression from void function
Fixes [LysLysKOM 22188815].
3738:
case F_RETURN: if (!CAR(n) || (CAR(n)->type == void_type_string)) {
-
yywarning("Returning a void expression. Converted to zero.");
+
if (!CAR(n)) { _CAR(n) = mkintnode(0); copy_pike_type(n->type, CAR(n)->type);
3746:
_CAR(n) = mknode(F_COMMA_EXPR, CAR(n), mkintnode(0)); copy_pike_type(n->type, CDAR(n)->type); }
+
if (!Pike_compiler->compiler_frame ||
+
Pike_compiler->compiler_frame->current_return_type !=
+
void_type_string) {
+
yywarning("Returning a void expression. Converted to zero.");
break; }
-
+
}
else if(Pike_compiler->compiler_frame && Pike_compiler->compiler_frame->current_return_type) {
3771:
free_type( t ); t = pop_type(); Pike_compiler->compiler_frame->current_return_type = t;
-
} else if ((Pike_compiler->compiler_frame->current_return_type !=
+
} else
{
+
node *retval = CAR(n);
+
if (
retval->token == F_COMMA_EXPR) {
+
retval = CDR
(
retval);
+
}
+
if ((
Pike_compiler->compiler_frame->current_return_type !=
void_type_string) ||
-
(
CAR(n)
->token != F_CONSTANT) ||
-
!SAFE_IS_ZERO(&
CAR(n)
->u.sval)) {
+
(
retval
->token != F_CONSTANT) ||
+
!SAFE_IS_ZERO(&
retval
->u.sval)) {
check_node_type(CAR(n), t, "Wrong return type."); } }
-
+
}
copy_pike_type(n->type, void_type_string); break;