From 105edc5126564e14f916a853eb24504b91fe6805 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 20 Jan 2025 22:08:13 +0900 Subject: [PATCH] [qfcc] Don't allow overloading of main for glsl It's supposed to always be void(void), so... --- tools/qfcc/source/glsl-parse.y | 2 +- tools/qfcc/source/target_spirv.c | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/qfcc/source/glsl-parse.y b/tools/qfcc/source/glsl-parse.y index a5b91c597..348fae2a7 100644 --- a/tools/qfcc/source/glsl-parse.y +++ b/tools/qfcc/source/glsl-parse.y @@ -331,7 +331,7 @@ function_definition $$ = current_symtab; auto spec = $1; spec.sym->params = spec.params; - spec.is_overload = true; + spec.is_overload = strcmp (spec.sym->name, "main") != 0; spec.type = find_type (parse_params (spec.type, spec.params)); spec.sym = function_symbol (spec, ctx); current_func = begin_function (spec, nullptr, current_symtab, ctx); diff --git a/tools/qfcc/source/target_spirv.c b/tools/qfcc/source/target_spirv.c index 743239285..577a2ec2f 100644 --- a/tools/qfcc/source/target_spirv.c +++ b/tools/qfcc/source/target_spirv.c @@ -817,6 +817,10 @@ spirv_function (function_t *func, spirvctx_t *ctx) static void spirv_EntryPoint (entrypoint_t *entrypoint, spirvctx_t *ctx) { + if (!entrypoint->func) { + error (0, "entry point %s never defined", entrypoint->name); + return; + } unsigned func_id = spirv_function (entrypoint->func, ctx); int len = strlen (entrypoint->name) + 1; @@ -2065,8 +2069,7 @@ static void spirv_build_code (function_t *func, const expr_t *statements) { func->exprs = statements; - if (strncmp ("main", func->o_name, 4) == 0 - && (!func->o_name[4] || func->o_name[4] == '|')) { + if (strcmp ("main", func->o_name) == 0) { attribute_t *mode = nullptr; if (pr.module->default_model == SpvExecutionModelFragment) { mode = new_attribute ("mode",