+2014-11-18 Jason Merrill <jason@redhat.com>
+
+ * tree.c (warn_deprecated_use): Show declaration with inform.
+
2014-11-18 Richard Biener <rguenther@suse.de>
PR tree-optimization/63914
void g(void)
{
Foo f;
- (int)f; // { dg-warning "'Foo::operator int\\(\\)' is deprecated \\(declared at" }
+ (int)f; // { dg-warning "'Foo::operator int\\(\\)' is deprecated" }
}
typedef int INT1 __attribute__((deprecated("Please avoid INT1")));
typedef INT1 INT2 __attribute__ ((__deprecated__("Please avoid INT2")));
-typedef INT1 INT1a; /* { dg-warning "'INT1' is deprecated .declared at \[^\n\]*: Please avoid INT1" "" } */
+typedef INT1 INT1a; /* { dg-warning "'INT1' is deprecated: Please avoid INT1" "" } */
-INT1 should_be_unavailable; /* { dg-warning "'INT1' is deprecated .declared at \[^\n\]*: Please avoid INT1" "" } */
+INT1 should_be_unavailable; /* { dg-warning "'INT1' is deprecated: Please avoid INT1" "" } */
INT1a should_not_be_deprecated;
INT1 f1(void) __attribute__ ((deprecated("Please avoid f1")));
-INT1 f2(void) { return 0; } /* { dg-warning "'INT1' is deprecated .declared at \[^\n\]*: Please avoid INT1" "" } */
+INT1 f2(void) { return 0; } /* { dg-warning "'INT1' is deprecated: Please avoid INT1" "" } */
INT2 f3(void) __attribute__ ((__deprecated__("Please avoid f3")));
-INT2 f4(void) { return 0; } /* { dg-warning "'INT2' is deprecated .declared at \[^\n\]*: Please avoid INT2" "" } */
+INT2 f4(void) { return 0; } /* { dg-warning "'INT2' is deprecated: Please avoid INT2" "" } */
int f5(INT2 x); /* { dg-warning "'INT2' is deprecated" "" } */
int f6(INT2 x) __attribute__ ((__deprecated__("Please avoid f6")));
int g1;
int g2 __attribute__ ((deprecated("Please avoid g2")));
int g3 __attribute__ ((__deprecated__("Please avoid g3")));
-Color k; /* { dg-warning "'Color' is deprecated .declared at \[^\n\]*: Please avoid Color" "" } */
+Color k; /* { dg-warning "'Color' is deprecated: Please avoid Color" "" } */
typedef struct {
int field1;
int func1()
{
- INT1 w; /* { dg-warning "'INT1' is deprecated .declared at \[^\n\]*: Please avoid INT1" "" } */
+ INT1 w; /* { dg-warning "'INT1' is deprecated: Please avoid INT1" "" } */
int x __attribute__ ((deprecated("Please avoid x")));
int y __attribute__ ((__deprecated__("Please avoid y")));
int z;
- int (*pf)() = f1; /* { dg-warning "'INT1 f1\\(\\)' is deprecated .declared at \[^\n\]*: Please avoid f1" "" } */
+ int (*pf)() = f1; /* { dg-warning "'INT1 f1\\(\\)' is deprecated: Please avoid f1" "" } */
- z = w + x + y + g1 + g2 + g3; /* { dg-warning "'x' is deprecated .declared at \[^\n\]*: Please avoid x" "" } */
- /* { dg-warning "'y' is deprecated .declared at \[^\n\]*: Please avoid y" "y" { target *-*-* } 53 } */
- /* { dg-warning "'g2' is deprecated .declared at \[^\n\]*: Please avoid g2" "g2" { target *-*-* } 53 } */
- /* { dg-warning "'g3' is deprecated .declared at \[^\n\]*: Please avoid g3" "g3" { target *-*-* } 53 } */
- return f1(); /* { dg-warning "'INT1 f1\\(\\)' is deprecated .declared at \[^\n\]*: Please avoid f1" "f1" } */
+ z = w + x + y + g1 + g2 + g3; /* { dg-warning "'x' is deprecated: Please avoid x" "" } */
+ /* { dg-warning "'y' is deprecated: Please avoid y" "y" { target *-*-* } 53 } */
+ /* { dg-warning "'g2' is deprecated: Please avoid g2" "g2" { target *-*-* } 53 } */
+ /* { dg-warning "'g3' is deprecated: Please avoid g3" "g3" { target *-*-* } 53 } */
+ return f1(); /* { dg-warning "'INT1 f1\\(\\)' is deprecated: Please avoid f1" "f1" } */
}
int func2(S1 *p)
S1 lp;
if (p->field1)
- return p->field2; /* { dg-warning "'S1::field2' is deprecated .declared at \[^\n\]*: Please avoid field2" "" } */
- else if (lp.field4) /* { dg-warning "'S1::field4' is deprecated .declared at \[^\n\]*: Please avoid field4" "" } */
+ return p->field2; /* { dg-warning "'S1::field2' is deprecated: Please avoid field2" "" } */
+ else if (lp.field4) /* { dg-warning "'S1::field4' is deprecated: Please avoid field4" "" } */
return p->field3;
p->u1.field5 = g1 + p->field7;
- p->u2.field9; /* { dg-warning "'S1::u2' is deprecated .declared at \[^\n\]*: Please avoid u2" "" } */
- return p->u1.field6 + p->field8; /* { dg-warning "'S1::<anonymous union>::field6' is deprecated .declared at \[^\n\]*: Please avoid field6" "" } */
- /* { dg-warning "'S1::field8' is deprecated .declared at \[^\n\]*: Please avoid field8" "field8" { target *-*-* } 71 } */
+ p->u2.field9; /* { dg-warning "'S1::u2' is deprecated: Please avoid u2" "" } */
+ return p->u1.field6 + p->field8; /* { dg-warning "'S1::<anonymous union>::field6' is deprecated: Please avoid field6" "" } */
+ /* { dg-warning "'S1::field8' is deprecated: Please avoid field8" "field8" { target *-*-* } 71 } */
}
struct SS1 {
int x;
- INT1 y; /* { dg-warning "'INT1' is deprecated .declared at \[^\n\]*: Please avoid INT1" "" } */
+ INT1 y; /* { dg-warning "'INT1' is deprecated: Please avoid INT1" "" } */
} __attribute__ ((deprecated("Please avoid SS1")));
-struct SS1 *p1; /* { dg-warning "'SS1' is deprecated .declared at \[^\n\]*: Please avoid SS1" "" } */
+struct SS1 *p1; /* { dg-warning "'SS1' is deprecated: Please avoid SS1" "" } */
struct __attribute__ ((__deprecated__("Please avoid SS2"))) SS2 {
int x;
- INT1 y; /* { dg-warning "'INT1' is deprecated .declared at \[^\n\]*: Please avoid INT1" "" } */
+ INT1 y; /* { dg-warning "'INT1' is deprecated: Please avoid INT1" "" } */
};
-struct SS2 *p2; /* { dg-warning "'SS2' is deprecated .declared at \[^\n\]*: Please avoid SS2" "" } */
+struct SS2 *p2; /* { dg-warning "'SS2' is deprecated: Please avoid SS2" "" } */
class T {
public:
int x;
} __attribute__ ((deprecated("Please avoid T")));
-T *p3; // { dg-warning "'T' is deprecated .declared at \[^\n\]*: Please avoid T" }
+T *p3; // { dg-warning "'T' is deprecated: Please avoid T" }
inline void T::member1(int) {}
-int T::member3(T *p) // { dg-warning "'T' is deprecated .declared at \[^\n\]*: Please avoid T" }
+int T::member3(T *p) // { dg-warning "'T' is deprecated: Please avoid T" }
{
- p->member1(1); /* { dg-warning "'void T::member1\\(int\\)' is deprecated .declared at \[^\n\]*: Please avoid member1" "" } */
- (*p).member1(2); /* { dg-warning "'void T::member1\\(int\\)' is deprecated .declared at \[^\n\]*: Please avoid member1" "" } */
- p->member2(1); /* { dg-warning "'void T::member2\\(INT1\\)' is deprecated .declared at \[^\n\]*: Please avoid member2" "" } */
- (*p).member2(2); /* { dg-warning "'void T::member2\\(INT1\\)' is deprecated .declared at \[^\n\]*: Please avoid member2" "" } */
+ p->member1(1); /* { dg-warning "'void T::member1\\(int\\)' is deprecated: Please avoid member1" "" } */
+ (*p).member1(2); /* { dg-warning "'void T::member1\\(int\\)' is deprecated: Please avoid member1" "" } */
+ p->member2(1); /* { dg-warning "'void T::member2\\(INT1\\)' is deprecated: Please avoid member2" "" } */
+ (*p).member2(2); /* { dg-warning "'void T::member2\\(INT1\\)' is deprecated: Please avoid member2" "" } */
p->member3(p);
(*p).member3(p);
- return f1(); /* { dg-warning "'INT1 f1\\(\\)' is deprecated .declared at \[^\n\]*: Please avoid f1" "" } */
+ return f1(); /* { dg-warning "'INT1 f1\\(\\)' is deprecated: Please avoid f1" "" } */
}
int g1;
int g2 __attribute__ ((deprecated("Please avoid g2")));
int g3 __attribute__ ((__deprecated__("Please avoid g3")));
-Color k; /* { dg-warning "'Color' is deprecated .declared at \[^\n\]*: Please avoid Color" "" } */
+Color k; /* { dg-warning "'Color' is deprecated: Please avoid Color" "" } */
typedef struct {
int field1;
int x __attribute__ ((deprecated("Avoid x")));
int y __attribute__ ((__deprecated__("Bad y")));
int z;
- int (*pf)() = f1; /* { dg-warning "'f1' is deprecated .declared at \[^\n\]*: Please avoid f1" "" } */
+ int (*pf)() = f1; /* { dg-warning "'f1' is deprecated: Please avoid f1" "" } */
- z = w + x + y + g1 + g2 + g3; /* { dg-warning "'x' is deprecated .declared at \[^\n\]*: Avoid x" "" } */
- /* { dg-warning "'y' is deprecated .declared at \[^\n\]*: Bad y" "y" { target *-*-* } 54 } */
- /* { dg-warning "'g2' is deprecated .declared at \[^\n\]*: Please avoid g2" "g2" { target *-*-* } 54 } */
- /* { dg-warning "'g3' is deprecated .declared at \[^\n\]*: Please avoid g3" "g3" { target *-*-* } 54 } */
- return f1(); /* { dg-warning "'f1' is deprecated .declared at \[^\n\]*: Please avoid f1" "" } */
+ z = w + x + y + g1 + g2 + g3; /* { dg-warning "'x' is deprecated: Avoid x" "" } */
+ /* { dg-warning "'y' is deprecated: Bad y" "y" { target *-*-* } 54 } */
+ /* { dg-warning "'g2' is deprecated: Please avoid g2" "g2" { target *-*-* } 54 } */
+ /* { dg-warning "'g3' is deprecated: Please avoid g3" "g3" { target *-*-* } 54 } */
+ return f1(); /* { dg-warning "'f1' is deprecated: Please avoid f1" "" } */
}
int func2(S1 *p)
S1 lp;
if (p->field1)
- return p->field2; /* { dg-warning "'field2' is deprecated .declared at \[^\n\]*: Please avoid field2" "" } */
- else if (lp.field4) /* { dg-warning "'field4' is deprecated .declared at \[^\n\]*: Please avoid field4" "" } */
+ return p->field2; /* { dg-warning "'field2' is deprecated: Please avoid field2" "" } */
+ else if (lp.field4) /* { dg-warning "'field4' is deprecated: Please avoid field4" "" } */
return p->field3;
p->u1.field5 = g1 + p->field7;
- p->u2.field9; /* { dg-warning "'u2' is deprecated .declared at \[^\n\]*: Please avoid u2" "" } */
- return p->u1.field6 + p->field8; /* { dg-warning "'field6' is deprecated .declared at \[^\n\]*: Please avoid field6" "" } */
- /* { dg-warning "'field8' is deprecated .declared at \[^\n\]*: Please avoid field8" "field8" { target *-*-* } 72 } */
+ p->u2.field9; /* { dg-warning "'u2' is deprecated: Please avoid u2" "" } */
+ return p->u1.field6 + p->field8; /* { dg-warning "'field6' is deprecated: Please avoid field6" "" } */
+ /* { dg-warning "'field8' is deprecated: Please avoid field8" "field8" { target *-*-* } 72 } */
}
struct SS1 {
INT1 y; /* { dg-warning "'INT1' is deprecated: Please avoid INT1" "" } */
} __attribute__ ((deprecated("Please avoid SS1")));
-struct SS1 *p1; /* { dg-warning "'SS1' is deprecated .declared at \[^\n\]*: Please avoid SS1" "" } */
+struct SS1 *p1; /* { dg-warning "'SS1' is deprecated: Please avoid SS1" "" } */
struct __attribute__ ((__deprecated__("Please avoid SS2"))) SS2 {
int x;
INT1 y; /* { dg-warning "'INT1' is deprecated: Please avoid INT1" "" } */
};
-struct SS2 *p2; /* { dg-warning "'SS2' is deprecated .declared at \[^\n\]*: Please avoid SS2" "" } */
+struct SS2 *p2; /* { dg-warning "'SS2' is deprecated: Please avoid SS2" "" } */
/* { dg-options "" } */
struct { int a; } __attribute__((deprecated ("Do not use"))) x; /* { dg-warning "type is deprecated" } */
-typeof(x) y; /* { dg-warning "type is deprecated .declared at .*.: Do not use" } */
+typeof(x) y; /* { dg-warning "type is deprecated: Do not use" } */
void func(void) __attribute__((deprecated ("Do not use")));
void f(void) {
- func(); /* { dg-warning "'func' is deprecated .declared at .*.: Do not use" } */
+ func(); /* { dg-warning "'func' is deprecated: Do not use" } */
}
{
obj *p = [obj new];
- return [p vargsn:0]; /* { dg-warning "'vargsn:' is deprecated .declared at" } */
+ return [p vargsn:0]; /* { dg-warning "'vargsn:' is deprecated" } */
}
{
obj *p = [obj new];
- return [p vargsn:0]; /* { dg-warning "'vargsn:' is deprecated .declared at " } */
+ return [p vargsn:0]; /* { dg-warning "'vargsn:' is deprecated" } */
}
else
msg = NULL;
+ bool w;
if (DECL_P (node))
{
- expanded_location xloc = expand_location (DECL_SOURCE_LOCATION (node));
if (msg)
- warning (OPT_Wdeprecated_declarations,
- "%qD is deprecated (declared at %r%s:%d%R): %s",
- node, "locus", xloc.file, xloc.line, msg);
+ w = warning (OPT_Wdeprecated_declarations,
+ "%qD is deprecated: %s", node, msg);
else
- warning (OPT_Wdeprecated_declarations,
- "%qD is deprecated (declared at %r%s:%d%R)",
- node, "locus", xloc.file, xloc.line);
+ w = warning (OPT_Wdeprecated_declarations,
+ "%qD is deprecated", node);
+ if (w)
+ inform (DECL_SOURCE_LOCATION (node), "declared here");
}
else if (TYPE_P (node))
{
if (decl)
{
- expanded_location xloc
- = expand_location (DECL_SOURCE_LOCATION (decl));
if (what)
{
if (msg)
- warning (OPT_Wdeprecated_declarations,
- "%qE is deprecated (declared at %r%s:%d%R): %s",
- what, "locus", xloc.file, xloc.line, msg);
+ w = warning (OPT_Wdeprecated_declarations,
+ "%qE is deprecated: %s", what, msg);
else
- warning (OPT_Wdeprecated_declarations,
- "%qE is deprecated (declared at %r%s:%d%R)",
- what, "locus", xloc.file, xloc.line);
+ w = warning (OPT_Wdeprecated_declarations,
+ "%qE is deprecated", what);
}
else
{
if (msg)
- warning (OPT_Wdeprecated_declarations,
- "type is deprecated (declared at %r%s:%d%R): %s",
- "locus", xloc.file, xloc.line, msg);
+ w = warning (OPT_Wdeprecated_declarations,
+ "type is deprecated: %s", msg);
else
- warning (OPT_Wdeprecated_declarations,
- "type is deprecated (declared at %r%s:%d%R)",
- "locus", xloc.file, xloc.line);
+ w = warning (OPT_Wdeprecated_declarations,
+ "type is deprecated");
}
+ if (w)
+ inform (DECL_SOURCE_LOCATION (decl), "declared here");
}
else
{