public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-3709] c++: more dummy non_constant_p arg avoidance
@ 2023-09-05 14:25 Patrick Palka
0 siblings, 0 replies; only message in thread
From: Patrick Palka @ 2023-09-05 14:25 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:9922bfa59c6bd881c997cf9a0d070fd62f2940c9
commit r14-3709-g9922bfa59c6bd881c997cf9a0d070fd62f2940c9
Author: Patrick Palka <ppalka@redhat.com>
Date: Tue Sep 5 10:20:51 2023 -0400
c++: more dummy non_constant_p arg avoidance
As a follow-up to Marek's r14-3088-ga263152643bbec, this patch makes
us avoid passing an effectively dummy non_constant_p argument in two
more spots in the parser so that we further avoid unnecessary
constantness checks from cp_parser_constant_expression.
gcc/cp/ChangeLog:
* parser.cc (cp_parser_parenthesized_expression_list_elt): Pass
nullptr as non_constant_p to cp_parser_braced_list if our
non_constant_p is null.
(cp_parser_initializer_list): Likewise to
cp_parser_initializer_clause. Avoid inspecting
clause_non_constant_p if it's uninitialized.
Diff:
---
gcc/cp/parser.cc | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 7811d582b072..ed0675c95992 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -8160,7 +8160,10 @@ cp_parser_parenthesized_expression_list_elt (cp_parser *parser, bool cast_p,
/* A braced-init-list. */
cp_lexer_set_source_position (parser->lexer);
maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
- expr = cp_parser_braced_list (parser, &expr_non_constant_p);
+ expr = cp_parser_braced_list (parser,
+ (non_constant_p != nullptr
+ ? &expr_non_constant_p
+ : nullptr));
if (non_constant_p && expr_non_constant_p)
*non_constant_p = true;
}
@@ -25986,9 +25989,11 @@ cp_parser_initializer_list (cp_parser* parser, bool* non_constant_p,
/* Parse the initializer. */
initializer = cp_parser_initializer_clause (parser,
- &clause_non_constant_p);
+ (non_constant_p != nullptr
+ ? &clause_non_constant_p
+ : nullptr));
/* If any clause is non-constant, so is the entire initializer. */
- if (clause_non_constant_p && non_constant_p)
+ if (non_constant_p && clause_non_constant_p)
*non_constant_p = true;
if (TREE_CODE (initializer) == CONSTRUCTOR)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-09-05 14:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-05 14:25 [gcc r14-3709] c++: more dummy non_constant_p arg avoidance Patrick Palka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).