aboutsummaryrefslogtreecommitdiff
path: root/src/stage1/parser.cpp
diff options
context:
space:
mode:
authorLoris Cro <kappaloris@gmail.com>2022-08-16 16:52:26 +0200
committerGitHub <noreply@github.com>2022-08-16 16:52:26 +0200
commit7f7d58ee895d0e29850ed1823ba91e672edc03a6 (patch)
tree7bd7515a24e5eafa8c4a95332908e6e5e41ffa47 /src/stage1/parser.cpp
parent5929da37a117dfe67983155b39d4ee39e11f7ebc (diff)
parentb3922289be1ffaf194b55face332892280981356 (diff)
downloadzig-7f7d58ee895d0e29850ed1823ba91e672edc03a6.tar.gz
zig-7f7d58ee895d0e29850ed1823ba91e672edc03a6.zip
Merge branch 'master' into autodoc-links
Diffstat (limited to 'src/stage1/parser.cpp')
-rw-r--r--src/stage1/parser.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/stage1/parser.cpp b/src/stage1/parser.cpp
index fdc0777aff..bd778484cb 100644
--- a/src/stage1/parser.cpp
+++ b/src/stage1/parser.cpp
@@ -2902,16 +2902,25 @@ static AstNode *ast_parse_container_decl_auto(ParseContext *pc) {
}
// ContainerDeclType
-// <- KEYWORD_struct
+// <- KEYWORD_struct (LPAREN Expr RPAREN)?
// / KEYWORD_enum (LPAREN Expr RPAREN)?
// / KEYWORD_union (LPAREN (KEYWORD_enum (LPAREN Expr RPAREN)? / Expr) RPAREN)?
// / KEYWORD_opaque
static AstNode *ast_parse_container_decl_type(ParseContext *pc) {
TokenIndex first = eat_token_if(pc, TokenIdKeywordStruct);
if (first != 0) {
+ bool explicit_backing_int = false;
+ if (eat_token_if(pc, TokenIdLParen) != 0) {
+ explicit_backing_int = true;
+ ast_expect(pc, ast_parse_expr);
+ expect_token(pc, TokenIdRParen);
+ }
AstNode *res = ast_create_node(pc, NodeTypeContainerDecl, first);
res->data.container_decl.init_arg_expr = nullptr;
res->data.container_decl.kind = ContainerKindStruct;
+ // We want this to be an error in semantic analysis not parsing to make sharing
+ // the test suite between stage1 and self hosted easier.
+ res->data.container_decl.unsupported_explicit_backing_int = explicit_backing_int;
return res;
}