* PR 17947 bad warning with implicit conversion and __attribute__((deprecated))
@ 2007-01-17 17:15 Manuel López-Ibáñez
2007-01-18 15:55 ` Ian Lance Taylor
0 siblings, 1 reply; 2+ messages in thread
From: Manuel López-Ibáñez @ 2007-01-17 17:15 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 821 bytes --]
:ADDPATCH toplev / c++:
The Wdeprecated-declarations warning is using %qs to print the name of
a declaration. This produces funny results such as "operator 1" when
it should say "Foo::operator int()". This patch replaces %qs with %qD
and updates current testcases. I wasn't able to find what is the
difference between %qD, %q+D and %q#D, so I am not sure if this is the
right choice.
Bootstrapped and regression tested with --enable-languages=all on
i686-pc-linux-gnu.
OK for mainline?
2007-01-18 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/
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.
[-- Attachment #2: wdeprecated.diff --]
[-- Type: text/plain, Size: 4483 bytes --]
Index: gcc/toplev.c
===================================================================
--- gcc/toplev.c (revision 120783)
+++ gcc/toplev.c (working copy)
@@ -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))
{
Index: gcc/testsuite/g++.dg/warn/deprecated-2.C
===================================================================
--- gcc/testsuite/g++.dg/warn/deprecated-2.C (revision 120783)
+++ gcc/testsuite/g++.dg/warn/deprecated-2.C (working copy)
@@ -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" } */
}
Index: gcc/testsuite/g++.dg/warn/deprecated.C
===================================================================
--- gcc/testsuite/g++.dg/warn/deprecated.C (revision 120783)
+++ gcc/testsuite/g++.dg/warn/deprecated.C (working copy)
@@ -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
Index: gcc/testsuite/g++.dg/warn/deprecated-3.C
===================================================================
--- gcc/testsuite/g++.dg/warn/deprecated-3.C (revision 0)
+++ gcc/testsuite/g++.dg/warn/deprecated-3.C (revision 0)
@@ -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" }
+}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: PR 17947 bad warning with implicit conversion and __attribute__((deprecated))
2007-01-17 17:15 PR 17947 bad warning with implicit conversion and __attribute__((deprecated)) Manuel López-Ibáñez
@ 2007-01-18 15:55 ` Ian Lance Taylor
0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2007-01-18 15:55 UTC (permalink / raw)
To: Manuel López-Ibáñez; +Cc: gcc-patches
"Manuel López-Ibáñez" <lopezibanez@gmail.com> writes:
> 2007-01-18 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/
> 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.
This is OK.
Thanks.
:REVIEWMAIL:
Ian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-01-18 15:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-17 17:15 PR 17947 bad warning with implicit conversion and __attribute__((deprecated)) Manuel López-Ibáñez
2007-01-18 15:55 ` Ian Lance Taylor
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).