assert(oper->type == SLANG_OPER_RETURN);
+ if (A->CurFunction->header.type.specifier.type == SLANG_SPEC_VOID) {
+ slang_info_log_error(A->log, "illegal return expression");
+ return NULL;
+ }
+
blockOper = slang_operation_new(1);
blockOper->type = SLANG_OPER_BLOCK_NO_NEW_SCOPE;
blockOper->locals->outer_scope = oper->locals->outer_scope;
assert(oper->type == SLANG_OPER_RETURN);
+ if (A->CurFunction->header.type.specifier.type != SLANG_SPEC_VOID) {
+ slang_info_log_error(A->log, "return statement requires an expression");
+ return NULL;
+ }
+
if (A->UseReturnFlag) {
/* Emit:
* __notRetFlag = 0;
else
newReturn = gen_return_with_expression(A, oper);
+ if (!newReturn)
+ return;
+
/* do substitutions on the new 'return' code */
slang_substitute(A, newReturn,
substCount, substOld, substNew, GL_FALSE);
static slang_ir_node *
_slang_gen_return(slang_assemble_ctx * A, slang_operation *oper)
{
- const GLboolean haveReturnValue
- = (oper->num_children == 1 && oper->children[0].type != SLANG_OPER_VOID);
-
- assert(oper->type == SLANG_OPER_RETURN ||
- oper->type == SLANG_OPER_RETURN_INLINED);
-
- /* error checking */
- if (oper->type == SLANG_OPER_RETURN) {
- assert(A->CurFunction);
-
- if (haveReturnValue &&
- A->CurFunction->header.type.specifier.type == SLANG_SPEC_VOID) {
- slang_info_log_error(A->log, "illegal return expression");
- return NULL;
- }
- else if (!haveReturnValue &&
- A->CurFunction->header.type.specifier.type != SLANG_SPEC_VOID) {
- slang_info_log_error(A->log, "return statement requires an expression");
- return NULL;
- }
- }
-
+ assert(oper->type == SLANG_OPER_RETURN);
return new_return(A->curFuncEndLabel);
}