From 3b6b7accb55980b149571d44e96f92dae500b0a9 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 10 Aug 2011 15:31:35 +0000 Subject: [PATCH] For the availability attribute, allow a declaration to be deprecated in the same version that it is introduced. Stuff happens. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137214 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclAttr.cpp | 6 +++--- test/Sema/attr-availability.c | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 0644103b44..419adefa12 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -1507,7 +1507,7 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, // Ensure that Introduced < Deprecated < Obsoleted (although not all // of these steps are needed). if (Introduced.isValid() && Deprecated.isValid() && - !(Introduced.Version < Deprecated.Version)) { + !(Introduced.Version <= Deprecated.Version)) { S.Diag(Introduced.KeywordLoc, diag::warn_availability_version_ordering) << 1 << PlatformName << Deprecated.Version.getAsString() << 0 << Introduced.Version.getAsString(); @@ -1515,7 +1515,7 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, } if (Introduced.isValid() && Obsoleted.isValid() && - !(Introduced.Version < Obsoleted.Version)) { + !(Introduced.Version <= Obsoleted.Version)) { S.Diag(Introduced.KeywordLoc, diag::warn_availability_version_ordering) << 2 << PlatformName << Obsoleted.Version.getAsString() << 0 << Introduced.Version.getAsString(); @@ -1523,7 +1523,7 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, } if (Deprecated.isValid() && Obsoleted.isValid() && - !(Deprecated.Version < Obsoleted.Version)) { + !(Deprecated.Version <= Obsoleted.Version)) { S.Diag(Deprecated.KeywordLoc, diag::warn_availability_version_ordering) << 2 << PlatformName << Obsoleted.Version.getAsString() << 1 << Deprecated.Version.getAsString(); diff --git a/test/Sema/attr-availability.c b/test/Sema/attr-availability.c index 1314cf5a5b..f6ed13190e 100644 --- a/test/Sema/attr-availability.c +++ b/test/Sema/attr-availability.c @@ -2,5 +2,6 @@ void f0() __attribute__((availability(macosx,introduced=10.4,deprecated=10.2))); // expected-warning{{feature cannot be deprecated in Mac OS X version 10.2 before it was introduced in version 10.4; attribute ignored}} void f1() __attribute__((availability(ios,obsoleted=2.1,deprecated=3.0))); // expected-warning{{feature cannot be obsoleted in iOS version 2.1 before it was deprecated in version 3.0; attribute ignored}} +void f2() __attribute__((availability(ios,introduced=2.1,deprecated=2.1))); -void f2() __attribute__((availability(otheros,introduced=2.2))); // expected-warning{{unknown platform 'otheros' in availability macro}} +void f3() __attribute__((availability(otheros,introduced=2.2))); // expected-warning{{unknown platform 'otheros' in availability macro}} -- 2.40.0