diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-04-23 20:30:52 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-04-23 20:30:52 +0000 |
commit | d6724367519b4f98dcce091854549282c11d70a0 (patch) | |
tree | aa30a4e8e944f3723cb2b29ad7ef33e5578a3580 | |
parent | 87380aaf4273b2259fa75790f2f544c4514cc763 (diff) |
with -Wdeprecated, include a note to its deprecated declaration
location. // rdar://10893232
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155385 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 6 | ||||
-rw-r--r-- | test/Sema/MicrosoftExtensions.c | 4 | ||||
-rw-r--r-- | test/Sema/attr-availability-ios.c | 8 | ||||
-rw-r--r-- | test/Sema/attr-availability-macosx.c | 2 | ||||
-rw-r--r-- | test/Sema/attr-availability.c | 2 | ||||
-rw-r--r-- | test/Sema/attr-deprecated-message.c | 2 | ||||
-rw-r--r-- | test/SemaObjC/attr-availability.m | 11 |
7 files changed, 23 insertions, 12 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 59c4373190..861b91420d 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -4189,9 +4189,13 @@ void Sema::EmitDeprecationWarning(NamedDecl *D, StringRef Message, // Otherwise, don't warn if our current context is deprecated. if (isDeclDeprecated(cast<Decl>(getCurLexicalContext()))) return; - if (!Message.empty()) + if (!Message.empty()) { Diag(Loc, diag::warn_deprecated_message) << D->getDeclName() << Message; + Diag(D->getLocation(), + isa<ObjCMethodDecl>(D) ? diag::note_method_declared_at + : diag::note_previous_decl) << D->getDeclName(); + } else { if (!UnknownObjCClass) Diag(Loc, diag::warn_deprecated) << D->getDeclName(); diff --git a/test/Sema/MicrosoftExtensions.c b/test/Sema/MicrosoftExtensions.c index fb0c6bde9a..52cb88277c 100644 --- a/test/Sema/MicrosoftExtensions.c +++ b/test/Sema/MicrosoftExtensions.c @@ -87,11 +87,11 @@ typedef struct { AA; // expected-warning {{anonymous structs are a Microsoft extension}} } BB; -__declspec(deprecated("This is deprecated")) enum DE1 { one, two } e1; +__declspec(deprecated("This is deprecated")) enum DE1 { one, two } e1; // expected-note {{'e1' declared here}} struct __declspec(deprecated) DS1 { int i; float f; }; #define MY_TEXT "This is also deprecated" -__declspec(deprecated(MY_TEXT)) void Dfunc1( void ) {} +__declspec(deprecated(MY_TEXT)) void Dfunc1( void ) {} // expected-note {{'Dfunc1' declared here}} void test( void ) { e1 = one; // expected-warning {{'e1' is deprecated: This is deprecated}} diff --git a/test/Sema/attr-availability-ios.c b/test/Sema/attr-availability-ios.c index ea05e17bad..329068cf16 100644 --- a/test/Sema/attr-availability-ios.c +++ b/test/Sema/attr-availability-ios.c @@ -1,14 +1,14 @@ // RUN: %clang_cc1 "-triple" "x86_64-apple-ios3.0" -fsyntax-only -verify %s -void f0(int) __attribute__((availability(ios,introduced=2.0,deprecated=2.1))); +void f0(int) __attribute__((availability(ios,introduced=2.0,deprecated=2.1))); // expected-note {{'f0' declared here}} void f1(int) __attribute__((availability(ios,introduced=2.1))); -void f2(int) __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); +void f2(int) __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{'f2' declared here}} void f3(int) __attribute__((availability(ios,introduced=3.0))); void f4(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(ios,introduced=2.0,deprecated=2.1,obsoleted=3.0))); // expected-note{{explicitly marked unavailable}} -void f5(int) __attribute__((availability(ios,introduced=2.0))) __attribute__((availability(ios,deprecated=3.0))); +void f5(int) __attribute__((availability(ios,introduced=2.0))) __attribute__((availability(ios,deprecated=3.0))); // expected-note {{'f5' declared here}} void f6(int) __attribute__((availability(ios,deprecated=3.0))); -void f6(int) __attribute__((availability(ios,introduced=2.0))); +void f6(int) __attribute__((availability(ios,introduced=2.0))); // expected-note {{'f6' declared here}} void test() { f0(0); // expected-warning{{'f0' is deprecated: first deprecated in iOS 2.1}} diff --git a/test/Sema/attr-availability-macosx.c b/test/Sema/attr-availability-macosx.c index 1de26e9e9e..781523a2e0 100644 --- a/test/Sema/attr-availability-macosx.c +++ b/test/Sema/attr-availability-macosx.c @@ -2,7 +2,7 @@ void f0(int) __attribute__((availability(macosx,introduced=10.4,deprecated=10.6))); void f1(int) __attribute__((availability(macosx,introduced=10.5))); -void f2(int) __attribute__((availability(macosx,introduced=10.4,deprecated=10.5))); +void f2(int) __attribute__((availability(macosx,introduced=10.4,deprecated=10.5))); // expected-note {{'f2' declared here}} void f3(int) __attribute__((availability(macosx,introduced=10.6))); void f4(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(ios,introduced=2.0,deprecated=3.0))); // expected-note{{explicitly marked unavailable}} void f5(int) __attribute__((availability(ios,introduced=3.2), availability(macosx,unavailable))); // expected-note{{function has been explicitly marked unavailable here}} diff --git a/test/Sema/attr-availability.c b/test/Sema/attr-availability.c index 0e6ea9697b..5fb63cd722 100644 --- a/test/Sema/attr-availability.c +++ b/test/Sema/attr-availability.c @@ -8,7 +8,7 @@ void f3() __attribute__((availability(otheros,introduced=2.2))); // expected-war // rdar://10095131 extern void -ATSFontGetName(const char *oName) __attribute__((availability(macosx,introduced=8.0,deprecated=9.0, message="use CTFontCopyFullName"))); +ATSFontGetName(const char *oName) __attribute__((availability(macosx,introduced=8.0,deprecated=9.0, message="use CTFontCopyFullName"))); // expected-note {{'ATSFontGetName' declared here}} extern void ATSFontGetPostScriptName(int flags) __attribute__((availability(macosx,introduced=8.0,obsoleted=9.0, message="use ATSFontGetFullPostScriptName"))); // expected-note {{function has been explicitly marked unavailable here}} diff --git a/test/Sema/attr-deprecated-message.c b/test/Sema/attr-deprecated-message.c index 5de31d0d13..08b09f95c0 100644 --- a/test/Sema/attr-deprecated-message.c +++ b/test/Sema/attr-deprecated-message.c @@ -21,7 +21,7 @@ typedef enum {red, green, blue} Color __attribute__((deprecated("Please avoid Co Color c1; // expected-warning {{'Color' is deprecated: Please avoid Color}} int g1; -int g2 __attribute__ ((deprecated("Please avoid g2"))); +int g2 __attribute__ ((deprecated("Please avoid g2"))); // expected-note {{'g2' declared here}} int func1() { diff --git a/test/SemaObjC/attr-availability.m b/test/SemaObjC/attr-availability.m index d857bda772..405cfbb98f 100644 --- a/test/SemaObjC/attr-availability.m +++ b/test/SemaObjC/attr-availability.m @@ -1,6 +1,11 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin9.0.0 -fsyntax-only -verify %s -@interface A -- (void)method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))); + +@protocol P +- (void)proto_method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))); // expected-note 2 {{method 'proto_method' declared here}} +@end + +@interface A <P> +- (void)method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))); // expected-note {{method 'method' declared here}} @end @interface B : A @@ -10,4 +15,6 @@ void f(A *a, B *b) { [a method]; // expected-warning{{'method' is deprecated: first deprecated in Mac OS X 10.2}} [b method]; + [a proto_method]; // expected-warning{{'proto_method' is deprecated: first deprecated in Mac OS X 10.2}} + [b proto_method]; // expected-warning{{'proto_method' is deprecated: first deprecated in Mac OS X 10.2}} } |