From: Ted Kremenek Date: Wed, 21 Jul 2010 20:43:11 +0000 (+0000) Subject: Upgrade "'X' is unavailable" from a warning to an error. This matches GCC's behavior... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=042411cc447f9b120086a6e4650583044f66fd12;p=clang Upgrade "'X' is unavailable" from a warning to an error. This matches GCC's behavior. Note that 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 . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109033 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 24b326ae1f..59bd8f8e38 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -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; -def warn_unavailable : Warning<"%0 is unavailable">, - InGroup; +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< diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 73127df5dd..58bc4f0801 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -59,7 +59,7 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc) { // See if the decl is unavailable if (D->getAttr()) { - Diag(Loc, diag::warn_unavailable) << D->getDeclName(); + Diag(Loc, diag::err_unavailable) << D->getDeclName(); Diag(D->getLocation(), diag::note_unavailable_here) << 0; } diff --git a/test/SemaCXX/attr-unavailable.cpp b/test/SemaCXX/attr-unavailable.cpp index 8b381dfe4b..6f5aa5e78c 100644 --- a/test/SemaCXX/attr-unavailable.cpp +++ b/test/SemaCXX/attr-unavailable.cpp @@ -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}} } diff --git a/test/SemaObjC/protocol-attribute.m b/test/SemaObjC/protocol-attribute.m index e04a39bda6..52c980396e 100644 --- a/test/SemaObjC/protocol-attribute.m +++ b/test/SemaObjC/protocol-attribute.m @@ -3,7 +3,7 @@ __attribute ((unavailable)) @protocol FwProto; // expected-note{{marked unavailable}} -Class cFw = 0; // expected-warning {{'FwProto' is unavailable}} +Class cFw = 0; // expected-error {{'FwProto' is unavailable}} __attribute ((deprecated)) @protocol MyProto1 @@ -35,12 +35,12 @@ Class clsP1 = 0; // expected-warning {{'MyProto1' is deprecated}} @protocol FwProto @end // expected-note{{marked unavailable}} -@interface MyClass2 // expected-warning {{'FwProto' is unavailable}} +@interface MyClass2 // expected-error {{'FwProto' is unavailable}} @end __attribute ((unavailable)) __attribute ((deprecated)) @protocol XProto; // expected-note{{marked unavailable}} -id idX = 0; // expected-warning {{'XProto' is unavailable}} expected-warning {{'XProto' is deprecated}} +id idX = 0; // expected-error {{'XProto' is unavailable}} expected-warning {{'XProto' is deprecated}} int main () {