mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fix default #foo args.
This commit is contained in:
@@ -1724,6 +1724,7 @@ struct SemaContext_
|
|||||||
Decl** locals;
|
Decl** locals;
|
||||||
DynamicScope active_scope;
|
DynamicScope active_scope;
|
||||||
Expr *return_expr;
|
Expr *return_expr;
|
||||||
|
bool is_temp;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ void gencontext_begin_module(GenContext *c)
|
|||||||
ASSERT0(!c->module && "Expected no module");
|
ASSERT0(!c->module && "Expected no module");
|
||||||
|
|
||||||
codegen_setup_object_names(c->code_module, &c->ir_filename, &c->asm_filename, &c->object_filename);
|
codegen_setup_object_names(c->code_module, &c->ir_filename, &c->asm_filename, &c->object_filename);
|
||||||
|
DEBUG_LOG("Emit module %s.", c->code_module->name->module);
|
||||||
c->panic_var = compiler.context.panic_var;
|
c->panic_var = compiler.context.panic_var;
|
||||||
c->panicf = compiler.context.panicf;
|
c->panicf = compiler.context.panicf;
|
||||||
c->module = LLVMModuleCreateWithNameInContext(c->code_module->name->module, c->context);
|
c->module = LLVMModuleCreateWithNameInContext(c->code_module->name->module, c->context);
|
||||||
|
|||||||
@@ -1362,6 +1362,12 @@ static bool sema_analyse_parameter(SemaContext *context, Expr *arg, Decl *param,
|
|||||||
break;
|
break;
|
||||||
case VARDECL_PARAM_EXPR:
|
case VARDECL_PARAM_EXPR:
|
||||||
// #foo
|
// #foo
|
||||||
|
if (context->is_temp)
|
||||||
|
{
|
||||||
|
SemaContext *temp = context;
|
||||||
|
context = MALLOCS(SemaContext);
|
||||||
|
*context = *temp;
|
||||||
|
}
|
||||||
param->var.hash_var.context = context;
|
param->var.hash_var.context = context;
|
||||||
param->var.hash_var.span = arg->span;
|
param->var.hash_var.span = arg->span;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -529,6 +529,7 @@ SemaContext *context_transform_for_eval(SemaContext *context, SemaContext *temp_
|
|||||||
temp_context->compilation_unit = context->compilation_unit;
|
temp_context->compilation_unit = context->compilation_unit;
|
||||||
temp_context->call_env = context->call_env;
|
temp_context->call_env = context->call_env;
|
||||||
temp_context->current_macro = context->current_macro;
|
temp_context->current_macro = context->current_macro;
|
||||||
|
temp_context->is_temp = true;
|
||||||
return temp_context;
|
return temp_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -343,7 +343,7 @@ static inline void* expand_(void *vec, size_t element_size)
|
|||||||
#define CONCAT(a, b) CONCAT_INNER(a, b)
|
#define CONCAT(a, b) CONCAT_INNER(a, b)
|
||||||
|
|
||||||
#define FOREACH(type__, name__, vec__) \
|
#define FOREACH(type__, name__, vec__) \
|
||||||
type__* CONCAT(foreach_vec_, __LINE__) = (vec__); type__* CONCAT(foreach_vecend_, __LINE__) = CONCAT(foreach_vec_, __LINE__) + vec_size(CONCAT(foreach_vec_, __LINE__)); \
|
type__* CONCAT(foreach_vec_, __LINE__) = (vec__); type__* CONCAT(foreach_vecend_, __LINE__) = CONCAT(foreach_vec_, __LINE__) ? CONCAT(foreach_vec_, __LINE__) + vec_size(CONCAT(foreach_vec_, __LINE__)) : NULL; \
|
||||||
type__* CONCAT(foreach_it_, __LINE__) = CONCAT(foreach_vec_, __LINE__); \
|
type__* CONCAT(foreach_it_, __LINE__) = CONCAT(foreach_vec_, __LINE__); \
|
||||||
for (type__ name__ ; CONCAT(foreach_it_, __LINE__) < CONCAT(foreach_vecend_, __LINE__) ? (name__ = *CONCAT(foreach_it_, __LINE__), true) : false; CONCAT(foreach_it_, __LINE__)++)
|
for (type__ name__ ; CONCAT(foreach_it_, __LINE__) < CONCAT(foreach_vecend_, __LINE__) ? (name__ = *CONCAT(foreach_it_, __LINE__), true) : false; CONCAT(foreach_it_, __LINE__)++)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user