aboutsummaryrefslogtreecommitdiff
path: root/src/types.cpp
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-06-11 20:52:54 +0100
committerGinger Bill <bill@gingerbill.org>2017-06-11 20:52:54 +0100
commitc2c935ba818167a7056da5ac61687ecd2d97cc59 (patch)
treee0a345e33aebe9811cfdeb3a65b63db13777ed72 /src/types.cpp
parent2d73c8868b62dd3555409ee4522205d670ddeb42 (diff)
Fix trailing default argument checking
Diffstat (limited to 'src/types.cpp')
-rw-r--r--src/types.cpp39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/types.cpp b/src/types.cpp
index f8b6eba16..a659d54f2 100644
--- a/src/types.cpp
+++ b/src/types.cpp
@@ -1100,24 +1100,6 @@ bool are_types_identical(Type *x, Type *y) {
return false;
}
-
-Type *default_type(Type *type) {
- if (type == NULL) {
- return t_invalid;
- }
- if (type->kind == Type_Basic) {
- switch (type->Basic.kind) {
- case Basic_UntypedBool: return t_bool;
- case Basic_UntypedInteger: return t_int;
- case Basic_UntypedFloat: return t_f64;
- case Basic_UntypedComplex: return t_complex128;
- case Basic_UntypedString: return t_string;
- case Basic_UntypedRune: return t_rune;
- }
- }
- return type;
-}
-
Type *default_bit_field_value_type(Type *type) {
if (type == NULL) {
return t_invalid;
@@ -1138,6 +1120,27 @@ Type *default_bit_field_value_type(Type *type) {
return type;
}
+Type *default_type(Type *type) {
+ if (type == NULL) {
+ return t_invalid;
+ }
+ if (type->kind == Type_Basic) {
+ switch (type->Basic.kind) {
+ case Basic_UntypedBool: return t_bool;
+ case Basic_UntypedInteger: return t_int;
+ case Basic_UntypedFloat: return t_f64;
+ case Basic_UntypedComplex: return t_complex128;
+ case Basic_UntypedString: return t_string;
+ case Basic_UntypedRune: return t_rune;
+ }
+ }
+ if (type->kind == Type_BitFieldValue) {
+ return default_bit_field_value_type(type);
+ }
+ return type;
+}
+
+
// NOTE(bill): Valid Compile time execution #run type
bool is_type_cte_safe(Type *type) {
type = default_type(base_type(type));