summaryrefslogtreecommitdiff
path: root/src/parser/parser_type.c
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-23 19:05:10 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-23 19:05:10 +0000
commit1991cb62d26b954e54cf13c2d765fb3a0bbaa3ca (patch)
treed183776b150690beb2ee45c1ace4e67ab5a29adc /src/parser/parser_type.c
parenta3ee8766e0fc9cb5c96fd9d38d5b0af7b02e01ff (diff)
Fix for #87
Diffstat (limited to 'src/parser/parser_type.c')
-rw-r--r--src/parser/parser_type.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/parser/parser_type.c b/src/parser/parser_type.c
index b11bedb..24e9f69 100644
--- a/src/parser/parser_type.c
+++ b/src/parser/parser_type.c
@@ -713,11 +713,20 @@ Type *parse_type_base(ParserContext *ctx, Lexer *l)
Type *parse_type_formal(ParserContext *ctx, Lexer *l)
{
int is_restrict = 0;
- if (lexer_peek(l).type == TOK_IDENT && lexer_peek(l).len == 8 &&
- strncmp(lexer_peek(l).start, "restrict", 8) == 0)
+ int is_const = 0;
+
+ if (lexer_peek(l).type == TOK_IDENT)
{
- lexer_next(l); // eat restrict
- is_restrict = 1;
+ if (lexer_peek(l).len == 8 && strncmp(lexer_peek(l).start, "restrict", 8) == 0)
+ {
+ lexer_next(l); // eat restrict
+ is_restrict = 1;
+ }
+ else if (lexer_peek(l).len == 5 && strncmp(lexer_peek(l).start, "const", 5) == 0)
+ {
+ lexer_next(l); // eat const
+ is_const = 1;
+ }
}
// Example: fn(int, int) -> int
@@ -829,6 +838,10 @@ Type *parse_type_formal(ParserContext *ctx, Lexer *l)
{
t->is_restrict = 1;
}
+ if (is_const)
+ {
+ t->is_const = 1;
+ }
return t;
}