public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Eric Botcazou <ebotcazou@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-1064] Do not erase warning data in gimple_set_location
Date: Mon, 13 Jun 2022 11:35:40 +0000 (GMT)	[thread overview]
Message-ID: <20220613113540.F03EB38387E1@sourceware.org> (raw)

https://gcc.gnu.org/g:cb1ecf3819f19a4fc35468010b66b5c1a7b21ee8

commit r13-1064-gcb1ecf3819f19a4fc35468010b66b5c1a7b21ee8
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Mon Jun 13 10:03:36 2022 +0200

    Do not erase warning data in gimple_set_location
    
    gimple_set_location is mostly invoked on newly built GIMPLE statements, so
    their location is UNKNOWN_LOCATION and setting it will clobber the warning
    data of the passed location, if any.
    
    gcc/
            * dwarf2out.cc (output_one_line_info_table): Initialize prev_addr.
            * gimple.h (gimple_set_location): Do not copy warning data from
            the previous location when it is UNKNOWN_LOCATION.
            * optabs.cc (expand_widen_pattern_expr): Always set oprnd{1,2}.
    gcc/testsuite/
            * c-c++-common/nonnull-1.c: Remove XFAIL for C++.

Diff:
---
 gcc/dwarf2out.cc                       | 2 +-
 gcc/gimple.h                           | 3 ++-
 gcc/optabs.cc                          | 6 ++----
 gcc/testsuite/c-c++-common/nonnull-1.c | 2 +-
 4 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index 29f32ec6939..b468a4b9c0f 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -12916,7 +12916,7 @@ output_one_line_info_table (dw_line_info_table *table)
   char line_label[MAX_ARTIFICIAL_LABEL_BYTES];
   unsigned int current_line = 1;
   bool current_is_stmt = DWARF_LINE_DEFAULT_IS_STMT_START;
-  dw_line_info_entry *ent, *prev_addr;
+  dw_line_info_entry *ent, *prev_addr = NULL;
   size_t i;
   unsigned int view;
 
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 6b1e89ad74e..870629cd562 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -1913,7 +1913,8 @@ static inline void
 gimple_set_location (gimple *g, location_t location)
 {
   /* Copy the no-warning data to the statement location.  */
-  copy_warning (location, g->location);
+  if (g->location != UNKNOWN_LOCATION)
+    copy_warning (location, g->location);
   g->location = location;
 }
 
diff --git a/gcc/optabs.cc b/gcc/optabs.cc
index c0a68471d2d..a50dd798f2a 100644
--- a/gcc/optabs.cc
+++ b/gcc/optabs.cc
@@ -264,10 +264,8 @@ expand_widen_pattern_expr (sepops ops, rtx op0, rtx op1, rtx wide_op,
   bool sbool = false;
 
   oprnd0 = ops->op0;
-  if (nops >= 2)
-    oprnd1 = ops->op1;
-  if (nops >= 3)
-    oprnd2 = ops->op2;
+  oprnd1 = nops >= 2 ? ops->op1 : NULL_TREE;
+  oprnd2 = nops >= 3 ? ops->op2 : NULL_TREE;
 
   tmode0 = TYPE_MODE (TREE_TYPE (oprnd0));
   if (ops->code == VEC_UNPACK_FIX_TRUNC_HI_EXPR
diff --git a/gcc/testsuite/c-c++-common/nonnull-1.c b/gcc/testsuite/c-c++-common/nonnull-1.c
index ea987365302..7be4e3479dd 100644
--- a/gcc/testsuite/c-c++-common/nonnull-1.c
+++ b/gcc/testsuite/c-c++-common/nonnull-1.c
@@ -30,5 +30,5 @@ func (char *cp1, char *cp2, char *cp3, char *cp4)
 __attribute__((nonnull (1))) int
 func2 (char *cp)
 {
-  return (cp != NULL) ? 1 : 0; /* { dg-warning "'nonnull' argument" "cp compared to NULL" { xfail c++ } } */
+  return (cp != NULL) ? 1 : 0; /* { dg-warning "'nonnull' argument" "cp compared to NULL" } */
 }


                 reply	other threads:[~2022-06-13 11:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220613113540.F03EB38387E1@sourceware.org \
    --to=ebotcazou@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).