Skip to content

Commit 760f133

Browse files
author
thradams
committed
refactoring
1 parent 104a757 commit 760f133

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

src/parser.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3563,28 +3563,28 @@ struct static_assert_declaration* static_assert_declaration(struct parser_ctx* c
35633563
parser_match_tk(ctx, TK_KEYWORD__STATIC_ASSERT, error);
35643564
parser_match_tk(ctx, '(', error);
35653565
struct expression_ctx ectx = { .bConstantExpressionRequired = true };
3566-
p_static_assert_declaration->p_conditional_expression = constant_expression(ctx, error, &ectx);
3566+
p_static_assert_declaration->constant_expression = constant_expression(ctx, error, &ectx);
35673567

35683568
if (error->code != 0)
35693569
throw;
35703570

35713571
if (ctx->current->type == ',')
35723572
{
35733573
parser_match(ctx);
3574-
p_static_assert_declaration->text_opt = ctx->current;
3574+
p_static_assert_declaration->string_literal_opt = ctx->current;
35753575
parser_match_tk(ctx, TK_STRING_LITERAL, error);
35763576
}
35773577

35783578
parser_match_tk(ctx, ')', error);
35793579
p_static_assert_declaration->last_token = ctx->current;
35803580
parser_match_tk(ctx, ';', error);
35813581

3582-
if (p_static_assert_declaration->p_conditional_expression->constant_value == 0)
3582+
if (p_static_assert_declaration->constant_expression->constant_value == 0)
35833583
{
3584-
if (p_static_assert_declaration->text_opt)
3584+
if (p_static_assert_declaration->string_literal_opt)
35853585
{
35863586
parser_seterror_with_token(ctx, position, "_Static_assert failed %s\n",
3587-
p_static_assert_declaration->text_opt->lexeme);
3587+
p_static_assert_declaration->string_literal_opt->lexeme);
35883588
}
35893589
else
35903590
{

src/parser.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,16 @@ struct declaration_specifiers* declaration_specifiers(struct parser_ctx* ctx, st
152152

153153
struct static_assert_declaration
154154
{
155+
/*
156+
static_assert-declaration:
157+
"static_assert" ( constant-expression , string-literal ) ;
158+
"static_assert" ( constant-expression ) ;
159+
*/
160+
155161
struct token* first_token;
156162
struct token* last_token;
157-
struct expression* p_conditional_expression;
158-
struct token* text_opt;
163+
struct expression* constant_expression;
164+
struct token* string_literal_opt;
159165
};
160166
struct static_assert_declaration* static_assert_declaration(struct parser_ctx* ctx, struct error* error);
161167

src/visit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ static void visit_block_item_list(struct visit_ctx* ctx, struct block_item_list*
10421042

10431043
static void visit_static_assert_declaration(struct visit_ctx* ctx, struct static_assert_declaration* p_static_assert_declaration, struct error* error)
10441044
{
1045-
visit_expression(ctx, p_static_assert_declaration->p_conditional_expression, error);
1045+
visit_expression(ctx, p_static_assert_declaration->constant_expression, error);
10461046

10471047
if (ctx->target < LANGUAGE_C11)
10481048
{
@@ -1062,7 +1062,7 @@ static void visit_static_assert_declaration(struct visit_ctx* ctx, struct static
10621062
}
10631063
else if (ctx->target == LANGUAGE_C11)
10641064
{
1065-
if (p_static_assert_declaration->text_opt == NULL)
1065+
if (p_static_assert_declaration->string_literal_opt == NULL)
10661066
{
10671067
struct token* rp = previous_parser_token(p_static_assert_declaration->last_token);
10681068
rp = previous_parser_token(rp);

0 commit comments

Comments
 (0)