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 9319fb0..0eddb39 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.def
+++ b/include/clang/Basic/DiagnosticSemaKinds.def
@@ -873,7 +873,7 @@
      "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 989de0c..8b2e088 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -981,8 +981,7 @@
 }
 
 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 @@
     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 0e8a919..2554531 100644
--- a/test/Parser/objc-try-catch-1.m
+++ b/test/Parser/objc-try-catch-1.m
@@ -27,7 +27,7 @@
       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 d3be70c..16e119d 100644
--- a/test/SemaObjC/try-catch.m
+++ b/test/SemaObjC/try-catch.m
@@ -38,6 +38,10 @@
 @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}}
 }