re PR c++/17947 (bad warning with implicit conversion and __attribute__((deprecated)))

2007-01-19  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

	PR c++/17947
	* toplev.c (warn_deprecated_use): Use %qD instead of %qs to
	print the name of the declared identifier.
		
testsuite/
	* g++.dg/warn/deprecated.C: Update warning output.
	* g++.dg/warn/deprecated-2.C: Likewise.
	* g++.dg/warn/deprecated-3.C: New.

From-SVN: r120969
This commit is contained in:
Manuel López-Ibáñez 2007-01-19 16:04:57 +00:00
parent b0fede98c0
commit e65fff3cde
6 changed files with 42 additions and 16 deletions

View File

@ -1,3 +1,9 @@
2007-01-19 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR c++/17947
* toplev.c (warn_deprecated_use): Use %qD instead of %qs to print
the name of the declared identifier.
2007-01-19 Dirk Mueller <dmueller@suse.de>
* config/i386.h (CONDITIONAL_REGISTER_USAGE): Store

View File

@ -1,3 +1,10 @@
2007-01-19 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR c++/17947
* g++.dg/warn/deprecated.C: Update warning output.
* g++.dg/warn/deprecated-2.C: Likewise.
* g++.dg/warn/deprecated-3.C: New.
2007-01-19 Nathan Sidwell <nathan@codesourcery.com>
* gcc.c-torture/execute/nestfunc-7.c: New.

View File

@ -7,5 +7,5 @@ void func(void);
void func(void) __attribute__((deprecated));
void f(void) {
func(); /* { dg-warning "'func' is deprecated" } */
func(); /* { dg-warning "'void func\\(\\)' is deprecated" } */
}

View File

@ -0,0 +1,14 @@
/* PR 17947 bad warning with implicit conversion and __attribute__((deprecated)) */
/* { dg-do compile } */
/* { dg-options "" } */
struct Foo
{
operator int() __attribute__((deprecated));
};
void g(void)
{
Foo f;
(int)f; // { dg-warning "warning: 'Foo::operator int\\(\\)' is deprecated \\(declared at" }
}

View File

@ -50,13 +50,13 @@ int func1()
int x __attribute__ ((deprecated));
int y __attribute__ ((__deprecated__));
int z;
int (*pf)() = f1; /* { dg-warning "'f1' is deprecated" "" } */
int (*pf)() = f1; /* { dg-warning "'INT1 f1\\(\\)' is deprecated" "" } */
z = w + x + y + g1 + g2 + g3; /* { dg-warning "'x' is deprecated" "" } */
/* { dg-warning "'y' is deprecated" "y" { target *-*-* } 55 } */
/* { dg-warning "'g2' is deprecated" "g2" { target *-*-* } 55 } */
/* { dg-warning "'g3' is deprecated" "g3" { target *-*-* } 55 } */
return f1(); /* { dg-warning "'f1' is deprecated" "f1" } */
return f1(); /* { dg-warning "'INT1 f1\\(\\)' is deprecated" "f1" } */
}
int func2(S1 *p)
@ -64,14 +64,14 @@ int func2(S1 *p)
S1 lp;
if (p->field1)
return p->field2; /* { dg-warning "'field2' is deprecated" "" } */
else if (lp.field4) /* { dg-warning "'field4' is deprecated" "" } */
return p->field2; /* { dg-warning "'S1::field2' is deprecated" "" } */
else if (lp.field4) /* { dg-warning "'S1::field4' is deprecated" "" } */
return p->field3;
p->u1.field5 = g1 + p->field7;
p->u2.field9; /* { dg-warning "'u2' is deprecated" "" } */
return p->u1.field6 + p->field8; /* { dg-warning "'field6' is deprecated" "" } */
/* { dg-warning "'field8' is deprecated" "field8" { target *-*-* } 73 } */
p->u2.field9; /* { dg-warning "'S1::u2' is deprecated" "" } */
return p->u1.field6 + p->field8; /* { dg-warning "'S1::<anonymous union>::field6' is deprecated" "" } */
/* { dg-warning "'S1::field8' is deprecated" "field8" { target *-*-* } 73 } */
}
struct SS1 {
@ -104,13 +104,13 @@ inline void T::member1(int) {}
int T::member3(T *p)
{
p->member1(1); /* { dg-warning "'member1' is deprecated" "" } */
(*p).member1(2); /* { dg-warning "'member1' is deprecated" "" } */
p->member2(1); /* { dg-warning "'member2' is deprecated" "" } */
(*p).member2(2); /* { dg-warning "'member2' is deprecated" "" } */
p->member1(1); /* { dg-warning "'void T::member1\\(int\\)' is deprecated" "" } */
(*p).member1(2); /* { dg-warning "'void T::member1\\(int\\)' is deprecated" "" } */
p->member2(1); /* { dg-warning "'void T::member2\\(INT1\\)' is deprecated" "" } */
(*p).member2(2); /* { dg-warning "'void T::member2\\(INT1\\)' is deprecated" "" } */
p->member3(p);
(*p).member3(p);
return f1(); /* { dg-warning "'f1' is deprecated" "" } */
return f1(); /* { dg-warning "'INT1 f1\\(\\)' is deprecated" "" } */
}
#endif

View File

@ -901,9 +901,8 @@ warn_deprecated_use (tree node)
{
expanded_location xloc = expand_location (DECL_SOURCE_LOCATION (node));
warning (OPT_Wdeprecated_declarations,
"%qs is deprecated (declared at %s:%d)",
IDENTIFIER_POINTER (DECL_NAME (node)),
xloc.file, xloc.line);
"%qD is deprecated (declared at %s:%d)",
node, xloc.file, xloc.line);
}
else if (TYPE_P (node))
{