summaryrefslogtreecommitdiff
path: root/05
diff options
context:
space:
mode:
Diffstat (limited to '05')
-rw-r--r--05/main.c1
-rw-r--r--05/parse.b12
2 files changed, 8 insertions, 5 deletions
diff --git a/05/main.c b/05/main.c
index e16367b..1c5fb4f 100644
--- a/05/main.c
+++ b/05/main.c
@@ -38,6 +38,7 @@ typedef struct {
int a = -138;
double f = 0;
+void *p = 0;
int j = 3+7<<5, k = 123;
/*
diff --git a/05/parse.b b/05/parse.b
index f44f582..4ab47a8 100644
--- a/05/parse.b
+++ b/05/parse.b
@@ -271,9 +271,9 @@ function parse_constant_initializer
:found_init_end
if *1token == SYMBOL_LBRACE goto parse_braced_initializer
-
+ if *1token == TOKEN_STRING_LITERAL goto parse_string_literal_initializer
p = types + type
- if *1p > TYPE_DOUBLE goto expression_initializer_for_nonscalar_type
+ if *1p > TYPE_POINTER goto expression_initializer_for_nonscalar_type
global 8000 dat_const_initializer
expr = &dat_const_initializer
@@ -307,13 +307,15 @@ function parse_constant_initializer
return
- :init_floating_check
+ :init_floating_check ; also checks pointer types (e.g. don't do static void *x = 1;)
if value != 0 goto floating_initializer_other_than_0
goto init_good
:parse_braced_initializer
byte 0xcc ; @TODO
-
+ :parse_string_literal_initializer
+ byte 0xcc ; @TODO
+
:find_init_end_eof
token_error(token, .str_find_init_end_eof)
:str_find_init_end_eof
@@ -332,7 +334,7 @@ function parse_constant_initializer
:floating_initializer_other_than_0
token_error(token, .str_floating_initializer_other_than_0)
:str_floating_initializer_other_than_0
- string Only 0 is supported as a floating-point initializer.
+ string Only 0 is supported as a floating-point/pointer initializer.
byte 0
; *p_token should be pointing to a {, this will advance it to point to the matching }
function token_skip_to_matching_rbrace