From 9b5c6bfff0329938b868a318b8d61164110a8047 Mon Sep 17 00:00:00 2001 From: Arkshine Date: Wed, 13 Aug 2014 18:22:06 +0200 Subject: [PATCH] Compiler: Fix asserting when returning a string literal. Imported from SM: https://bugs.alliedmods.net/show_bug.cgi?id=3836. --- compiler/libpc300/sc1.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compiler/libpc300/sc1.c b/compiler/libpc300/sc1.c index 7a097918..1cdcf643 100755 --- a/compiler/libpc300/sc1.c +++ b/compiler/libpc300/sc1.c @@ -5251,6 +5251,11 @@ static void doreturn(void) error(78); /* mix "return;" and "return value;" */ ident=doexpr(TRUE,FALSE,TRUE,TRUE,&tag,&sym,TRUE); needtoken(tTERM); + if (ident == iARRAY && sym == NULL) { + /* returning a literal string is not supported (it must be a variable) */ + error(39); + ident = iCONSTEXPR; /* avoid handling an "array" case */ + } /* if */ /* see if this function already has a sub type (an array attached) */ sub=finddepend(curfunc); assert(sub==NULL || sub->ident==iREFARRAY);