]> granicus.if.org Git - clang/commitdiff
Turn warning into error. Minor incompatibility with GCC (for scalar types, GCC only...
authorSteve Naroff <snaroff@apple.com>
Thu, 12 Feb 2009 15:54:59 +0000 (15:54 +0000)
committerSteve Naroff <snaroff@apple.com>
Thu, 12 Feb 2009 15:54:59 +0000 (15:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64375 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.def
lib/Sema/SemaStmt.cpp
test/Parser/objc-try-catch-1.m
test/SemaObjC/try-catch.m

index 9319fb0a4e4244c44ebb52c539c56aab0fd2244f..0eddb39e7dd5d718090ca4cda87fb840d72e9201 100644 (file)
@@ -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")
index 989de0cdbf7a7b44ada32b2fc401aee8eabf7b82..8b2e088b2e24559050bbaf7ac94b8cf353a1c2dd 100644 (file)
@@ -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*>(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();
     }
   }
index 0e8a91977d3eab9b9e12ab3a22611ec7db0eff3f..255453135b0169b80acf8b9c10c96c19b3afb496 100644 (file)
@@ -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());
index d3be70c74ab62884ac9693c8c3a931ed15ca3438..16e119db80c4bcefd69bdaa1622383a1b3d6befb 100644 (file)
@@ -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}}
 }