From 3d72a326573225ed857fbe7aa8d4d510750976e9 Mon Sep 17 00:00:00 2001 From: Lydia Duncan Date: Mon, 18 Nov 2024 14:54:00 -0800 Subject: [PATCH 1/4] Rename `parenth_location` to `paren_location` in the language server/etc. I at first thought this was a typo for "parent", but Jade said it was short for parentheses. If my memory serves, we typically shorten that to `paren` instead, so rename the method and its uses to reflect that. A `make test-chpl-language-server` behaved the same as on nightly ---- Signed-off-by: Lydia Duncan --- tools/chapel-py/src/method-tables/uast-methods.h | 2 +- tools/chpl-language-server/src/symbol_signature.py | 4 ++-- tools/chplcheck/src/rules.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/chapel-py/src/method-tables/uast-methods.h b/tools/chapel-py/src/method-tables/uast-methods.h index 507a3cd2a8b3..12f5c1bfa43b 100644 --- a/tools/chapel-py/src/method-tables/uast-methods.h +++ b/tools/chapel-py/src/method-tables/uast-methods.h @@ -108,7 +108,7 @@ CLASS_BEGIN(AstNode) std::optional, auto loc = chpl::parsing::locateCurlyBracesWithAst(context, node); return getValidLocation(loc)) - PLAIN_GETTER(AstNode, parenth_location, "Get the Location of the parentheses of this AstNode node", + PLAIN_GETTER(AstNode, paren_location, "Get the Location of the parentheses of this AstNode node", std::optional, auto loc = chpl::parsing::locateExprParenthWithAst(context, node); return getValidLocation(loc)) diff --git a/tools/chpl-language-server/src/symbol_signature.py b/tools/chpl-language-server/src/symbol_signature.py index a3c0d1572a36..5e300fc0e15d 100644 --- a/tools/chpl-language-server/src/symbol_signature.py +++ b/tools/chpl-language-server/src/symbol_signature.py @@ -357,7 +357,7 @@ def _fncall_to_string(call: chapel.FnCall) -> List[Component]: comps.extend(_wrap_in(call_args, (openbr, closebr))) - comps = _wrap_in(comps, ("(", ")")) if call.parenth_location() else comps + comps = _wrap_in(comps, ("(", ")")) if call.paren_location() else comps return comps @@ -418,7 +418,7 @@ def is_postfix(op: str) -> bool: comps.extend(_node_to_string(call.actual(0))) comps.append(_wrap_str(bop_to_string(call.op()))) comps.extend(_node_to_string(call.actual(1))) - comps = _wrap_in(comps, ("(", ")")) if call.parenth_location() else comps + comps = _wrap_in(comps, ("(", ")")) if call.paren_location() else comps return comps diff --git a/tools/chplcheck/src/rules.py b/tools/chplcheck/src/rules.py index c7192002098d..b6e66f2748d0 100644 --- a/tools/chplcheck/src/rules.py +++ b/tools/chplcheck/src/rules.py @@ -292,7 +292,7 @@ def ControlFlowParentheses( return True # No parentheses to speak of - paren_loc = subject.parenth_location() + paren_loc = subject.paren_location() if paren_loc is None: return True @@ -305,7 +305,7 @@ def RemoveControlFlowParentheses(context: Context, result: BasicRuleResult): # Since we're here, these should already be non-None. subject = result.data assert subject - paren_loc = subject.parenth_location() + paren_loc = subject.paren_location() assert paren_loc # If parentheses span multiple lines, don't provide a fixit, From 40bd2ed2d5c5df512f93cac3753824c5a7cda62a Mon Sep 17 00:00:00 2001 From: Lydia Duncan Date: Wed, 20 Nov 2024 09:39:08 -0800 Subject: [PATCH 2/4] Also update dyno uses of `ExprParenth` to `ExprParen` Does not include the generated parser changes, I'm putting that in a separate commit for cleanliness ---- Signed-off-by: Lydia Duncan --- frontend/include/chpl/uast/all-location-maps.h | 2 +- frontend/lib/parsing/ParserContextImpl.h | 10 +++++----- frontend/lib/parsing/chpl.ypp | 12 ++++++------ frontend/lib/uast/post-parse-checks.cpp | 2 +- tools/chapel-py/src/method-tables/uast-methods.h | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/frontend/include/chpl/uast/all-location-maps.h b/frontend/include/chpl/uast/all-location-maps.h index a5144f3e19be..0537c6a08c1a 100644 --- a/frontend/include/chpl/uast/all-location-maps.h +++ b/frontend/include/chpl/uast/all-location-maps.h @@ -28,7 +28,7 @@ LOCATION_MAP(NamedDecl, DeclName) LOCATION_MAP(Loop, LoopHeader) LOCATION_MAP(AstNode, BlockHeader) LOCATION_MAP(NamedDecl, DeclHeader) -LOCATION_MAP(AstNode, ExprParenth) +LOCATION_MAP(AstNode, ExprParen) LOCATION_MAP(AstNode, CurlyBraces) // LOCATION_MAP(AstNode, NamedActual) // LOCATION_MAP(AstNode, AttributeNamedActual) diff --git a/frontend/lib/parsing/ParserContextImpl.h b/frontend/lib/parsing/ParserContextImpl.h index b89d7cb459e5..384b5360c4aa 100644 --- a/frontend/lib/parsing/ParserContextImpl.h +++ b/frontend/lib/parsing/ParserContextImpl.h @@ -1865,7 +1865,7 @@ owned ParserContext::buildLoopIndexDecl(YYLTYPE location, /*typeExpression*/ nullptr, /*initExpression*/ nullptr); builder->noteDeclNameLocation(var.get(), convLoc); - builder->copyExprParenthLocation(e, var.get()); + builder->copyExprParenLocation(e, var.get()); builder->deleteAllLocations(e); // Delete the location of 'e' because it's about to be deallocated; // we don't want a new allocation of an AST node to have the same pointer @@ -1895,8 +1895,8 @@ owned ParserContext::buildLoopIndexDecl(YYLTYPE location, std::move(elements), /*typeExpression*/ nullptr, /*initExpression*/ nullptr); - builder->copyExprParenthLocation(e, td.get()); - builder->deleteExprParenthLocation(e); + builder->copyExprParenLocation(e, td.get()); + builder->deleteExprParenLocation(e); // See the comment above for why we delete the location of 'e'. return td; } else { @@ -1988,8 +1988,8 @@ FnCall* ParserContext::wrapCalledExpressionInNew(YYLTYPE location, auto newExpr = New::build(builder, convertLocation(location), toOwned(calledExpr), management); - builder->copyExprParenthLocation(fnCall, newExpr.get()); - builder->deleteExprParenthLocation(fnCall); + builder->copyExprParenLocation(fnCall, newExpr.get()); + builder->deleteExprParenLocation(fnCall); child = std::move(newExpr); // Extend the location of the call to the left and patch the location. diff --git a/frontend/lib/parsing/chpl.ypp b/frontend/lib/parsing/chpl.ypp index 786a2a83dad4..e745b7a0bcd1 100644 --- a/frontend/lib/parsing/chpl.ypp +++ b/frontend/lib/parsing/chpl.ypp @@ -2559,7 +2559,7 @@ fn_decl_receiver_expr: ident_expr | TLP expr TRP { - BUILDER->tryNoteExprParenthLocation($2, LOC(@$)); + BUILDER->tryNoteExprParenLocation($2, LOC(@$)); $$ = $2; } ; @@ -3346,7 +3346,7 @@ new_expr: see if we can remove them. */ | TNEW TOWNED TLP expr TRP TLP opt_actual_ls TRP %prec TNOELSE { - BUILDER->tryNoteExprParenthLocation($4, LOC2(@3, @5)); + BUILDER->tryNoteExprParenLocation($4, LOC2(@3, @5)); AstList actuals; std::vector actualNames; context->consumeNamedActuals($7, actuals, actualNames); @@ -3359,7 +3359,7 @@ new_expr: } | TNEW TSHARED TLP expr TRP TLP opt_actual_ls TRP %prec TNOELSE { - BUILDER->tryNoteExprParenthLocation($4, LOC2(@3, @5)); + BUILDER->tryNoteExprParenLocation($4, LOC2(@3, @5)); AstList actuals; std::vector actualNames; context->consumeNamedActuals($7, actuals, actualNames); @@ -3372,7 +3372,7 @@ new_expr: } | TNEW TOWNED TLP expr TRP TLP opt_actual_ls TRP TQUESTION { - BUILDER->tryNoteExprParenthLocation($4, LOC2(@3, @5)); + BUILDER->tryNoteExprParenLocation($4, LOC2(@3, @5)); AstList actuals; std::vector actualNames; context->consumeNamedActuals($7, actuals, actualNames); @@ -3386,7 +3386,7 @@ new_expr: } | TNEW TSHARED TLP expr TRP TLP opt_actual_ls TRP TQUESTION { - BUILDER->tryNoteExprParenthLocation($4, LOC2(@3, @5)); + BUILDER->tryNoteExprParenLocation($4, LOC2(@3, @5)); AstList actuals; std::vector actualNames; context->consumeNamedActuals($7, actuals, actualNames); @@ -3596,7 +3596,7 @@ parenthesized_expr: TLP opt_try_expr TRP { // Use 'tryNote' here in case an expression like ((x)) comes along. - BUILDER->tryNoteExprParenthLocation($2, LOC(@$)); + BUILDER->tryNoteExprParenLocation($2, LOC(@$)); $$ = $2; } | TLP tuple_component TCOMMA TRP diff --git a/frontend/lib/uast/post-parse-checks.cpp b/frontend/lib/uast/post-parse-checks.cpp index b611672bba12..fb13e0d514c2 100644 --- a/frontend/lib/uast/post-parse-checks.cpp +++ b/frontend/lib/uast/post-parse-checks.cpp @@ -798,7 +798,7 @@ static void collectEqualPrecedenceOpsWithoutParens(Context* context, if (auto childOp = child->toOpCall()) { if (childOp->numActuals() == 2 && binOpPrecedence(childOp->op()) == prec) { // The child only counts as a 'problem' if it's not parenthesized. - if (parsing::locateExprParenthWithAst(context, childOp).line() == -1) { + if (parsing::locateExprParenWithAst(context, childOp).line() == -1) { collectEqualPrecedenceOpsWithoutParens(context, childOp, prec, ops, operands); return; } diff --git a/tools/chapel-py/src/method-tables/uast-methods.h b/tools/chapel-py/src/method-tables/uast-methods.h index 12f5c1bfa43b..172975e01505 100644 --- a/tools/chapel-py/src/method-tables/uast-methods.h +++ b/tools/chapel-py/src/method-tables/uast-methods.h @@ -110,7 +110,7 @@ CLASS_BEGIN(AstNode) return getValidLocation(loc)) PLAIN_GETTER(AstNode, paren_location, "Get the Location of the parentheses of this AstNode node", std::optional, - auto loc = chpl::parsing::locateExprParenthWithAst(context, node); + auto loc = chpl::parsing::locateExprParenWithAst(context, node); return getValidLocation(loc)) CLASS_END(AstNode) From 97524168e0211e92bce686e5467cefcac6f5f154 Mon Sep 17 00:00:00 2001 From: Lydia Duncan Date: Wed, 20 Nov 2024 09:43:32 -0800 Subject: [PATCH 3/4] Update generated parser files for the `ExprParenth` rename ---- Signed-off-by: Lydia Duncan --- frontend/lib/parsing/bison-chpl-lib.cpp | 12 ++++---- frontend/lib/parsing/flex-chpl-lib.cpp | 39 +++++++++++++------------ frontend/lib/parsing/flex-chpl-lib.h | 9 +++--- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/frontend/lib/parsing/bison-chpl-lib.cpp b/frontend/lib/parsing/bison-chpl-lib.cpp index a2b72ec092bb..c1a0c319329d 100644 --- a/frontend/lib/parsing/bison-chpl-lib.cpp +++ b/frontend/lib/parsing/bison-chpl-lib.cpp @@ -8524,7 +8524,7 @@ YYLTYPE yylloc = yyloc_default; case 363: /* fn_decl_receiver_expr: TLP expr TRP */ #line 2561 "chpl.ypp" { - BUILDER->tryNoteExprParenthLocation((yyvsp[-1].expr), LOC((yyloc))); + BUILDER->tryNoteExprParenLocation((yyvsp[-1].expr), LOC((yyloc))); (yyval.expr) = (yyvsp[-1].expr); } #line 8531 "bison-chpl-lib.cpp" @@ -9940,7 +9940,7 @@ YYLTYPE yylloc = yyloc_default; case 619: /* new_expr: TNEW TOWNED TLP expr TRP TLP opt_actual_ls TRP */ #line 3348 "chpl.ypp" { - BUILDER->tryNoteExprParenthLocation((yyvsp[-4].expr), LOC2((yylsp[-5]), (yylsp[-3]))); + BUILDER->tryNoteExprParenLocation((yyvsp[-4].expr), LOC2((yylsp[-5]), (yylsp[-3]))); AstList actuals; std::vector actualNames; context->consumeNamedActuals((yyvsp[-1].maybeNamedActualList), actuals, actualNames); @@ -9957,7 +9957,7 @@ YYLTYPE yylloc = yyloc_default; case 620: /* new_expr: TNEW TSHARED TLP expr TRP TLP opt_actual_ls TRP */ #line 3361 "chpl.ypp" { - BUILDER->tryNoteExprParenthLocation((yyvsp[-4].expr), LOC2((yylsp[-5]), (yylsp[-3]))); + BUILDER->tryNoteExprParenLocation((yyvsp[-4].expr), LOC2((yylsp[-5]), (yylsp[-3]))); AstList actuals; std::vector actualNames; context->consumeNamedActuals((yyvsp[-1].maybeNamedActualList), actuals, actualNames); @@ -9974,7 +9974,7 @@ YYLTYPE yylloc = yyloc_default; case 621: /* new_expr: TNEW TOWNED TLP expr TRP TLP opt_actual_ls TRP TQUESTION */ #line 3374 "chpl.ypp" { - BUILDER->tryNoteExprParenthLocation((yyvsp[-5].expr), LOC2((yylsp[-6]), (yylsp[-4]))); + BUILDER->tryNoteExprParenLocation((yyvsp[-5].expr), LOC2((yylsp[-6]), (yylsp[-4]))); AstList actuals; std::vector actualNames; context->consumeNamedActuals((yyvsp[-2].maybeNamedActualList), actuals, actualNames); @@ -9992,7 +9992,7 @@ YYLTYPE yylloc = yyloc_default; case 622: /* new_expr: TNEW TSHARED TLP expr TRP TLP opt_actual_ls TRP TQUESTION */ #line 3388 "chpl.ypp" { - BUILDER->tryNoteExprParenthLocation((yyvsp[-5].expr), LOC2((yylsp[-6]), (yylsp[-4]))); + BUILDER->tryNoteExprParenLocation((yyvsp[-5].expr), LOC2((yylsp[-6]), (yylsp[-4]))); AstList actuals; std::vector actualNames; context->consumeNamedActuals((yyvsp[-2].maybeNamedActualList), actuals, actualNames); @@ -10237,7 +10237,7 @@ YYLTYPE yylloc = yyloc_default; #line 3597 "chpl.ypp" { // Use 'tryNote' here in case an expression like ((x)) comes along. - BUILDER->tryNoteExprParenthLocation((yyvsp[-1].expr), LOC((yyloc))); + BUILDER->tryNoteExprParenLocation((yyvsp[-1].expr), LOC((yyloc))); (yyval.expr) = (yyvsp[-1].expr); } #line 10244 "bison-chpl-lib.cpp" diff --git a/frontend/lib/parsing/flex-chpl-lib.cpp b/frontend/lib/parsing/flex-chpl-lib.cpp index c8a7fe5217de..2cd4f7922519 100644 --- a/frontend/lib/parsing/flex-chpl-lib.cpp +++ b/frontend/lib/parsing/flex-chpl-lib.cpp @@ -281,6 +281,7 @@ typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; @@ -445,7 +446,7 @@ struct yy_buffer_state /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - int yy_n_chars; + yy_size_t yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -522,7 +523,7 @@ static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner ); void *yyalloc ( yy_size_t , yyscan_t yyscanner ); void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); @@ -569,7 +570,7 @@ static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); */ #define YY_DO_BEFORE_ACTION \ yyg->yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; @@ -1079,10 +1080,10 @@ static void processInvalidToken(yyscan_t scanner); static bool yy_has_state(yyscan_t scanner); } -#line 1082 "flex-chpl-lib.cpp" +#line 1083 "flex-chpl-lib.cpp" /* hex float literals, have decimal exponents indicating the power of 2 */ -#line 1085 "flex-chpl-lib.cpp" +#line 1086 "flex-chpl-lib.cpp" #define INITIAL 0 #define externmode 1 @@ -1110,8 +1111,8 @@ struct yyguts_t size_t yy_buffer_stack_max; /**< capacity of stack. */ YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ char yy_hold_char; - int yy_n_chars; - int yyleng_r; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; char *yy_c_buf_p; int yy_init; int yy_start; @@ -1168,7 +1169,7 @@ FILE *yyget_out ( yyscan_t yyscanner ); void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - int yyget_leng ( yyscan_t yyscanner ); + yy_size_t yyget_leng ( yyscan_t yyscanner ); char *yyget_text ( yyscan_t yyscanner ); @@ -1253,7 +1254,7 @@ static int input ( yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - int n; \ + yy_size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -1372,7 +1373,7 @@ YY_DECL #line 114 "chpl.lex" -#line 1375 "flex-chpl-lib.cpp" +#line 1376 "flex-chpl-lib.cpp" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -2377,7 +2378,7 @@ YY_RULE_SETUP #line 330 "chpl.lex" ECHO; YY_BREAK -#line 2380 "flex-chpl-lib.cpp" +#line 2381 "flex-chpl-lib.cpp" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(externmode): yyterminate(); @@ -2566,7 +2567,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else { - int num_to_read = + yy_size_t num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) @@ -2580,7 +2581,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) if ( b->yy_is_our_buffer ) { - int new_size = b->yy_buf_size * 2; + yy_size_t new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -2638,7 +2639,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ - int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) @@ -2745,7 +2746,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else { /* need more input */ - int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; ++yyg->yy_c_buf_p; switch ( yy_get_next_buffer( yyscanner ) ) @@ -3123,12 +3124,12 @@ YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner) +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) { YY_BUFFER_STATE b; char *buf; yy_size_t n; - int i; + yy_size_t i; /* Get memory for full buffer, including space for trailing EOB's. */ n = (yy_size_t) (_yybytes_len + 2); @@ -3213,7 +3214,7 @@ static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) do \ { \ /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ + yy_size_t yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ yytext[yyleng] = yyg->yy_hold_char; \ yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ @@ -3281,7 +3282,7 @@ FILE *yyget_out (yyscan_t yyscanner) /** Get the length of the current token. * @param yyscanner The scanner object. */ -int yyget_leng (yyscan_t yyscanner) +yy_size_t yyget_leng (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyleng; diff --git a/frontend/lib/parsing/flex-chpl-lib.h b/frontend/lib/parsing/flex-chpl-lib.h index f6fbf73d4e42..a3513a78e7b2 100644 --- a/frontend/lib/parsing/flex-chpl-lib.h +++ b/frontend/lib/parsing/flex-chpl-lib.h @@ -285,6 +285,7 @@ typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; @@ -398,7 +399,7 @@ struct yy_buffer_state /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - int yy_n_chars; + yy_size_t yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -442,7 +443,7 @@ void yypop_buffer_state ( yyscan_t yyscanner ); YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner ); void *yyalloc ( yy_size_t , yyscan_t yyscanner ); void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); @@ -496,7 +497,7 @@ FILE *yyget_out ( yyscan_t yyscanner ); void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - int yyget_leng ( yyscan_t yyscanner ); + yy_size_t yyget_leng ( yyscan_t yyscanner ); char *yyget_text ( yyscan_t yyscanner ); @@ -730,6 +731,6 @@ extern int yylex \ #line 330 "chpl.lex" -#line 733 "flex-chpl-lib.h" +#line 734 "flex-chpl-lib.h" #undef yychpl_IN_HEADER #endif /* yychpl_HEADER_H */ From 775174379261a88b462b9f6221ec0181b2c75765 Mon Sep 17 00:00:00 2001 From: Lydia Duncan Date: Wed, 20 Nov 2024 10:28:30 -0800 Subject: [PATCH 4/4] Revert the flex changes to avoid the warnings It looks like they were unnecessary anyways, but that's kinda annoying ---- Signed-off-by: Lydia Duncan --- frontend/lib/parsing/flex-chpl-lib.cpp | 39 +++++++++++++------------- frontend/lib/parsing/flex-chpl-lib.h | 9 +++--- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/frontend/lib/parsing/flex-chpl-lib.cpp b/frontend/lib/parsing/flex-chpl-lib.cpp index 2cd4f7922519..c8a7fe5217de 100644 --- a/frontend/lib/parsing/flex-chpl-lib.cpp +++ b/frontend/lib/parsing/flex-chpl-lib.cpp @@ -281,7 +281,6 @@ typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; -typedef uint64_t flex_uint64_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; @@ -446,7 +445,7 @@ struct yy_buffer_state /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - yy_size_t yy_n_chars; + int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -523,7 +522,7 @@ static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); void *yyalloc ( yy_size_t , yyscan_t yyscanner ); void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); @@ -570,7 +569,7 @@ static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); */ #define YY_DO_BEFORE_ACTION \ yyg->yytext_ptr = yy_bp; \ - yyleng = (yy_size_t) (yy_cp - yy_bp); \ + yyleng = (int) (yy_cp - yy_bp); \ yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; @@ -1080,10 +1079,10 @@ static void processInvalidToken(yyscan_t scanner); static bool yy_has_state(yyscan_t scanner); } -#line 1083 "flex-chpl-lib.cpp" +#line 1082 "flex-chpl-lib.cpp" /* hex float literals, have decimal exponents indicating the power of 2 */ -#line 1086 "flex-chpl-lib.cpp" +#line 1085 "flex-chpl-lib.cpp" #define INITIAL 0 #define externmode 1 @@ -1111,8 +1110,8 @@ struct yyguts_t size_t yy_buffer_stack_max; /**< capacity of stack. */ YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ char yy_hold_char; - yy_size_t yy_n_chars; - yy_size_t yyleng_r; + int yy_n_chars; + int yyleng_r; char *yy_c_buf_p; int yy_init; int yy_start; @@ -1169,7 +1168,7 @@ FILE *yyget_out ( yyscan_t yyscanner ); void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - yy_size_t yyget_leng ( yyscan_t yyscanner ); + int yyget_leng ( yyscan_t yyscanner ); char *yyget_text ( yyscan_t yyscanner ); @@ -1254,7 +1253,7 @@ static int input ( yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - yy_size_t n; \ + int n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -1373,7 +1372,7 @@ YY_DECL #line 114 "chpl.lex" -#line 1376 "flex-chpl-lib.cpp" +#line 1375 "flex-chpl-lib.cpp" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -2378,7 +2377,7 @@ YY_RULE_SETUP #line 330 "chpl.lex" ECHO; YY_BREAK -#line 2381 "flex-chpl-lib.cpp" +#line 2380 "flex-chpl-lib.cpp" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(externmode): yyterminate(); @@ -2567,7 +2566,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else { - yy_size_t num_to_read = + int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) @@ -2581,7 +2580,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) if ( b->yy_is_our_buffer ) { - yy_size_t new_size = b->yy_buf_size * 2; + int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -2639,7 +2638,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) @@ -2746,7 +2745,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else { /* need more input */ - yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); ++yyg->yy_c_buf_p; switch ( yy_get_next_buffer( yyscanner ) ) @@ -3124,12 +3123,12 @@ YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner) { YY_BUFFER_STATE b; char *buf; yy_size_t n; - yy_size_t i; + int i; /* Get memory for full buffer, including space for trailing EOB's. */ n = (yy_size_t) (_yybytes_len + 2); @@ -3214,7 +3213,7 @@ static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) do \ { \ /* Undo effects of setting up yytext. */ \ - yy_size_t yyless_macro_arg = (n); \ + int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ yytext[yyleng] = yyg->yy_hold_char; \ yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ @@ -3282,7 +3281,7 @@ FILE *yyget_out (yyscan_t yyscanner) /** Get the length of the current token. * @param yyscanner The scanner object. */ -yy_size_t yyget_leng (yyscan_t yyscanner) +int yyget_leng (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyleng; diff --git a/frontend/lib/parsing/flex-chpl-lib.h b/frontend/lib/parsing/flex-chpl-lib.h index a3513a78e7b2..f6fbf73d4e42 100644 --- a/frontend/lib/parsing/flex-chpl-lib.h +++ b/frontend/lib/parsing/flex-chpl-lib.h @@ -285,7 +285,6 @@ typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; -typedef uint64_t flex_uint64_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; @@ -399,7 +398,7 @@ struct yy_buffer_state /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - yy_size_t yy_n_chars; + int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -443,7 +442,7 @@ void yypop_buffer_state ( yyscan_t yyscanner ); YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); void *yyalloc ( yy_size_t , yyscan_t yyscanner ); void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); @@ -497,7 +496,7 @@ FILE *yyget_out ( yyscan_t yyscanner ); void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - yy_size_t yyget_leng ( yyscan_t yyscanner ); + int yyget_leng ( yyscan_t yyscanner ); char *yyget_text ( yyscan_t yyscanner ); @@ -731,6 +730,6 @@ extern int yylex \ #line 330 "chpl.lex" -#line 734 "flex-chpl-lib.h" +#line 733 "flex-chpl-lib.h" #undef yychpl_IN_HEADER #endif /* yychpl_HEADER_H */