Semantic analysis was reporting a NULL datatype for funcs with void retvals.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 31 Dec 2014 16:49:59 -0500
changeset 1145 07f69ab909ec
parent 1144 8ca4b4f3ef22
child 1146 31337471b909
Semantic analysis was reporting a NULL datatype for funcs with void retvals.
mojoshader_compiler.c
--- a/mojoshader_compiler.c	Sun Nov 23 21:21:25 2014 -0500
+++ b/mojoshader_compiler.c	Wed Dec 31 16:49:59 2014 -0500
@@ -1888,22 +1888,23 @@
                                         const MOJOSHADER_astDataType **params,
                                         const int intrinsic)
 {
-    if ( ((paramcount > 0) && (params == NULL)) ||
-         ((paramcount == 0) && (params != NULL)) )
-        return NULL;
-
-    // !!! 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)))
+    const MOJOSHADER_astDataType **dtparams = NULL;
+    void *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)