From: Steve Naroff Date: Thu, 12 Feb 2009 15:54:59 +0000 (+0000) Subject: Turn warning into error. Minor incompatibility with GCC (for scalar types, GCC only... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3dcfe10a6801eb52f4c20f1242bea0a3a98aa146;p=clang Turn warning into error. Minor incompatibility with GCC (for scalar types, GCC only produces a warning). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64375 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.def b/include/clang/Basic/DiagnosticSemaKinds.def index 9319fb0a4e..0eddb39e7d 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.def +++ b/include/clang/Basic/DiagnosticSemaKinds.def @@ -873,7 +873,7 @@ DIAG(warn_method_not_found_in_protocol, WARNING, "method %objcinstance0 not found in protocol (return type defaults to 'id')") DIAG(error_bad_receiver_type, ERROR, "bad receiver type %0") -DIAG(warn_objc_throw_expects_object, WARNING, +DIAG(error_objc_throw_expects_object, ERROR, "invalid %0 argument (expected an ObjC object type)") DIAG(error_rethrow_used_outside_catch, ERROR, "@throw (rethrow) used outside of a @catch block") diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 989de0cdbf..8b2e088b2e 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -981,8 +981,7 @@ Sema::ActOnObjCAtTryStmt(SourceLocation AtLoc, } Action::OwningStmtResult -Sema::ActOnObjCAtThrowStmt(SourceLocation AtLoc, ExprArg expr, - Scope *CurScope) { +Sema::ActOnObjCAtThrowStmt(SourceLocation AtLoc, ExprArg expr,Scope *CurScope) { Expr *ThrowExpr = static_cast(expr.release()); if (!ThrowExpr) { // @throw without an expression designates a rethrow (which much occur @@ -998,8 +997,7 @@ Sema::ActOnObjCAtThrowStmt(SourceLocation AtLoc, ExprArg expr, if (!Context.isObjCObjectPointerType(ThrowType)) { const PointerType *PT = ThrowType->getAsPointerType(); if (!PT || !PT->getPointeeType()->isVoidType()) - // This should be an error, however GCC only yields a warning. - Diag(AtLoc, diag::warn_objc_throw_expects_object) + Diag(AtLoc, diag::error_objc_throw_expects_object) << ThrowExpr->getType() << ThrowExpr->getSourceRange(); } } diff --git a/test/Parser/objc-try-catch-1.m b/test/Parser/objc-try-catch-1.m index 0e8a91977d..255453135b 100644 --- a/test/Parser/objc-try-catch-1.m +++ b/test/Parser/objc-try-catch-1.m @@ -27,7 +27,7 @@ void * foo() return proc(); } @catch (Frob* ex) { - @throw 1,2; // expected-warning {{invalid 'int' argument (expected an ObjC object type)}} + @throw 1,2; // expected-error {{invalid 'int' argument (expected an ObjC object type)}} } @catch(...) { @throw (4,3,proc()); diff --git a/test/SemaObjC/try-catch.m b/test/SemaObjC/try-catch.m index d3be70c74a..16e119db80 100644 --- a/test/SemaObjC/try-catch.m +++ b/test/SemaObjC/try-catch.m @@ -38,6 +38,10 @@ typedef struct _NSZone NSZone; @end int foo() { - @throw 42; // expected-warning {{invalid 'int' argument (expected an ObjC object type)}} + struct s { int a, b; } agg, *pagg; + + @throw 42; // expected-error {{invalid 'int' argument (expected an ObjC object type)}} + @throw agg; // expected-error {{invalid 'struct s' argument (expected an ObjC object type)}} + @throw pagg; // expected-error {{invalid 'struct s *' argument (expected an ObjC object type)}} @throw; // expected-error {{@throw (rethrow) used outside of a @catch block}} }