mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-04-16 06:11:15 +00:00
[qfcc] Clear current function for constexpr evaluation
The code gen return statements checks for out/inout parameters in the current function and thus could result in some undesired behavior when constants are evaluated within such a function.
This commit is contained in:
parent
5714433a9c
commit
7a30ac9527
1 changed files with 5 additions and 0 deletions
|
@ -45,6 +45,7 @@
|
|||
#include "tools/qfcc/include/dot.h"
|
||||
#include "tools/qfcc/include/evaluate.h"
|
||||
#include "tools/qfcc/include/expr.h"
|
||||
#include "tools/qfcc/include/function.h"
|
||||
#include "tools/qfcc/include/opcodes.h"
|
||||
#include "tools/qfcc/include/options.h"
|
||||
#include "tools/qfcc/include/statements.h"
|
||||
|
@ -251,6 +252,8 @@ evaluate_constexpr (const expr_t *e)
|
|||
|
||||
defspace_reset (&value_defspace);
|
||||
auto saved_version = options.code.progsversion;
|
||||
auto saved_func = current_func;
|
||||
current_func = nullptr;
|
||||
options.code.progsversion = PROG_VERSION;
|
||||
sblock_t sblock = {
|
||||
.tail = &sblock.statements,
|
||||
|
@ -258,6 +261,8 @@ evaluate_constexpr (const expr_t *e)
|
|||
ex_listitem_t return_expr = { .expr = new_return_expr (e) };
|
||||
ex_list_t return_st = { .head = &return_expr, .tail = &return_expr.next };
|
||||
auto sb = statement_slist (&sblock, &return_st);
|
||||
current_func = saved_func;
|
||||
|
||||
if (sblock.next != sb && sb->statements) {
|
||||
internal_error (e, "statement_slist did too much");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue