]> granicus.if.org Git - clang/commitdiff
Upgrade "'X' is unavailable" from a warning to an error. This matches GCC's behavior...
authorTed Kremenek <kremenek@apple.com>
Wed, 21 Jul 2010 20:43:11 +0000 (20:43 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 21 Jul 2010 20:43:11 +0000 (20:43 +0000)
GCC emits a warning instead of an error when using an unavailable Objective-C protocol, so now
Clang's behavior is more strict in this case, but more consistent.  We will need to see how much
this fires on real code and determine whether this case should be downgraded to a warning.

Fixes <rdar://problem/8213093>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109033 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaExpr.cpp
test/SemaCXX/attr-unavailable.cpp
test/SemaObjC/protocol-attribute.m

index 24b326ae1f622163f40430333a8b87d3cbff3754..59bd8f8e384de38ac99e5860dedd00a68f4d8092 100644 (file)
@@ -1685,8 +1685,7 @@ def note_dependent_var_use : Note<"must qualify identifier to find this "
 def err_undeclared_use : Error<"use of undeclared %0">;
 def warn_deprecated : Warning<"%0 is deprecated">,
     InGroup<DeprecatedDeclarations>;
-def warn_unavailable : Warning<"%0 is unavailable">,
-    InGroup<DeprecatedDeclarations>;
+def err_unavailable : Error<"%0 is unavailable">;
 def note_unavailable_here : Note<
   "function has been explicitly marked %select{unavailable|deleted}0 here">;
 def warn_not_enough_argument : Warning<
index 73127df5ddc23d50f4e95fe318365c1b9706b518..58bc4f0801db8706c08d54dcefe768a85b5df471 100644 (file)
@@ -59,7 +59,7 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc) {
 
   // See if the decl is unavailable
   if (D->getAttr<UnavailableAttr>()) {
-    Diag(Loc, diag::warn_unavailable) << D->getDeclName();
+    Diag(Loc, diag::err_unavailable) << D->getDeclName();
     Diag(D->getLocation(), diag::note_unavailable_here) << 0;
   }
 
index 8b381dfe4b25b06cb67c59ce81092ad925457520..6f5aa5e78c4c639d479803d0077c996950baf098 100644 (file)
@@ -12,9 +12,9 @@ void test_foo(short* sp) {
   double &dr = foo(1.0);
   foo(sp); // expected-error{{call to unavailable function 'foo'}}
 
-  void (*fp)(...) = &bar; // expected-warning{{'bar' is unavailable}}
-  void (*fp2)(...) = bar; // expected-warning{{'bar' is unavailable}}
+  void (*fp)(...) = &bar; // expected-error{{'bar' is unavailable}}
+  void (*fp2)(...) = bar; // expected-error{{'bar' is unavailable}}
 
   int &(*fp3)(int) = foo;
-  void (*fp4)(...) = foo; // expected-warning{{'foo' is unavailable}}
+  void (*fp4)(...) = foo; // expected-error{{'foo' is unavailable}}
 }
index e04a39bda6ca140f9f91631d18829bceb5771588..52c980396eda873f989aa6f156358e71cfb8e82e 100644 (file)
@@ -3,7 +3,7 @@
 __attribute ((unavailable))
 @protocol FwProto; // expected-note{{marked unavailable}}
 
-Class <FwProto> cFw = 0;  // expected-warning {{'FwProto' is unavailable}}
+Class <FwProto> cFw = 0;  // expected-error {{'FwProto' is unavailable}}
 
 
 __attribute ((deprecated)) @protocol MyProto1
@@ -35,12 +35,12 @@ Class <MyProto1> clsP1 = 0;  // expected-warning {{'MyProto1' is deprecated}}
 
 @protocol FwProto @end // expected-note{{marked unavailable}}
 
-@interface MyClass2 <FwProto> // expected-warning {{'FwProto' is unavailable}}
+@interface MyClass2 <FwProto> // expected-error {{'FwProto' is unavailable}}
 @end
 
 __attribute ((unavailable)) __attribute ((deprecated)) @protocol XProto; // expected-note{{marked unavailable}}
 
-id <XProto> idX = 0; // expected-warning {{'XProto' is unavailable}} expected-warning {{'XProto' is deprecated}}
+id <XProto> idX = 0; // expected-error {{'XProto' is unavailable}} expected-warning {{'XProto' is deprecated}}
 
 int main ()
 {