From: David Malcolm <dmalcolm@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: gcc-patches@gcc.gnu.org, David Malcolm <dmalcolm@redhat.com>
Subject: [PATCH 09/10] Fix g++.dg/warn/pr35635.C
Date: Thu, 03 Dec 2015 14:37:00 -0000 [thread overview]
Message-ID: <1449154548-43964-10-git-send-email-dmalcolm@redhat.com> (raw)
In-Reply-To: <1449154548-43964-1-git-send-email-dmalcolm@redhat.com>
This testcase was broken by the patch kit; upon investigation
the best fix is to try to use the location of the relevant
expression when warning about conversions, rather than
input_location, falling back to the latter via EXPR_LOC_OR_LOC.
One dg-warning needed moving, since the caret is on the "?" of the
conditional here:
uchar_x = bar != 0
~~~~~~~~
? (unsigned char) 1024
^~~~~~~~~~~~~~~~~~~~~~
: -1;
~~~~
gcc/cp/ChangeLog:
* cvt.c (cp_convert_and_check): When warning about conversions,
attempt to use the location of "expr" if available, otherwise
falling back to the old behavior of using input_location.
gcc/testsuite/ChangeLog:
* g++.dg/warn/pr35635.C (func3): Update location of a
dg-warning.
---
gcc/cp/cvt.c | 4 ++--
gcc/testsuite/g++.dg/warn/pr35635.C | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index ebca004..f24f280 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -650,8 +650,8 @@ cp_convert_and_check (tree type, tree expr, tsubst_flags_t complain)
folded_result = fold_simple (folded_result);
if (!TREE_OVERFLOW_P (folded)
&& folded_result != error_mark_node)
- warnings_for_convert_and_check (input_location, type, folded,
- folded_result);
+ warnings_for_convert_and_check (EXPR_LOC_OR_LOC (expr, input_location),
+ type, folded, folded_result);
}
return result;
diff --git a/gcc/testsuite/g++.dg/warn/pr35635.C b/gcc/testsuite/g++.dg/warn/pr35635.C
index de68ceb..19345c5 100644
--- a/gcc/testsuite/g++.dg/warn/pr35635.C
+++ b/gcc/testsuite/g++.dg/warn/pr35635.C
@@ -62,9 +62,9 @@ void func3()
/* At least one branch of ? does not fit in the destination, thus
warn. */
uchar_x = bar != 0 ? 2.1 : 10; /* { dg-warning "conversion" } */
- uchar_x = bar != 0 /* { dg-warning "negative integer implicitly converted to unsigned type" } */
- ? (unsigned char) 1024
- : -1;
+ uchar_x = bar != 0
+ ? (unsigned char) 1024 /* { dg-warning "negative integer implicitly converted to unsigned type" } */
+ : -1;
}
void func4()
--
1.8.5.3
next prev parent reply other threads:[~2015-12-03 14:37 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-07 3:40 [PATCH/RFC] C++ FE: expression ranges (work in progress) David Malcolm
2015-11-15 4:43 ` [PATCH/RFC] C++ FE: expression ranges (v2) David Malcolm
2015-11-19 20:46 ` Jason Merrill
2015-11-21 8:22 ` Jason Merrill
2015-11-21 8:22 ` Jakub Jelinek
2015-11-23 10:02 ` Richard Biener
2015-11-23 16:58 ` David Malcolm
2015-11-23 17:08 ` Jakub Jelinek
2015-11-23 17:09 ` Marek Polacek
2015-11-23 19:45 ` Jason Merrill
2015-11-24 9:42 ` Richard Biener
2015-11-24 11:08 ` David Malcolm
2015-11-24 11:50 ` Richard Biener
2015-11-24 12:15 ` Marek Polacek
2015-11-25 20:32 ` [PATCH/RFC 0/2] C++ FE: expression ranges (v3) David Malcolm
2015-11-25 20:32 ` [PATCH 1/2] RFC: C++: attempt to provide location_t in more places David Malcolm
2015-11-25 21:33 ` Jason Merrill
2015-12-03 14:36 ` [PATCH 00/10] C++ expression ranges v4 David Malcolm
2015-12-03 14:36 ` [PATCH 04/10] Fix g++.dg/template/crash55.C David Malcolm
2015-12-03 14:37 ` [PATCH 03/10] Fix g++.dg/gomp/loop-1.C David Malcolm
2015-12-03 14:37 ` [PATCH 02/10] Fix g++.dg/cpp0x/nsdmi-template14.C David Malcolm
2015-12-03 20:33 ` Jason Merrill
2015-12-03 21:43 ` David Malcolm
2015-12-03 22:17 ` Jason Merrill
2015-12-04 14:22 ` [PATCH 02/10 v2] Fix g++.dg/cpp0x/nsdmi-template14.C (v2) David Malcolm
2015-12-03 14:37 ` [PATCH 07/10] Fix g++.dg/template/ref3.C David Malcolm
2015-12-03 20:38 ` Jason Merrill
2015-12-03 22:08 ` David Malcolm
2015-12-04 16:01 ` Jason Merrill
2015-12-04 16:45 ` [PATCH] Add XFAIL to g++.dg/template/ref3.C (PR c++/68699) David Malcolm
2015-12-04 17:09 ` Jason Merrill
2015-12-03 14:37 ` [PATCH 01/10] C++ FE: expression ranges v4 David Malcolm
2015-12-04 17:10 ` Jason Merrill
2015-12-04 18:13 ` David Malcolm
2015-12-03 14:37 ` [PATCH 10/10] Fix g++.dg/warn/Wconversion-real-integer2.C David Malcolm
2015-12-03 14:37 ` David Malcolm [this message]
2015-12-03 14:37 ` [PATCH 05/10] Fix location of dg-error within g++.dg/template/pr64100.C David Malcolm
2015-12-03 14:37 ` [PATCH 08/10] Fix g++.dg/ubsan/pr63956.C David Malcolm
2015-12-03 14:53 ` [PATCH 06/10] Fix g++.dg/template/pseudodtor3.C David Malcolm
2015-11-25 20:38 ` [PATCH 2/2] RFC: C++ FE: expression ranges (work in progress) v3 David Malcolm
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=1449154548-43964-10-git-send-email-dmalcolm@redhat.com \
--to=dmalcolm@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
/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).