public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-3274] c++: Various small fixes
@ 2021-08-31 19:54 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2021-08-31 19:54 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:9c6344c10de1c90015c68adfb880291af980b886

commit r12-3274-g9c6344c10de1c90015c68adfb880291af980b886
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Aug 25 15:10:21 2021 -0400

    c++: Various small fixes
    
    A copy-paste error, a couple of missed checks to guard undefined accesses,
    and we don't need to use type_uses_auto to extract the auto node we just
    built.
    
    gcc/cp/ChangeLog:
    
            * coroutines.cc (flatten_await_stmt): Fix copyo.
            * decl.c (reshape_init_class): Simplify.
            * module.cc (module_state::read_language): Add null check.
            * parser.c (build_range_temp): Avoid type_uses_auto.
            (cp_parser_class_specifier_1): Add null check.

Diff:
---
 gcc/cp/coroutines.cc |  2 +-
 gcc/cp/decl.c        |  3 +--
 gcc/cp/module.cc     |  2 +-
 gcc/cp/parser.c      | 15 +++++++--------
 4 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index 47c79e58db5..25269d9e51a 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -2905,7 +2905,7 @@ flatten_await_stmt (var_nest_node *n, hash_set<tree> *promoted,
 	  tree else_cl = COND_EXPR_ELSE (old_expr);
 	  if (!VOID_TYPE_P (TREE_TYPE (else_cl)))
 	    {
-	      gcc_checking_assert (TREE_CODE (then_cl) != STATEMENT_LIST);
+	      gcc_checking_assert (TREE_CODE (else_cl) != STATEMENT_LIST);
 	      else_cl
 		= build2 (init_expr ? INIT_EXPR : MODIFY_EXPR, var_type,
 			  var, else_cl);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 3414cbdc876..e981eadc6dd 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6563,8 +6563,7 @@ reshape_init_class (tree type, reshape_iter *d, bool first_initializer_p,
     continue_:
       if (base_binfo)
 	{
-	  BINFO_BASE_ITERATE (binfo, ++binfo_idx, base_binfo);
-	  if (base_binfo)
+	  if (BINFO_BASE_ITERATE (binfo, ++binfo_idx, base_binfo))
 	    field = base_binfo;
 	  else
 	    field = next_initializable_field (TYPE_FIELDS (type));
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index ccbde292c22..4b2ad6f3db8 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -17977,7 +17977,7 @@ module_state::read_language (bool outermost)
 
   function_depth++; /* Prevent unexpected GCs.  */
 
-  if (counts[MSC_entities] != entity_num)
+  if (ok && counts[MSC_entities] != entity_num)
     ok = false;
   if (ok && counts[MSC_entities]
       && !read_entities (counts[MSC_entities],
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 1e2a4b121ea..d3c31be0967 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -13474,17 +13474,15 @@ cp_parser_range_for (cp_parser *parser, tree scope, tree init, tree range_decl,
 static tree
 build_range_temp (tree range_expr)
 {
-  tree range_type, range_temp;
-
   /* Find out the type deduced by the declaration
      `auto &&__range = range_expr'.  */
-  range_type = cp_build_reference_type (make_auto (), true);
-  range_type = do_auto_deduction (range_type, range_expr,
-				  type_uses_auto (range_type));
+  tree auto_node = make_auto ();
+  tree range_type = cp_build_reference_type (auto_node, true);
+  range_type = do_auto_deduction (range_type, range_expr, auto_node);
 
   /* Create the __range variable.  */
-  range_temp = build_decl (input_location, VAR_DECL, for_range__identifier,
-			   range_type);
+  tree range_temp = build_decl (input_location, VAR_DECL,
+				for_range__identifier, range_type);
   TREE_USED (range_temp) = 1;
   DECL_ARTIFICIAL (range_temp) = 1;
 
@@ -25910,7 +25908,8 @@ cp_parser_class_specifier_1 (cp_parser* parser)
 	     so that maybe_instantiate_noexcept can tsubst the NOEXCEPT_EXPR
 	     in the pattern.  */
 	  for (tree i : DEFPARSE_INSTANTIATIONS (def_parse))
-	    DEFERRED_NOEXCEPT_PATTERN (TREE_PURPOSE (i)) = TREE_PURPOSE (spec);
+	    DEFERRED_NOEXCEPT_PATTERN (TREE_PURPOSE (i))
+	      = spec ? TREE_PURPOSE (spec) : error_mark_node;
 
 	  /* Restore the state of local_variables_forbidden_p.  */
 	  parser->local_variables_forbidden_p = local_variables_forbidden_p;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-31 19:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-31 19:54 [gcc r12-3274] c++: Various small fixes Jason Merrill

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).