From 44bf45043ad4b6e8a0832e0d32ce5c0f995cfe3c Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 31 Dec 2014 16:49:59 -0500 Subject: [PATCH] Semantic analysis was reporting a NULL datatype for funcs with void retvals. --- mojoshader_compiler.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/mojoshader_compiler.c b/mojoshader_compiler.c index b166f8f8..3e49ff64 100644 --- a/mojoshader_compiler.c +++ b/mojoshader_compiler.c @@ -1888,22 +1888,23 @@ static const MOJOSHADER_astDataType *build_function_datatype(Context *ctx, const MOJOSHADER_astDataType **params, const int intrinsic) { - if ( ((paramcount > 0) && (params == NULL)) || - ((paramcount == 0) && (params != NULL)) ) - return NULL; + const MOJOSHADER_astDataType **dtparams = NULL; + void *ptr; - // !!! FIXME: this is hacky. - const MOJOSHADER_astDataType **dtparams; - void *ptr = Malloc(ctx, sizeof (*params) * paramcount); - if (ptr == NULL) - return NULL; - if (!buffer_append(ctx->garbage, &ptr, sizeof (ptr))) + if (paramcount > 0) { - Free(ctx, ptr); - return NULL; - } // if - dtparams = (const MOJOSHADER_astDataType **) ptr; - memcpy(dtparams, params, sizeof (*params) * paramcount); + // !!! FIXME: this is hacky. + ptr = Malloc(ctx, sizeof (*params) * paramcount); + if (ptr == NULL) + return NULL; + if (!buffer_append(ctx->garbage, &ptr, sizeof (ptr))) + { + Free(ctx, ptr); + return NULL; + } // if + dtparams = (const MOJOSHADER_astDataType **) ptr; + memcpy(dtparams, params, sizeof (*params) * paramcount); + } ptr = Malloc(ctx, sizeof (MOJOSHADER_astDataType)); if (ptr == NULL)