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,7 +4372,8 @@ 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 "
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))

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

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