tree.c (handle_nodiscard_attribute): Improve warning location.

/cp
2019-01-03  Paolo Carlini  <paolo.carlini@oracle.com>

	* tree.c (handle_nodiscard_attribute): Improve warning location.

/testsuite
2019-01-03  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/cpp1z/nodiscard3.C: Test locations too.

From-SVN: r267547
This commit is contained in:
Paolo Carlini 2019-01-03 10:00:30 +00:00 committed by Paolo Carlini
parent d1409ea5a2
commit 7dae295006
4 changed files with 15 additions and 6 deletions

View File

@ -1,3 +1,7 @@
2019-01-03 Paolo Carlini <paolo.carlini@oracle.com>
* tree.c (handle_nodiscard_attribute): Improve warning location.
2019-01-02 Marek Polacek <polacek@redhat.com>
PR c++/88612 - ICE with -Waddress-of-packed-member.

View File

@ -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 */;

View File

@ -1,3 +1,7 @@
2019-01-03 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/cpp1z/nodiscard3.C: Test locations too.
2019-01-03 Martin Liska <mliska@suse.cz>
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 <msebor@redhat.com>
Jeff Law <law@redhat.com>
@ -31,7 +35,7 @@
messages only on vect_hw_misalign targets.
2019-01-02 Steven G. Kargl <kargl@gcc.gnu.org>
* 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.

View File

@ -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);