From 7dae295006bed4093ecbc1fda38a457338ff859b Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 3 Jan 2019 10:00:30 +0000 Subject: [PATCH] tree.c (handle_nodiscard_attribute): Improve warning location. /cp 2019-01-03 Paolo Carlini * tree.c (handle_nodiscard_attribute): Improve warning location. /testsuite 2019-01-03 Paolo Carlini * g++.dg/cpp1z/nodiscard3.C: Test locations too. From-SVN: r267547 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/tree.c | 5 +++-- gcc/testsuite/ChangeLog | 8 ++++++-- gcc/testsuite/g++.dg/cpp1z/nodiscard3.C | 4 ++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1ac5832d455..5b94654b10a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2019-01-03 Paolo Carlini + + * tree.c (handle_nodiscard_attribute): Improve warning location. + 2019-01-02 Marek Polacek PR c++/88612 - ICE with -Waddress-of-packed-member. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 6bbad5fb7a9..4db89a4e5a6 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -4372,8 +4372,9 @@ handle_nodiscard_attribute (tree *node, tree name, tree /*args*/, if (TREE_CODE (*node) == FUNCTION_DECL) { if (VOID_TYPE_P (TREE_TYPE (TREE_TYPE (*node)))) - warning (OPT_Wattributes, "%qE attribute applied to %qD with void " - "return type", name, *node); + warning_at (DECL_SOURCE_LOCATION (*node), + OPT_Wattributes, "%qE attribute applied to %qD with void " + "return type", name, *node); } else if (OVERLOAD_TYPE_P (*node)) /* OK */; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0eb365817e8..c077f7a9a8e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-01-03 Paolo Carlini + + * g++.dg/cpp1z/nodiscard3.C: Test locations too. + 2019-01-03 Martin Liska PR testsuite/88436 @@ -14,7 +18,7 @@ PR c++/81486 - CTAD failing with (). * g++.dg/cpp1z/class-deduction60.C: New test. * g++.dg/cpp1z/class-deduction61.C: New test. - + 2019-01-02 Martin Sebor Jeff Law @@ -31,7 +35,7 @@ messages only on vect_hw_misalign targets. 2019-01-02 Steven G. Kargl - + * gfortran.dg/argument_checking_7.f90: Remove run-on error message. * gfortran.dg/dec_d_lines_3.f: Ditto. * gfortran.dg/dec_structure_24.f90: Ditto. diff --git a/gcc/testsuite/g++.dg/cpp1z/nodiscard3.C b/gcc/testsuite/g++.dg/cpp1z/nodiscard3.C index 4d24ce54413..42485b73972 100644 --- a/gcc/testsuite/g++.dg/cpp1z/nodiscard3.C +++ b/gcc/testsuite/g++.dg/cpp1z/nodiscard3.C @@ -13,8 +13,8 @@ typedef struct { char big[1024]; fnt fn; } C; struct [[nodiscard]] D { int i; D(); ~D(); }; WUR E check1 (void); -WUR void check2 (void); /* { dg-warning "nodiscard" } */ -WUR int foo; /* { dg-warning "nodiscard" } */ +WUR void check2 (void); /* { dg-warning "10:.nodiscard." } */ +WUR int foo; /* { dg-warning "9:.nodiscard." } */ int bar (void); WURAI E check3 (void) { return (E)bar (); } WUR A check4 (void); -- 2.30.2