Allow for NO_DEFAULT_STRUCT_VALUES

(will decide later if I want them or not)
This commit is contained in:
gingerBill
2018-05-13 21:09:49 +01:00
parent 9f1dda701d
commit 780b81a59f
4 changed files with 13 additions and 68 deletions
+1 -1
View File
@@ -684,7 +684,7 @@ Type *ir_type(irValue *value) {
bool ir_type_has_default_values(Type *t) {
#if 1
#if !defined(NO_DEFAULT_STRUCT_VALUES)
switch (t->kind) {
case Type_Named:
return ir_type_has_default_values(t->Named.base);
+1
View File
@@ -1,5 +1,6 @@
// #define NO_ARRAY_BOUNDS_CHECK
#define NO_POINTER_ARITHMETIC
// #define NO_DEFAULT_STRUCT_VALUES
#include "common.cpp"
#include "timings.cpp"
+6 -4
View File
@@ -2959,10 +2959,12 @@ AstNode *parse_field_list(AstFile *f, isize *name_count_, u32 allowed_flags, Tok
syntax_error(f->curr_token, "Default parameters can only be applied to single values");
}
// if (allowed_flags == FieldFlag_Struct && default_value != nullptr) {
// syntax_error(default_value, "Default parameters are not allowed for structs");
// default_value = nullptr;
// }
#if defined(NO_DEFAULT_STRUCT_VALUES)
if (allowed_flags == FieldFlag_Struct && default_value != nullptr) {
syntax_error(default_value, "Default parameters are not allowed for structs");
default_value = nullptr;
}
#endif
if (type != nullptr && type->kind == AstNode_Ellipsis) {
if (seen_ellipsis) syntax_error(type, "Extra variadic parameter after ellipsis");