[1/3] C-family, Objective-C [1/3] : Implement Wobjc-root-class [PR77404].

Message ID EA3C03BF-BE1D-427C-BD4A-B96062F851B3@sandoe.co.uk
State New
Headers show
Series
  • [1/3] C-family, Objective-C [1/3] : Implement Wobjc-root-class [PR77404].
Related show

Commit Message

Iain Sandoe Nov. 12, 2020, 7:38 p.m.
Hi

This warning catches the case that the user has left the
superclass specification from a class interface.  Root
classes are, of course, permitted and an attribute is added
to mark these so that the diagnostic is suppressed.

The warning and attribute spellings have been kept in sync
with the language reference implementation (clang).

The diagnostic location information present in the objective-c
interface and class definitions is relatively poor.  This patch
adds a location for the class name to the interface and makes use
of it in existing warnings.

Part 1 is the changes to code and added tests.

Many entries in the testsuite make use of root classes so
there are a large number of mechanical changes there adding
"-Wno-objc-root-class" to the options.

The test changes are parts 2 (objective-c) and 3 (objective-c++)
in the patch series. (rather repetitive, attached, not inline).

tested on x86_64-darwin, x86_64-linux-gnu,
OK for the c-family parts?
(I believe the rest is trivial or within ObjC maintainer’s area).

thanks
Iain

+@end /* { dg-warning {class 'ARootObject' defined without specifying a  
base class} } */
-- 
2.24.1
From 5dc56a6c2a2ef6c4bf9d261fb355e96e06563982 Mon Sep 17 00:00:00 2001
From: Iain Sandoe <iain@sandoe.co.uk>

Date: Thu, 12 Nov 2020 13:11:11 +0000
Subject: [PATCH 2/3] Objective-C [2/3] : Implement Wobjc-root-class [PR77404].

Add "Wno-objc-root-class" to tests in the Objective-C suite where
needed.

gcc/testsuite/ChangeLog:

	PR objc/77404
	* objc.dg/anon-1.m: Add Wno-objc-root-class.
	* objc.dg/attributes/class-attribute-1.m: Likewise.
	* objc.dg/attributes/class-attribute-2.m: Likewise.
	* objc.dg/attributes/class-attribute-3.m: Likewise.
	* objc.dg/attributes/method-deprecated-1.m: Likewise.
	* objc.dg/attributes/method-deprecated-2.m: Likewise.
	* objc.dg/attributes/method-deprecated-3.m: Likewise.
	* objc.dg/attributes/method-format-1.m: Likewise.
	* objc.dg/attributes/method-nonnull-1.m: Likewise.
	* objc.dg/attributes/method-noreturn-1.m: Likewise.
	* objc.dg/attributes/method-sentinel-1.m: Likewise.
	* objc.dg/attributes/nsobject-01.m: Likewise.
	* objc.dg/attributes/objc-exception-1.m: Likewise.
	* objc.dg/attributes/parameter-attribute-1.m: Likewise.
	* objc.dg/attributes/parameter-attribute-2.m: Likewise.
	* objc.dg/attributes/proto-attribute-1.m: Likewise.
	* objc.dg/attributes/proto-attribute-2.m: Likewise.
	* objc.dg/attributes/proto-attribute-3.m: Likewise.
	* objc.dg/attributes/proto-attribute-4.m: Likewise.
	* objc.dg/bitfield-2.m: Likewise.
	* objc.dg/break-in-ifstmt.m: Likewise.
	* objc.dg/class-1.m: Likewise.
	* objc.dg/class-extension-1.m: Likewise.
	* objc.dg/class-extension-2.m: Likewise.
	* objc.dg/class-extension-3.m: Likewise.
	* objc.dg/class-extension-4.m: Likewise.
	* objc.dg/class-protocol-1.m: Likewise.
	* objc.dg/comp-types-7.m: Likewise.
	* objc.dg/demangle-1.m: Likewise.
	* objc.dg/duplicate-class-1.m: Likewise.
	* objc.dg/encode-6-next.m: Likewise.
	* objc.dg/encode-6.m: Likewise.
	* objc.dg/enhanced-proto-2.m: Likewise.
	* objc.dg/exceptions-1.m: Likewise.
	* objc.dg/exceptions-3.m: Likewise.
	* objc.dg/exceptions-4.m: Likewise.
	* objc.dg/exceptions-5.m: Likewise.
	* objc.dg/fobjc-std-1.m: Likewise.
	* objc.dg/foreach-2.m: Likewise.
	* objc.dg/foreach-4.m: Likewise.
	* objc.dg/foreach-5.m: Likewise.
	* objc.dg/fsyntax-only.m: Likewise.
	* objc.dg/gnu-api-2-class-meta.m: Likewise.
	* objc.dg/gnu-api-2-class.m: Likewise.
	* objc.dg/gnu-api-2-ivar.m: Likewise.
	* objc.dg/gnu-api-2-method.m: Likewise.
	* objc.dg/gnu-api-2-objc.m: Likewise.
	* objc.dg/gnu-api-2-objc_msg_lookup.m: Likewise.
	* objc.dg/gnu-api-2-object.m: Likewise.
	* objc.dg/gnu-api-2-property.m: Likewise.
	* objc.dg/gnu-api-2-protocol.m: Likewise.
	* objc.dg/gnu-api-2-resolve-method.m: Likewise.
	* objc.dg/gnu-api-2-sel.m: Likewise.
	* objc.dg/incomplete-type-1.m: Likewise.
	* objc.dg/instancetype-0.m: Likewise.
	* objc.dg/invalid-method-2.m: Likewise.
	* objc.dg/ivar-invalid-type-1.m: Likewise.
	* objc.dg/ivar-problem-1.m: Likewise.
	* objc.dg/ivar-scope-1.m: Likewise.
	* objc.dg/ivar-scope-2.m: Likewise.
	* objc.dg/ivar-scope-4.m: Likewise.
	* objc.dg/ivar-visibility-1.m: Likewise.
	* objc.dg/ivar-visibility-2.m: Likewise.
	* objc.dg/ivar-visibility-3.m: Likewise.
	* objc.dg/ivar-visibility-4.m: Likewise.
	* objc.dg/local-decl-1.m: Likewise.
	* objc.dg/lto/lto.exp: Likewise.
	* objc.dg/lto/trivial-1_0.m: Likewise.
	* objc.dg/method-1.m: Likewise.
	* objc.dg/method-12.m: Likewise.
	* objc.dg/method-13.m: Likewise.
	* objc.dg/method-14.m: Likewise.
	* objc.dg/missing-proto-3.m: Likewise.
	* objc.dg/next-runtime-1.m: Likewise.
	* objc.dg/objc-foreach-1.m: Likewise.
	* objc.dg/objc-foreach-2.m: Likewise.
	* objc.dg/objc-foreach-3.m: Likewise.
	* objc.dg/objc-nofilename-1.m: Likewise.
	* objc.dg/param-1.m: Likewise.
	* objc.dg/pch/pch.exp: Likewise.
	* objc.dg/plugin/diagnostic-test-expressions-1.m: Likewise.
	* objc.dg/pr23709.m: Likewise.
	* objc.dg/private-1.m: Likewise.
	* objc.dg/private-2.m: Likewise.
	* objc.dg/property/property.exp: Likewise.
	* objc.dg/proto-hier-1.m: Likewise.
	* objc.dg/proto-hier-2.m: Likewise.
	* objc.dg/proto-lossage-1.m: Likewise.
	* objc.dg/proto-lossage-5.m: Likewise.
	* objc.dg/proto-qual-1.m: Likewise.
	* objc.dg/protocol-inheritance-1.m: Likewise.
	* objc.dg/protocol-inheritance-2.m: Likewise.
	* objc.dg/protocol-optional-1.m: Likewise.
	* objc.dg/selector-1.m: Likewise.
	* objc.dg/selector-2.m: Likewise.
	* objc.dg/selector-3.m: Likewise.
	* objc.dg/selector-4.m: Likewise.
	* objc.dg/shadow-1.m: Likewise.
	* objc.dg/shadow-2.m: Likewise.
	* objc.dg/special/load-category-1.m: Likewise.
	* objc.dg/special/load-category-2.m: Likewise.
	* objc.dg/special/load-category-3.m: Likewise.
	* objc.dg/special/special.exp: Likewise.
	* objc.dg/special/unclaimed-category-1.h: Likewise.
	* objc.dg/special/unclaimed-category-1.m: Likewise.
	* objc.dg/stabs-1.m: Likewise.
	* objc.dg/strings/strings.exp: Likewise.
	* objc.dg/stubify-1.m: Likewise.
	* objc.dg/stubify-2.m: Likewise.
	* objc.dg/super-class-2.m: Likewise.
	* objc.dg/super-dealloc-1.m: Likewise.
	* objc.dg/super-dealloc-2.m: Likewise.
	* objc.dg/sync-3.m: Likewise.
	* objc.dg/threedotthree-abi-1.m: Likewise.
	* objc.dg/torture/dg-torture.exp: Likewise.
	* objc.dg/torture/strings/strings.exp: Likewise.
	* objc.dg/try-catch-11.m: Likewise.
	* objc.dg/try-catch-12.m: Likewise.
	* objc.dg/type-size-2.m: Likewise.
	* objc.dg/type-size-3.m: Likewise.
	* objc.dg/type-size-4.m: Likewise.
	* objc.dg/type-size-5.m: Likewise.
	* objc.dg/undeclared-selector.m: Likewise.
	* objc.dg/volatile-1.m: Likewise.
---
 gcc/testsuite/objc.dg/anon-1.m                   |  1 +
 .../objc.dg/attributes/class-attribute-1.m       |  1 +
 .../objc.dg/attributes/class-attribute-2.m       |  1 +
 .../objc.dg/attributes/class-attribute-3.m       |  1 +
 .../objc.dg/attributes/method-deprecated-1.m     |  1 +
 .../objc.dg/attributes/method-deprecated-2.m     |  1 +
 .../objc.dg/attributes/method-deprecated-3.m     |  1 +
 .../objc.dg/attributes/method-format-1.m         |  1 +
 .../objc.dg/attributes/method-nonnull-1.m        |  1 +
 .../objc.dg/attributes/method-noreturn-1.m       |  1 +
 .../objc.dg/attributes/method-sentinel-1.m       |  1 +
 gcc/testsuite/objc.dg/attributes/nsobject-01.m   |  1 +
 .../objc.dg/attributes/objc-exception-1.m        |  1 +
 .../objc.dg/attributes/parameter-attribute-1.m   |  1 +
 .../objc.dg/attributes/parameter-attribute-2.m   |  1 +
 .../objc.dg/attributes/proto-attribute-1.m       |  1 +
 .../objc.dg/attributes/proto-attribute-2.m       |  1 +
 .../objc.dg/attributes/proto-attribute-3.m       |  1 +
 .../objc.dg/attributes/proto-attribute-4.m       |  1 +
 gcc/testsuite/objc.dg/bitfield-2.m               |  1 +
 gcc/testsuite/objc.dg/break-in-ifstmt.m          |  1 +
 gcc/testsuite/objc.dg/class-1.m                  |  4 ++++
 gcc/testsuite/objc.dg/class-extension-1.m        |  1 +
 gcc/testsuite/objc.dg/class-extension-2.m        |  1 +
 gcc/testsuite/objc.dg/class-extension-3.m        |  1 +
 gcc/testsuite/objc.dg/class-extension-4.m        |  1 +
 gcc/testsuite/objc.dg/class-protocol-1.m         |  1 +
 gcc/testsuite/objc.dg/comp-types-7.m             |  1 +
 gcc/testsuite/objc.dg/demangle-1.m               |  1 +
 gcc/testsuite/objc.dg/duplicate-class-1.m        |  1 +
 gcc/testsuite/objc.dg/encode-6-next.m            |  1 +
 gcc/testsuite/objc.dg/encode-6.m                 |  1 +
 gcc/testsuite/objc.dg/enhanced-proto-2.m         |  1 +
 gcc/testsuite/objc.dg/exceptions-1.m             |  1 +
 gcc/testsuite/objc.dg/exceptions-3.m             |  1 +
 gcc/testsuite/objc.dg/exceptions-4.m             |  1 +
 gcc/testsuite/objc.dg/exceptions-5.m             |  1 +
 gcc/testsuite/objc.dg/fobjc-std-1.m              |  5 +++--
 gcc/testsuite/objc.dg/foreach-2.m                |  1 +
 gcc/testsuite/objc.dg/foreach-4.m                |  1 +
 gcc/testsuite/objc.dg/foreach-5.m                |  1 +
 gcc/testsuite/objc.dg/fsyntax-only.m             |  3 +++
 gcc/testsuite/objc.dg/gnu-api-2-class-meta.m     |  4 +---
 gcc/testsuite/objc.dg/gnu-api-2-class.m          |  1 +
 gcc/testsuite/objc.dg/gnu-api-2-ivar.m           |  1 +
 gcc/testsuite/objc.dg/gnu-api-2-method.m         |  1 +
 gcc/testsuite/objc.dg/gnu-api-2-objc.m           |  1 +
 .../objc.dg/gnu-api-2-objc_msg_lookup.m          |  1 +
 gcc/testsuite/objc.dg/gnu-api-2-object.m         |  1 +
 gcc/testsuite/objc.dg/gnu-api-2-property.m       |  1 +
 gcc/testsuite/objc.dg/gnu-api-2-protocol.m       |  1 +
 gcc/testsuite/objc.dg/gnu-api-2-resolve-method.m |  1 +
 gcc/testsuite/objc.dg/gnu-api-2-sel.m            |  1 +
 gcc/testsuite/objc.dg/incomplete-type-1.m        |  3 +++
 gcc/testsuite/objc.dg/instancetype-0.m           |  3 +++
 gcc/testsuite/objc.dg/invalid-method-2.m         |  3 +++
 gcc/testsuite/objc.dg/ivar-invalid-type-1.m      |  3 +++
 gcc/testsuite/objc.dg/ivar-problem-1.m           |  6 ++++++
 gcc/testsuite/objc.dg/ivar-scope-1.m             |  3 +++
 gcc/testsuite/objc.dg/ivar-scope-2.m             |  3 +++
 gcc/testsuite/objc.dg/ivar-scope-4.m             |  3 ++-
 gcc/testsuite/objc.dg/ivar-visibility-1.m        |  1 +
 gcc/testsuite/objc.dg/ivar-visibility-2.m        |  2 +-
 gcc/testsuite/objc.dg/ivar-visibility-3.m        |  2 +-
 gcc/testsuite/objc.dg/ivar-visibility-4.m        |  2 +-
 gcc/testsuite/objc.dg/local-decl-1.m             |  1 +
 gcc/testsuite/objc.dg/lto/lto.exp                | 16 ++++++++--------
 gcc/testsuite/objc.dg/lto/trivial-1_0.m          |  4 ++--
 gcc/testsuite/objc.dg/method-1.m                 |  1 +
 gcc/testsuite/objc.dg/method-12.m                |  1 +
 gcc/testsuite/objc.dg/method-13.m                |  1 +
 gcc/testsuite/objc.dg/method-14.m                |  1 +
 gcc/testsuite/objc.dg/missing-proto-3.m          |  3 ++-
 gcc/testsuite/objc.dg/next-runtime-1.m           |  1 +
 gcc/testsuite/objc.dg/objc-foreach-1.m           |  1 +
 gcc/testsuite/objc.dg/objc-foreach-2.m           |  1 +
 gcc/testsuite/objc.dg/objc-foreach-3.m           |  1 +
 gcc/testsuite/objc.dg/objc-nofilename-1.m        |  1 +
 gcc/testsuite/objc.dg/param-1.m                  |  1 +
 gcc/testsuite/objc.dg/pch/pch.exp                |  4 ++--
 .../plugin/diagnostic-test-expressions-1.m       |  2 +-
 gcc/testsuite/objc.dg/pr23709.m                  |  1 +
 gcc/testsuite/objc.dg/private-1.m                |  1 +
 gcc/testsuite/objc.dg/private-2.m                |  1 +
 gcc/testsuite/objc.dg/property/property.exp      |  4 ++--
 gcc/testsuite/objc.dg/proto-hier-1.m             |  1 +
 gcc/testsuite/objc.dg/proto-hier-2.m             |  1 +
 gcc/testsuite/objc.dg/proto-lossage-1.m          |  1 +
 gcc/testsuite/objc.dg/proto-lossage-5.m          |  1 +
 gcc/testsuite/objc.dg/proto-qual-1.m             |  1 +
 gcc/testsuite/objc.dg/protocol-inheritance-1.m   |  1 +
 gcc/testsuite/objc.dg/protocol-inheritance-2.m   |  1 +
 gcc/testsuite/objc.dg/protocol-optional-1.m      |  1 +
 gcc/testsuite/objc.dg/selector-1.m               |  1 +
 gcc/testsuite/objc.dg/selector-2.m               |  1 +
 gcc/testsuite/objc.dg/selector-3.m               |  1 +
 gcc/testsuite/objc.dg/selector-4.m               |  1 +
 gcc/testsuite/objc.dg/shadow-1.m                 |  1 +
 gcc/testsuite/objc.dg/shadow-2.m                 |  1 +
 gcc/testsuite/objc.dg/special/load-category-1.m  |  1 +
 gcc/testsuite/objc.dg/special/load-category-2.m  |  1 +
 gcc/testsuite/objc.dg/special/load-category-3.m  |  1 +
 gcc/testsuite/objc.dg/special/special.exp        |  8 ++++++++
 .../objc.dg/special/unclaimed-category-1.h       |  1 +
 .../objc.dg/special/unclaimed-category-1.m       |  1 +
 gcc/testsuite/objc.dg/stabs-1.m                  |  1 +
 gcc/testsuite/objc.dg/strings/strings.exp        |  4 ++--
 gcc/testsuite/objc.dg/stubify-1.m                |  1 +
 gcc/testsuite/objc.dg/stubify-2.m                |  1 +
 gcc/testsuite/objc.dg/super-class-2.m            |  1 +
 gcc/testsuite/objc.dg/super-dealloc-1.m          |  1 +
 gcc/testsuite/objc.dg/super-dealloc-2.m          |  1 +
 gcc/testsuite/objc.dg/sync-3.m                   |  1 +
 gcc/testsuite/objc.dg/threedotthree-abi-1.m      |  1 +
 gcc/testsuite/objc.dg/torture/dg-torture.exp     |  4 ++--
 .../objc.dg/torture/strings/strings.exp          |  4 ++--
 gcc/testsuite/objc.dg/try-catch-11.m             |  1 +
 gcc/testsuite/objc.dg/try-catch-12.m             |  1 +
 gcc/testsuite/objc.dg/type-size-2.m              |  1 +
 gcc/testsuite/objc.dg/type-size-3.m              |  1 +
 gcc/testsuite/objc.dg/type-size-4.m              |  1 +
 gcc/testsuite/objc.dg/type-size-5.m              |  1 +
 gcc/testsuite/objc.dg/undeclared-selector.m      |  1 +
 gcc/testsuite/objc.dg/volatile-1.m               |  3 ++-
 124 files changed, 171 insertions(+), 32 deletions(-)

diff --git a/gcc/testsuite/objc.dg/anon-1.m b/gcc/testsuite/objc.dg/anon-1.m
index 5f10f7d6026..5dab3fa142d 100644
--- a/gcc/testsuite/objc.dg/anon-1.m
+++ b/gcc/testsuite/objc.dg/anon-1.m
@@ -1,5 +1,6 @@
 /* Test for graceful handling of anonymous ivars.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 @interface Foo {
    unsigned char : 1;
diff --git a/gcc/testsuite/objc.dg/attributes/class-attribute-1.m b/gcc/testsuite/objc.dg/attributes/class-attribute-1.m
index 3444760bc3d..93e5d7f40ae 100644
--- a/gcc/testsuite/objc.dg/attributes/class-attribute-1.m
+++ b/gcc/testsuite/objc.dg/attributes/class-attribute-1.m
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* Test deprecate attribute with an @interface declaration.  */
 
diff --git a/gcc/testsuite/objc.dg/attributes/class-attribute-2.m b/gcc/testsuite/objc.dg/attributes/class-attribute-2.m
index 2e1bacb3fa0..f8137ffb4c4 100644
--- a/gcc/testsuite/objc.dg/attributes/class-attribute-2.m
+++ b/gcc/testsuite/objc.dg/attributes/class-attribute-2.m
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/objc.dg/attributes/class-attribute-3.m b/gcc/testsuite/objc.dg/attributes/class-attribute-3.m
index 6cc5d4e2681..7c3b3b0e006 100644
--- a/gcc/testsuite/objc.dg/attributes/class-attribute-3.m
+++ b/gcc/testsuite/objc.dg/attributes/class-attribute-3.m
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* Test that you get a warning when an unknown class attribute is ignored.  */
 
diff --git a/gcc/testsuite/objc.dg/attributes/method-deprecated-1.m b/gcc/testsuite/objc.dg/attributes/method-deprecated-1.m
index 8343856a5c6..68e8373920d 100644
--- a/gcc/testsuite/objc.dg/attributes/method-deprecated-1.m
+++ b/gcc/testsuite/objc.dg/attributes/method-deprecated-1.m
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/objc.dg/attributes/method-deprecated-2.m b/gcc/testsuite/objc.dg/attributes/method-deprecated-2.m
index 1e5d87f3e63..8fb0e1510d0 100644
--- a/gcc/testsuite/objc.dg/attributes/method-deprecated-2.m
+++ b/gcc/testsuite/objc.dg/attributes/method-deprecated-2.m
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/objc.dg/attributes/method-deprecated-3.m b/gcc/testsuite/objc.dg/attributes/method-deprecated-3.m
index 5c715a20b68..efa2d349557 100644
--- a/gcc/testsuite/objc.dg/attributes/method-deprecated-3.m
+++ b/gcc/testsuite/objc.dg/attributes/method-deprecated-3.m
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/objc.dg/attributes/method-format-1.m b/gcc/testsuite/objc.dg/attributes/method-format-1.m
index 9ff34f92fb1..d3bb997b2aa 100644
--- a/gcc/testsuite/objc.dg/attributes/method-format-1.m
+++ b/gcc/testsuite/objc.dg/attributes/method-format-1.m
@@ -1,6 +1,7 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010.  */
 /* { dg-do compile } */
 /* { dg-options "-Wall" } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 #include <stdlib.h>
diff --git a/gcc/testsuite/objc.dg/attributes/method-nonnull-1.m b/gcc/testsuite/objc.dg/attributes/method-nonnull-1.m
index fe5f885b2d4..a3bfd9bc3c6 100644
--- a/gcc/testsuite/objc.dg/attributes/method-nonnull-1.m
+++ b/gcc/testsuite/objc.dg/attributes/method-nonnull-1.m
@@ -1,6 +1,7 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, May 2011.  */
 /* { dg-do compile } */
 /* { dg-options "-Wall" } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 #include <stdlib.h>
diff --git a/gcc/testsuite/objc.dg/attributes/method-noreturn-1.m b/gcc/testsuite/objc.dg/attributes/method-noreturn-1.m
index a83048bb7ed..413a0be4b2b 100644
--- a/gcc/testsuite/objc.dg/attributes/method-noreturn-1.m
+++ b/gcc/testsuite/objc.dg/attributes/method-noreturn-1.m
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 #include <stdlib.h>
diff --git a/gcc/testsuite/objc.dg/attributes/method-sentinel-1.m b/gcc/testsuite/objc.dg/attributes/method-sentinel-1.m
index e2abb1e8a1d..f89c98121b9 100644
--- a/gcc/testsuite/objc.dg/attributes/method-sentinel-1.m
+++ b/gcc/testsuite/objc.dg/attributes/method-sentinel-1.m
@@ -1,6 +1,7 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010.  */
 /* { dg-do compile } */
 /* { dg-options "-Wall" } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 #include <stdlib.h>
diff --git a/gcc/testsuite/objc.dg/attributes/nsobject-01.m b/gcc/testsuite/objc.dg/attributes/nsobject-01.m
index 5b568490391..1f331508a89 100644
--- a/gcc/testsuite/objc.dg/attributes/nsobject-01.m
+++ b/gcc/testsuite/objc.dg/attributes/nsobject-01.m
@@ -1,5 +1,6 @@
 /* Test handling of the NSObject attribute.  */
 /*  { dg-additional-options "-fsyntax-only " } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 typedef struct AnObj * __attribute__ ((NSObject)) AnObjRef;
 typedef struct AnObj * __attribute__ ((__NSObject__)) AnotherObjRef;
diff --git a/gcc/testsuite/objc.dg/attributes/objc-exception-1.m b/gcc/testsuite/objc.dg/attributes/objc-exception-1.m
index e7f6f856f8f..19e5ade8bcd 100644
--- a/gcc/testsuite/objc.dg/attributes/objc-exception-1.m
+++ b/gcc/testsuite/objc.dg/attributes/objc-exception-1.m
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, February 2011.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* Test that the 'objc_exception' attribute is accepted for
    @interfaces, but not for anything else.  */
diff --git a/gcc/testsuite/objc.dg/attributes/parameter-attribute-1.m b/gcc/testsuite/objc.dg/attributes/parameter-attribute-1.m
index 8263df66db9..d6ebaf227f3 100644
--- a/gcc/testsuite/objc.dg/attributes/parameter-attribute-1.m
+++ b/gcc/testsuite/objc.dg/attributes/parameter-attribute-1.m
@@ -1,6 +1,7 @@
 /* Test __attribute__((unused)) for an Objective-C method parameter.  */
 /* { dg-do compile } */
 /* { dg-options "-Wunused-parameter" } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/objc.dg/attributes/parameter-attribute-2.m b/gcc/testsuite/objc.dg/attributes/parameter-attribute-2.m
index 99c5a308b8c..637846d4a08 100644
--- a/gcc/testsuite/objc.dg/attributes/parameter-attribute-2.m
+++ b/gcc/testsuite/objc.dg/attributes/parameter-attribute-2.m
@@ -1,5 +1,6 @@
 /* Test that we get warnings for unrecognized attributes.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/objc.dg/attributes/proto-attribute-1.m b/gcc/testsuite/objc.dg/attributes/proto-attribute-1.m
index a852a7a6c2f..03726dc7bed 100644
--- a/gcc/testsuite/objc.dg/attributes/proto-attribute-1.m
+++ b/gcc/testsuite/objc.dg/attributes/proto-attribute-1.m
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/objc.dg/attributes/proto-attribute-2.m b/gcc/testsuite/objc.dg/attributes/proto-attribute-2.m
index b23b81de20c..6a73d248ee8 100644
--- a/gcc/testsuite/objc.dg/attributes/proto-attribute-2.m
+++ b/gcc/testsuite/objc.dg/attributes/proto-attribute-2.m
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* Test deprecate attribute with a forward declarations of
    @protocol.  */
diff --git a/gcc/testsuite/objc.dg/attributes/proto-attribute-3.m b/gcc/testsuite/objc.dg/attributes/proto-attribute-3.m
index 2be286ecfb7..ad6d0c804b1 100644
--- a/gcc/testsuite/objc.dg/attributes/proto-attribute-3.m
+++ b/gcc/testsuite/objc.dg/attributes/proto-attribute-3.m
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* Test deprecate attribute with normal @protocol declarations.  */
 
diff --git a/gcc/testsuite/objc.dg/attributes/proto-attribute-4.m b/gcc/testsuite/objc.dg/attributes/proto-attribute-4.m
index 226fd68b3f2..8d34ebdcc2f 100644
--- a/gcc/testsuite/objc.dg/attributes/proto-attribute-4.m
+++ b/gcc/testsuite/objc.dg/attributes/proto-attribute-4.m
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* Test that you get a warning when an unknown protocol attribute is ignored.  */
 
diff --git a/gcc/testsuite/objc.dg/bitfield-2.m b/gcc/testsuite/objc.dg/bitfield-2.m
index 7e8147a7008..b28c81e0569 100644
--- a/gcc/testsuite/objc.dg/bitfield-2.m
+++ b/gcc/testsuite/objc.dg/bitfield-2.m
@@ -4,6 +4,7 @@
 /* { dg-options "-fsigned-char" } */
 /* { dg-do run { target *-*-darwin* } } */
 /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 typedef struct objc_object { struct objc_class *class_pointer; } *id;
 
diff --git a/gcc/testsuite/objc.dg/break-in-ifstmt.m b/gcc/testsuite/objc.dg/break-in-ifstmt.m
index 896849472a7..6176832ed1c 100644
--- a/gcc/testsuite/objc.dg/break-in-ifstmt.m
+++ b/gcc/testsuite/objc.dg/break-in-ifstmt.m
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 @interface foo
 - (void) test;
diff --git a/gcc/testsuite/objc.dg/class-1.m b/gcc/testsuite/objc.dg/class-1.m
index 05049373fa4..64383f22d99 100644
--- a/gcc/testsuite/objc.dg/class-1.m
+++ b/gcc/testsuite/objc.dg/class-1.m
@@ -1,5 +1,6 @@
 /* Redeclarations of class names.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 typedef int foo; /* { dg-line foo_def } */
 
@@ -8,6 +9,9 @@ typedef int foo; /* { dg-line foo_def } */
 
 typedef int bar; /* { dg-line bar_def } */
 
+#if defined(__has_attribute) && __has_attribute(objc_root_class)
+__attribute__((objc_root_class))
+#endif
 @interface bar
 @end  /* { dg-error "redeclared as different kind of symbol" } */
 /* { dg-error "previous declaration of" "" { target *-*-* } bar_def } */
diff --git a/gcc/testsuite/objc.dg/class-extension-1.m b/gcc/testsuite/objc.dg/class-extension-1.m
index 5c89a9838cf..9d6658a6399 100644
--- a/gcc/testsuite/objc.dg/class-extension-1.m
+++ b/gcc/testsuite/objc.dg/class-extension-1.m
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* This test tests the basic of class extensions.  */
 
diff --git a/gcc/testsuite/objc.dg/class-extension-2.m b/gcc/testsuite/objc.dg/class-extension-2.m
index 7f55b601fb3..293facb189f 100644
--- a/gcc/testsuite/objc.dg/class-extension-2.m
+++ b/gcc/testsuite/objc.dg/class-extension-2.m
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* This test tests class extensions and protocols.  */
 
diff --git a/gcc/testsuite/objc.dg/class-extension-3.m b/gcc/testsuite/objc.dg/class-extension-3.m
index 69e57053969..51fe5eef083 100644
--- a/gcc/testsuite/objc.dg/class-extension-3.m
+++ b/gcc/testsuite/objc.dg/class-extension-3.m
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* This test tests warnings on class extensions.  */
 
diff --git a/gcc/testsuite/objc.dg/class-extension-4.m b/gcc/testsuite/objc.dg/class-extension-4.m
index 692a0fcbd0a..5d367d40bd5 100644
--- a/gcc/testsuite/objc.dg/class-extension-4.m
+++ b/gcc/testsuite/objc.dg/class-extension-4.m
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* This test tests you can not declare a class extension after the class @implementation.  */
 
diff --git a/gcc/testsuite/objc.dg/class-protocol-1.m b/gcc/testsuite/objc.dg/class-protocol-1.m
index 59c8f827615..34680c2ef3a 100644
--- a/gcc/testsuite/objc.dg/class-protocol-1.m
+++ b/gcc/testsuite/objc.dg/class-protocol-1.m
@@ -1,6 +1,7 @@
 /* Check Class <protocol> types */
 /* Author: David Ayers <d.ayers@inode.at> */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 #include "../objc-obj-c++-shared/runtime.h"
diff --git a/gcc/testsuite/objc.dg/comp-types-7.m b/gcc/testsuite/objc.dg/comp-types-7.m
index 526934fbb82..6b796f09b29 100644
--- a/gcc/testsuite/objc.dg/comp-types-7.m
+++ b/gcc/testsuite/objc.dg/comp-types-7.m
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 /* We used to ICE because we removed the cast to List_linked*
    in -[ListIndex_linked next]. */
 
diff --git a/gcc/testsuite/objc.dg/demangle-1.m b/gcc/testsuite/objc.dg/demangle-1.m
index 42b79a9eb0a..61e79a69976 100644
--- a/gcc/testsuite/objc.dg/demangle-1.m
+++ b/gcc/testsuite/objc.dg/demangle-1.m
@@ -1,6 +1,7 @@
 /* Test demangling an Objective-C method.  */
 /* { dg-do run } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <string.h>
 #include <stdlib.h>
diff --git a/gcc/testsuite/objc.dg/duplicate-class-1.m b/gcc/testsuite/objc.dg/duplicate-class-1.m
index 30a18ffa5a6..7992ebf978c 100644
--- a/gcc/testsuite/objc.dg/duplicate-class-1.m
+++ b/gcc/testsuite/objc.dg/duplicate-class-1.m
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* Test that a duplicated @implementation for the same class does not
    crash the compiler.  */
diff --git a/gcc/testsuite/objc.dg/encode-6-next.m b/gcc/testsuite/objc.dg/encode-6-next.m
index c3d922659aa..18ee15db446 100644
--- a/gcc/testsuite/objc.dg/encode-6-next.m
+++ b/gcc/testsuite/objc.dg/encode-6-next.m
@@ -2,6 +2,7 @@
 /* Author: Ziemowit Laski  <zlaski@apple.com>  */
 /* { dg-do compile } */
 /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 struct Cxx {
   const struct Cxx *next;
diff --git a/gcc/testsuite/objc.dg/encode-6.m b/gcc/testsuite/objc.dg/encode-6.m
index 291a41e96a0..9e9e4925c5e 100644
--- a/gcc/testsuite/objc.dg/encode-6.m
+++ b/gcc/testsuite/objc.dg/encode-6.m
@@ -2,6 +2,7 @@
 /* Author: Ziemowit Laski  <zlaski@apple.com>  */
 /* { dg-do compile } */
 /* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 struct Cxx {
   const struct Cxx *next;
diff --git a/gcc/testsuite/objc.dg/enhanced-proto-2.m b/gcc/testsuite/objc.dg/enhanced-proto-2.m
index c196b5151c9..ca99445df40 100644
--- a/gcc/testsuite/objc.dg/enhanced-proto-2.m
+++ b/gcc/testsuite/objc.dg/enhanced-proto-2.m
@@ -1,5 +1,6 @@
 /* Test use of @optional/@required keywords in @protocol class. */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 @protocol MyProto1 
 @optional
diff --git a/gcc/testsuite/objc.dg/exceptions-1.m b/gcc/testsuite/objc.dg/exceptions-1.m
index 0f3b7e8ae14..1e861773b96 100644
--- a/gcc/testsuite/objc.dg/exceptions-1.m
+++ b/gcc/testsuite/objc.dg/exceptions-1.m
@@ -1,6 +1,7 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
 /* { dg-options "-fobjc-exceptions" } */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* This test checks the syntax @catch (...) which catches any
    exceptions.  At the moment, @catch (...) is identical to @catch (id
diff --git a/gcc/testsuite/objc.dg/exceptions-3.m b/gcc/testsuite/objc.dg/exceptions-3.m
index 69a6494e048..bedaf53ee83 100644
--- a/gcc/testsuite/objc.dg/exceptions-3.m
+++ b/gcc/testsuite/objc.dg/exceptions-3.m
@@ -1,6 +1,7 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
 /* { dg-options "-fobjc-exceptions" } */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* Test that the compiler is checking the argument of @catch(), and
    produce errors when invalid types are used.  */
diff --git a/gcc/testsuite/objc.dg/exceptions-4.m b/gcc/testsuite/objc.dg/exceptions-4.m
index bbdb741f40b..5d77ffa61d2 100644
--- a/gcc/testsuite/objc.dg/exceptions-4.m
+++ b/gcc/testsuite/objc.dg/exceptions-4.m
@@ -1,6 +1,7 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
 /* { dg-options "-fobjc-exceptions" } */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* Test warnings when parsing syntax errors in @catch().  */
 
diff --git a/gcc/testsuite/objc.dg/exceptions-5.m b/gcc/testsuite/objc.dg/exceptions-5.m
index 55ef0f340e6..31796bc4c5c 100644
--- a/gcc/testsuite/objc.dg/exceptions-5.m
+++ b/gcc/testsuite/objc.dg/exceptions-5.m
@@ -1,6 +1,7 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
 /* { dg-options "-fobjc-exceptions" } */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* Test that you can use an unnamed argument with @catch.  This test is the same
    as exceptions-3.m, but with no name for @catch arguments.  */
diff --git a/gcc/testsuite/objc.dg/fobjc-std-1.m b/gcc/testsuite/objc.dg/fobjc-std-1.m
index 9a15b8af5da..729f65c5ea6 100644
--- a/gcc/testsuite/objc.dg/fobjc-std-1.m
+++ b/gcc/testsuite/objc.dg/fobjc-std-1.m
@@ -1,6 +1,7 @@
 /* Test warnings when using -fobjc-std=objc1.  */
 /* { dg-do compile } */
 /* { dg-options "-fobjc-std=objc1" } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
@@ -29,8 +30,8 @@
 @end
 
 __attribute__ ((deprecated))
-@interface MyRootClass2
-{  /* { dg-error "class attributes are not available in Objective.C 1.0" } */
+@interface MyRootClass2 /* { dg-error "class attributes are not available in Objective.C 1.0" } */
+{  
   Class isa;
 }
 @end
diff --git a/gcc/testsuite/objc.dg/foreach-2.m b/gcc/testsuite/objc.dg/foreach-2.m
index 93bc9028463..ccce557482f 100644
--- a/gcc/testsuite/objc.dg/foreach-2.m
+++ b/gcc/testsuite/objc.dg/foreach-2.m
@@ -6,6 +6,7 @@
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
 /* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
 /* { dg-additional-sources "../objc-obj-c++-shared/nsconstantstring-class-impl.m" } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include "../objc-obj-c++-shared/TestsuiteObject.m"
 #ifndef __NEXT_RUNTIME__
diff --git a/gcc/testsuite/objc.dg/foreach-4.m b/gcc/testsuite/objc.dg/foreach-4.m
index faee73b8223..23656090c3c 100644
--- a/gcc/testsuite/objc.dg/foreach-4.m
+++ b/gcc/testsuite/objc.dg/foreach-4.m
@@ -6,6 +6,7 @@
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
 /* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
 /* { dg-additional-sources "../objc-obj-c++-shared/nsconstantstring-class-impl.m" } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #import "../objc-obj-c++-shared/TestsuiteObject.m"
 #ifndef __NEXT_RUNTIME__
diff --git a/gcc/testsuite/objc.dg/foreach-5.m b/gcc/testsuite/objc.dg/foreach-5.m
index dce26fa3e93..1bcb10b6faf 100644
--- a/gcc/testsuite/objc.dg/foreach-5.m
+++ b/gcc/testsuite/objc.dg/foreach-5.m
@@ -6,6 +6,7 @@
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
 /* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
 /* { dg-additional-sources "../objc-obj-c++-shared/nsconstantstring-class-impl.m" } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #import "../objc-obj-c++-shared/TestsuiteObject.m"
 #ifndef __NEXT_RUNTIME__
diff --git a/gcc/testsuite/objc.dg/fsyntax-only.m b/gcc/testsuite/objc.dg/fsyntax-only.m
index 54a879e22c5..70ea8ace43d 100644
--- a/gcc/testsuite/objc.dg/fsyntax-only.m
+++ b/gcc/testsuite/objc.dg/fsyntax-only.m
@@ -2,6 +2,9 @@
 /* { dg-do compile } */
 /* { dg-options "-fsyntax-only" } */
 
+#if defined(__has_attribute) && __has_attribute(objc_root_class)
+__attribute__((objc_root_class))
+#endif
 @interface foo
 -(void) my_method:(int) i with:(int) j;
 @end
diff --git a/gcc/testsuite/objc.dg/gnu-api-2-class-meta.m b/gcc/testsuite/objc.dg/gnu-api-2-class-meta.m
index 3a85b163c91..6c1c76a87a3 100644
--- a/gcc/testsuite/objc.dg/gnu-api-2-class-meta.m
+++ b/gcc/testsuite/objc.dg/gnu-api-2-class-meta.m
@@ -20,6 +20,7 @@
 /* { dg-do run } */
 /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 /* { dg-additional-options "-DOBJC_OLD_DISPATCH_PROTOTYPES" { target { *-*-darwin* } } } */
 
 /* To get the modern GNU Objective-C Runtime API, you include
@@ -29,9 +30,6 @@
 #include <stdio.h>
 #include <string.h>
 
-#if __has_attribute(objc_root_class)
-__attribute__((objc_root_class))
-#endif
 @interface MyRootClass
 { Class isa; }
 + alloc;
diff --git a/gcc/testsuite/objc.dg/gnu-api-2-class.m b/gcc/testsuite/objc.dg/gnu-api-2-class.m
index eade0dcbbfa..d11dae0e6dc 100644
--- a/gcc/testsuite/objc.dg/gnu-api-2-class.m
+++ b/gcc/testsuite/objc.dg/gnu-api-2-class.m
@@ -7,6 +7,7 @@
 /* { dg-do run } */
 /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 /* { dg-additional-options "-DOBJC_OLD_DISPATCH_PROTOTYPES" { target { *-*-darwin* } } } */
 
 /* To get the modern GNU Objective-C Runtime API, you include
diff --git a/gcc/testsuite/objc.dg/gnu-api-2-ivar.m b/gcc/testsuite/objc.dg/gnu-api-2-ivar.m
index 19ac004e7b1..072d2655bb8 100644
--- a/gcc/testsuite/objc.dg/gnu-api-2-ivar.m
+++ b/gcc/testsuite/objc.dg/gnu-api-2-ivar.m
@@ -5,6 +5,7 @@
 /* { dg-do run } */
 /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* To get the modern GNU Objective-C Runtime API, you include
    objc/runtime.h.  */
diff --git a/gcc/testsuite/objc.dg/gnu-api-2-method.m b/gcc/testsuite/objc.dg/gnu-api-2-method.m
index 0c4fe4f0c5e..ea1da8d138f 100644
--- a/gcc/testsuite/objc.dg/gnu-api-2-method.m
+++ b/gcc/testsuite/objc.dg/gnu-api-2-method.m
@@ -5,6 +5,7 @@
 /* { dg-do run } */
 /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* To get the modern GNU Objective-C Runtime API, you include
    objc/runtime.h.  */
diff --git a/gcc/testsuite/objc.dg/gnu-api-2-objc.m b/gcc/testsuite/objc.dg/gnu-api-2-objc.m
index 1b4ce8e4799..e9ec5d7ab94 100644
--- a/gcc/testsuite/objc.dg/gnu-api-2-objc.m
+++ b/gcc/testsuite/objc.dg/gnu-api-2-objc.m
@@ -9,6 +9,7 @@
    systems that don't have the V2 APis).  XFAILing the run is not useful
    since it will XPASS on the sub-set that works.  */
 /* { dg-skip-if "Incompatible" { *-*-darwin* } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* To get the modern GNU Objective-C Runtime API, you include
    objc/runtime.h.  */
diff --git a/gcc/testsuite/objc.dg/gnu-api-2-objc_msg_lookup.m b/gcc/testsuite/objc.dg/gnu-api-2-objc_msg_lookup.m
index 5751f3fd298..d417225cdfb 100644
--- a/gcc/testsuite/objc.dg/gnu-api-2-objc_msg_lookup.m
+++ b/gcc/testsuite/objc.dg/gnu-api-2-objc_msg_lookup.m
@@ -5,6 +5,7 @@
 
 /* { dg-do run } */
 /* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* To get the modern GNU Objective-C Runtime API, you include
    objc/runtime.h.  */
diff --git a/gcc/testsuite/objc.dg/gnu-api-2-object.m b/gcc/testsuite/objc.dg/gnu-api-2-object.m
index 3d4d444fe27..20c4342d267 100644
--- a/gcc/testsuite/objc.dg/gnu-api-2-object.m
+++ b/gcc/testsuite/objc.dg/gnu-api-2-object.m
@@ -5,6 +5,7 @@
 /* { dg-do run } */
 /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* To get the modern GNU Objective-C Runtime API, you include
    objc/runtime.h.  */
diff --git a/gcc/testsuite/objc.dg/gnu-api-2-property.m b/gcc/testsuite/objc.dg/gnu-api-2-property.m
index 12c0d8b98e3..0ef4d79f9b3 100644
--- a/gcc/testsuite/objc.dg/gnu-api-2-property.m
+++ b/gcc/testsuite/objc.dg/gnu-api-2-property.m
@@ -4,6 +4,7 @@
 
 /* { dg-do run } */
 /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* To get the modern GNU Objective-C Runtime API, you include
    objc/runtime.h.  */
diff --git a/gcc/testsuite/objc.dg/gnu-api-2-protocol.m b/gcc/testsuite/objc.dg/gnu-api-2-protocol.m
index a34d74ce90d..682adcd716e 100644
--- a/gcc/testsuite/objc.dg/gnu-api-2-protocol.m
+++ b/gcc/testsuite/objc.dg/gnu-api-2-protocol.m
@@ -5,6 +5,7 @@
 /* { dg-do run } */
 /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* To get the modern GNU Objective-C Runtime API, you include
    objc/runtime.h.  */
diff --git a/gcc/testsuite/objc.dg/gnu-api-2-resolve-method.m b/gcc/testsuite/objc.dg/gnu-api-2-resolve-method.m
index a387709908c..6eaa3dd72a3 100644
--- a/gcc/testsuite/objc.dg/gnu-api-2-resolve-method.m
+++ b/gcc/testsuite/objc.dg/gnu-api-2-resolve-method.m
@@ -5,6 +5,7 @@
 
 /* { dg-do run } */
 /* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* To get the modern GNU Objective-C Runtime API, you include
    objc/runtime.h.  */
diff --git a/gcc/testsuite/objc.dg/gnu-api-2-sel.m b/gcc/testsuite/objc.dg/gnu-api-2-sel.m
index b71fdfab48c..bc581bec2f7 100644
--- a/gcc/testsuite/objc.dg/gnu-api-2-sel.m
+++ b/gcc/testsuite/objc.dg/gnu-api-2-sel.m
@@ -4,6 +4,7 @@
 
 /* { dg-do run } */
 /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* To get the modern GNU Objective-C Runtime API, you include
    objc/runtime.h.  */
diff --git a/gcc/testsuite/objc.dg/incomplete-type-1.m b/gcc/testsuite/objc.dg/incomplete-type-1.m
index f1e875f9aae..60d0d8a1133 100644
--- a/gcc/testsuite/objc.dg/incomplete-type-1.m
+++ b/gcc/testsuite/objc.dg/incomplete-type-1.m
@@ -6,6 +6,9 @@
 enum type1;
 struct type2;
 
+#if defined(__has_attribute) && __has_attribute(objc_root_class)
+__attribute__((objc_root_class))
+#endif
 @interface MyObject
 - (void) method1: (enum type1)argument;
 - (void) method2: (struct type2)argument;
diff --git a/gcc/testsuite/objc.dg/instancetype-0.m b/gcc/testsuite/objc.dg/instancetype-0.m
index 32cafdf314c..dc279269d24 100644
--- a/gcc/testsuite/objc.dg/instancetype-0.m
+++ b/gcc/testsuite/objc.dg/instancetype-0.m
@@ -6,6 +6,9 @@
 extern id class_createInstance (id, int);
 extern id class_getSuperclass (id);
 
+#if defined(__has_attribute) && __has_attribute(objc_root_class)
+__attribute__((objc_root_class))
+#endif
 @interface MyObject
 {
   Class isa;
diff --git a/gcc/testsuite/objc.dg/invalid-method-2.m b/gcc/testsuite/objc.dg/invalid-method-2.m
index cb18de95740..0a4bd6390fc 100644
--- a/gcc/testsuite/objc.dg/invalid-method-2.m
+++ b/gcc/testsuite/objc.dg/invalid-method-2.m
@@ -3,6 +3,9 @@
 /* Test that using an invalid type in a method declaration produces a
    friendly error without a compiler crash.  */
 
+#if defined(__has_attribute) && __has_attribute(objc_root_class)
+__attribute__((objc_root_class))
+#endif
 @interface MyClass
 @end
 
diff --git a/gcc/testsuite/objc.dg/ivar-invalid-type-1.m b/gcc/testsuite/objc.dg/ivar-invalid-type-1.m
index 3e7785db86f..98bf36e17c9 100644
--- a/gcc/testsuite/objc.dg/ivar-invalid-type-1.m
+++ b/gcc/testsuite/objc.dg/ivar-invalid-type-1.m
@@ -1,6 +1,9 @@
 /* { dg-do compile } */
 #include <objc/objc.h>
 
+#if defined(__has_attribute) && __has_attribute(objc_root_class)
+__attribute__((objc_root_class))
+#endif
 @interface MyRootClass
 {
   Class isa;
diff --git a/gcc/testsuite/objc.dg/ivar-problem-1.m b/gcc/testsuite/objc.dg/ivar-problem-1.m
index 4a877680549..0d5bb66ea32 100644
--- a/gcc/testsuite/objc.dg/ivar-problem-1.m
+++ b/gcc/testsuite/objc.dg/ivar-problem-1.m
@@ -10,6 +10,9 @@
 #include <stdlib.h>
 #include <objc/objc.h>
 
+#if defined(__has_attribute) && __has_attribute(objc_root_class)
+__attribute__((objc_root_class))
+#endif
 @interface MyRootClass1
 {
   Class isa;
@@ -36,6 +39,9 @@
 @end
 
 
+#if defined(__has_attribute) && __has_attribute(objc_root_class)
+__attribute__((objc_root_class))
+#endif
 @interface MyRootClass2
 {
   Class isa;
diff --git a/gcc/testsuite/objc.dg/ivar-scope-1.m b/gcc/testsuite/objc.dg/ivar-scope-1.m
index 34443a442fe..64d275b44bd 100644
--- a/gcc/testsuite/objc.dg/ivar-scope-1.m
+++ b/gcc/testsuite/objc.dg/ivar-scope-1.m
@@ -3,6 +3,9 @@
 /* { dg-do compile } */
 #include <objc/objc.h>
 
+#if defined(__has_attribute) && __has_attribute(objc_root_class)
+__attribute__((objc_root_class))
+#endif
 @interface MyClass
 {
   int someivar;
diff --git a/gcc/testsuite/objc.dg/ivar-scope-2.m b/gcc/testsuite/objc.dg/ivar-scope-2.m
index ff795d08d6a..1149d735d12 100644
--- a/gcc/testsuite/objc.dg/ivar-scope-2.m
+++ b/gcc/testsuite/objc.dg/ivar-scope-2.m
@@ -4,6 +4,9 @@
 /* { dg-additional-options "-fno-local-ivars" } */
 #include <objc/objc.h>
 
+#if defined(__has_attribute) && __has_attribute(objc_root_class)
+__attribute__((objc_root_class))
+#endif
 @interface MyClass
 {
   int someivar;
diff --git a/gcc/testsuite/objc.dg/ivar-scope-4.m b/gcc/testsuite/objc.dg/ivar-scope-4.m
index 5fc29f90bdc..df1c8927586 100644
--- a/gcc/testsuite/objc.dg/ivar-scope-4.m
+++ b/gcc/testsuite/objc.dg/ivar-scope-4.m
@@ -1,7 +1,8 @@
 /* Test instance variable scope.  */
 /* Author: Dimitris Papavasiliou <dpapavas@gmail.com>.  */
 /* { dg-do run } */
-/* { dg-additional-options "-Wno-shadow-ivar -fno-local-ivars" } */
+/* { dg-additional-options "-Wno-shadow-ivar -fno-local-ivars -Wno-objc-root-class" } */
+
 #include "../objc-obj-c++-shared/runtime.h"
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/objc.dg/ivar-visibility-1.m b/gcc/testsuite/objc.dg/ivar-visibility-1.m
index 5a222591d19..79d791ec7ab 100644
--- a/gcc/testsuite/objc.dg/ivar-visibility-1.m
+++ b/gcc/testsuite/objc.dg/ivar-visibility-1.m
@@ -1,6 +1,7 @@
 /* Test instance variable visibility.  */
 /* Author: Dimitris Papavasiliou <dpapavas@gmail.com>.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 #include <objc/objc.h>
 
 @interface MySuperClass
diff --git a/gcc/testsuite/objc.dg/ivar-visibility-2.m b/gcc/testsuite/objc.dg/ivar-visibility-2.m
index eb41c8f4db0..6ddcb5b4665 100644
--- a/gcc/testsuite/objc.dg/ivar-visibility-2.m
+++ b/gcc/testsuite/objc.dg/ivar-visibility-2.m
@@ -1,7 +1,7 @@
 /* Test instance variable visibility.  */
 /* Author: Dimitris Papavasiliou <dpapavas@gmail.com>.  */
 /* { dg-do compile } */
-/* { dg-additional-options "-fivar-visibility=protected" } */
+/* { dg-additional-options "-fivar-visibility=protected -Wno-objc-root-class" } */
 #include <objc/objc.h>
 
 @interface MySuperClass
diff --git a/gcc/testsuite/objc.dg/ivar-visibility-3.m b/gcc/testsuite/objc.dg/ivar-visibility-3.m
index ecc6f99c760..64035037a25 100644
--- a/gcc/testsuite/objc.dg/ivar-visibility-3.m
+++ b/gcc/testsuite/objc.dg/ivar-visibility-3.m
@@ -1,7 +1,7 @@
 /* Test instance variable visibility.  */
 /* Author: Dimitris Papavasiliou <dpapavas@gmail.com>.  */
 /* { dg-do compile } */
-/* { dg-additional-options "-fivar-visibility=private" } */
+/* { dg-additional-options "-fivar-visibility=private -Wno-objc-root-class" } */
 #include <objc/objc.h>
 
 @interface MySuperClass
diff --git a/gcc/testsuite/objc.dg/ivar-visibility-4.m b/gcc/testsuite/objc.dg/ivar-visibility-4.m
index adfeb449e55..abd802b5423 100644
--- a/gcc/testsuite/objc.dg/ivar-visibility-4.m
+++ b/gcc/testsuite/objc.dg/ivar-visibility-4.m
@@ -1,7 +1,7 @@
 /* Test instance variable visibility.  */
 /* Author: Dimitris Papavasiliou <dpapavas@gmail.com>.  */
 /* { dg-do compile } */
-/* { dg-additional-options "-fivar-visibility=public" } */
+/* { dg-additional-options "-fivar-visibility=public -Wno-objc-root-class" } */
 #include <objc/objc.h>
 
 @interface MySuperClass
diff --git a/gcc/testsuite/objc.dg/local-decl-1.m b/gcc/testsuite/objc.dg/local-decl-1.m
index 4a4bfdffe7e..8356a8ca248 100644
--- a/gcc/testsuite/objc.dg/local-decl-1.m
+++ b/gcc/testsuite/objc.dg/local-decl-1.m
@@ -1,6 +1,7 @@
 /* Test for hiding of ivars by local variables.  */
 /* Author: Ziemowit Laski <zlaski@apple.com>.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 @interface Sprite {
   int a;
diff --git a/gcc/testsuite/objc.dg/lto/lto.exp b/gcc/testsuite/objc.dg/lto/lto.exp
index e563ecbc3c2..8a362d67288 100644
--- a/gcc/testsuite/objc.dg/lto/lto.exp
+++ b/gcc/testsuite/objc.dg/lto/lto.exp
@@ -41,10 +41,10 @@ if { ![check_effective_target_lto] } {
 global LTO_OPTIONS
 
 set LTO_OPTIONS [list	\
-  {-O0 -flto -fgnu-runtime}	\
-  {-O2 -flto -fgnu-runtime}	\
-  {-O0 -flto -flto-partition=none -fgnu-runtime} 	\
-  {-O2 -flto -flto-partition=none -fgnu-runtime}	\
+  {-O0 -flto -fgnu-runtime -Wno-objc-root-class}	\
+  {-O2 -flto -fgnu-runtime -Wno-objc-root-class }	\
+  {-O0 -flto -flto-partition=none -fgnu-runtime -Wno-objc-root-class} 	\
+  {-O2 -flto -flto-partition=none -fgnu-runtime -Wno-objc-root-class}	\
 ]
 
 objc_init
@@ -67,10 +67,10 @@ foreach src $tests {
 # darwin targets can also run code with the NeXT runtime.
 if [istarget "*-*-darwin*" ] {
 set LTO_OPTIONS [list	\
-  {-O0 -flto -fnext-runtime}	\
-  {-O2 -flto -fnext-runtime}	\
-  {-O0 -flto -flto-partition=none -fnext-runtime} 	\
-  {-O2 -flto -flto-partition=none -fnext-runtime}	\
+  {-O0 -flto -fnext-runtime -Wno-objc-root-class}	\
+  {-O2 -flto -fnext-runtime -Wno-objc-root-class}	\
+  {-O0 -flto -flto-partition=none -fnext-runtime -Wno-objc-root-class} 	\
+  {-O2 -flto -flto-partition=none -fnext-runtime -Wno-objc-root-class}	\
 ]
   foreach src $tests {
     # If we're only testing specific files and this isn't one of them, skip it.
diff --git a/gcc/testsuite/objc.dg/lto/trivial-1_0.m b/gcc/testsuite/objc.dg/lto/trivial-1_0.m
index ba1b1aa8b35..ca07fa4bdb2 100644
--- a/gcc/testsuite/objc.dg/lto/trivial-1_0.m
+++ b/gcc/testsuite/objc.dg/lto/trivial-1_0.m
@@ -1,5 +1,5 @@
 /* { dg-lto-do run } */
-/* { dg-skip-if "" { "*-*-darwin*" && lp64 } } */
+
 extern int printf (char *,...) ;
 
 typedef struct objc_class *Class;
@@ -7,7 +7,7 @@ typedef struct objc_class *Class;
 struct objc_class {
     Class isa;
     /* other stuff... */
-}  ;
+};
 
 @interface myRootObject {
 @public
diff --git a/gcc/testsuite/objc.dg/method-1.m b/gcc/testsuite/objc.dg/method-1.m
index 194c64fac4e..bd23493988c 100644
--- a/gcc/testsuite/objc.dg/method-1.m
+++ b/gcc/testsuite/objc.dg/method-1.m
@@ -1,5 +1,6 @@
 /* Tests of duplication.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 @interface class1
 - (int) meth1;   /* { dg-message "previous declaration" } */
diff --git a/gcc/testsuite/objc.dg/method-12.m b/gcc/testsuite/objc.dg/method-12.m
index 411caac111a..b69a84f300b 100644
--- a/gcc/testsuite/objc.dg/method-12.m
+++ b/gcc/testsuite/objc.dg/method-12.m
@@ -1,5 +1,6 @@
 /* Contributed by Igor Seleznev <selez@mail.ru>.  */
 /* This used to be broken.  */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/objc.dg/method-13.m b/gcc/testsuite/objc.dg/method-13.m
index 592038b9d93..3e0fde5f5ba 100644
--- a/gcc/testsuite/objc.dg/method-13.m
+++ b/gcc/testsuite/objc.dg/method-13.m
@@ -4,6 +4,7 @@
 /* Author: Ziemowit Laski <zlaski@apple.com>.  */
 /* { dg-do run } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 #include "../objc-obj-c++-shared/runtime.h"
diff --git a/gcc/testsuite/objc.dg/method-14.m b/gcc/testsuite/objc.dg/method-14.m
index 96982254aa9..bc3ee12f20b 100644
--- a/gcc/testsuite/objc.dg/method-14.m
+++ b/gcc/testsuite/objc.dg/method-14.m
@@ -2,6 +2,7 @@
    used as method selectors.  */
 /* Author: Ziemowit Laski <zlaski@apple.com>.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 @interface Foo
 - (void)insertNewButtonImage:(Foo *)newButtonImage in:(Foo *)buttonCell;
diff --git a/gcc/testsuite/objc.dg/missing-proto-3.m b/gcc/testsuite/objc.dg/missing-proto-3.m
index 05e1a258183..77aa3a39446 100644
--- a/gcc/testsuite/objc.dg/missing-proto-3.m
+++ b/gcc/testsuite/objc.dg/missing-proto-3.m
@@ -2,7 +2,8 @@
    In addition to not crashing :-), the compiler should properly handle
    valid protocol references, even when they're mixed with invalid ones.  */
 /* { dg-do compile } */
- 
+/* { dg-additional-options "-Wno-objc-root-class" } */
+
 #include <objc/objc.h>
 
 @protocol DefinedProtocol
diff --git a/gcc/testsuite/objc.dg/next-runtime-1.m b/gcc/testsuite/objc.dg/next-runtime-1.m
index c76b6166d2e..2ce798bc94f 100644
--- a/gcc/testsuite/objc.dg/next-runtime-1.m
+++ b/gcc/testsuite/objc.dg/next-runtime-1.m
@@ -7,6 +7,7 @@
 /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
 /* { dg-skip-if "" { *-*-* } { "-fobjc-abi-version=1" } { "" } } */
 /* { dg-options "-fobjc-abi-version=0" { target { *-*-darwin* && { ! lp64 } } } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 @interface FooBar
 - (void)boo;
diff --git a/gcc/testsuite/objc.dg/objc-foreach-1.m b/gcc/testsuite/objc.dg/objc-foreach-1.m
index 81f5dae0c2f..e4c958ced72 100644
--- a/gcc/testsuite/objc.dg/objc-foreach-1.m
+++ b/gcc/testsuite/objc.dg/objc-foreach-1.m
@@ -1,5 +1,6 @@
 /* Syntax check for the new foreach statement. */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 typedef struct objc_class *Class;
 
diff --git a/gcc/testsuite/objc.dg/objc-foreach-2.m b/gcc/testsuite/objc.dg/objc-foreach-2.m
index a01f004fec6..0f79089f278 100644
--- a/gcc/testsuite/objc.dg/objc-foreach-2.m
+++ b/gcc/testsuite/objc.dg/objc-foreach-2.m
@@ -1,5 +1,6 @@
 /* Syntax check for the new foreach statement. */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 typedef struct objc_class *Class;
 
diff --git a/gcc/testsuite/objc.dg/objc-foreach-3.m b/gcc/testsuite/objc.dg/objc-foreach-3.m
index 922db39e748..b551ae39436 100644
--- a/gcc/testsuite/objc.dg/objc-foreach-3.m
+++ b/gcc/testsuite/objc.dg/objc-foreach-3.m
@@ -1,6 +1,7 @@
 /* Syntax check for the new foreach statement. 
    Use of declaration in loop-header without requiring c99 mode. */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 typedef struct objc_class *Class;
 
diff --git a/gcc/testsuite/objc.dg/objc-nofilename-1.m b/gcc/testsuite/objc.dg/objc-nofilename-1.m
index 21e0c53b70e..3ddaa6431ec 100644
--- a/gcc/testsuite/objc.dg/objc-nofilename-1.m
+++ b/gcc/testsuite/objc.dg/objc-nofilename-1.m
@@ -1,5 +1,6 @@
 /* Test to make sure that file name does not appear in the binary. */
 /* { dg-do compile { target *-*-darwin* } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/objc.dg/param-1.m b/gcc/testsuite/objc.dg/param-1.m
index 9dbf6e3fcd9..8e7781169ac 100644
--- a/gcc/testsuite/objc.dg/param-1.m
+++ b/gcc/testsuite/objc.dg/param-1.m
@@ -1,6 +1,7 @@
 /* Test if compiler detects object as an parameter to a method
    or not. It is not valid.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 @interface foo
 @end
diff --git a/gcc/testsuite/objc.dg/pch/pch.exp b/gcc/testsuite/objc.dg/pch/pch.exp
index 2da3d96d4fe..54c3e429efe 100644
--- a/gcc/testsuite/objc.dg/pch/pch.exp
+++ b/gcc/testsuite/objc.dg/pch/pch.exp
@@ -41,7 +41,7 @@ foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.m]] {
     # unlikely to make any difference to PCH.  However, we do want to
     # add -O0 -g, since users who want PCH usually want debugging and quick
     # compiles.
-    dg-flags-pch $subdir $test "-fgnu-runtime" $mytorture ".h"
+    dg-flags-pch $subdir $test "-fgnu-runtime -Wno-objc-root-class" $mytorture ".h"
 }
 
 if [istarget "*-*-darwin*" ] {
@@ -52,7 +52,7 @@ if [istarget "*-*-darwin*" ] {
     # unlikely to make any difference to PCH.  However, we do want to
     # add -O0 -g, since users who want PCH usually want debugging and quick
     # compiles.
-    dg-flags-pch $subdir $test "-fnext-runtime" $mytorture ".h"
+    dg-flags-pch $subdir $test "-fnext-runtime -Wno-objc-root-class" $mytorture ".h"
   }
 }
 
diff --git a/gcc/testsuite/objc.dg/plugin/diagnostic-test-expressions-1.m b/gcc/testsuite/objc.dg/plugin/diagnostic-test-expressions-1.m
index 23a93021e83..7070b37b38c 100644
--- a/gcc/testsuite/objc.dg/plugin/diagnostic-test-expressions-1.m
+++ b/gcc/testsuite/objc.dg/plugin/diagnostic-test-expressions-1.m
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O -fdiagnostics-show-caret" } */
+/* { dg-options "-O -fdiagnostics-show-caret -Wno-objc-root-class" } */
 
 /* This file is similar to diagnostic-test-expressions-1.c
    (see the notes in that file); this file adds test
diff --git a/gcc/testsuite/objc.dg/pr23709.m b/gcc/testsuite/objc.dg/pr23709.m
index 7ff9b605239..2bdcca56d36 100644
--- a/gcc/testsuite/objc.dg/pr23709.m
+++ b/gcc/testsuite/objc.dg/pr23709.m
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 @interface A
 +(void)method: (int)parameter {} /* { dg-error "expected" } */
diff --git a/gcc/testsuite/objc.dg/private-1.m b/gcc/testsuite/objc.dg/private-1.m
index 7540fc5800c..5bd29e5939b 100644
--- a/gcc/testsuite/objc.dg/private-1.m
+++ b/gcc/testsuite/objc.dg/private-1.m
@@ -1,6 +1,7 @@
 /* Test errors for accessing @private and @protected variables.  */
 /* Author: Nicola Pero <nicola@brainstorm.co.uk>.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 #include <objc/objc.h>
 
 @interface MySuperClass
diff --git a/gcc/testsuite/objc.dg/private-2.m b/gcc/testsuite/objc.dg/private-2.m
index eff376a0c84..d0646f5ca68 100644
--- a/gcc/testsuite/objc.dg/private-2.m
+++ b/gcc/testsuite/objc.dg/private-2.m
@@ -1,6 +1,7 @@
 /* Test warnings for shadowing instance variables.  */
 /* Author: Nicola Pero <nicola@brainstorm.co.uk>.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 #include <objc/objc.h>
 
 @interface MySuperClass
diff --git a/gcc/testsuite/objc.dg/property/property.exp b/gcc/testsuite/objc.dg/property/property.exp
index 47ffcdf27db..1c203dbcbf0 100644
--- a/gcc/testsuite/objc.dg/property/property.exp
+++ b/gcc/testsuite/objc.dg/property/property.exp
@@ -31,12 +31,12 @@ dg-init
 set tests [lsort [glob -nocomplain $srcdir/$subdir/*.m]]
 
 # Main loop.
-dg-runtest $tests "-fgnu-runtime" $DEFAULT_CFLAGS
+dg-runtest $tests "-fgnu-runtime -Wno-objc-root-class" $DEFAULT_CFLAGS
 
 # Darwin targets can also run code with the NeXT runtime.
 # but Properties are not supported by the runtime lib before Darwin 9.
 if [istarget "*-*-darwin\[9123\]*" ] {
-  dg-runtest $tests "-fnext-runtime" $DEFAULT_CFLAGS
+  dg-runtest $tests "-fnext-runtime -Wno-objc-root-class" $DEFAULT_CFLAGS
 }
 
 # All done.
diff --git a/gcc/testsuite/objc.dg/proto-hier-1.m b/gcc/testsuite/objc.dg/proto-hier-1.m
index 0f409fc69ed..648a4d45cc3 100644
--- a/gcc/testsuite/objc.dg/proto-hier-1.m
+++ b/gcc/testsuite/objc.dg/proto-hier-1.m
@@ -1,6 +1,7 @@
 /* Test for handling of protocol hierarchies.  */
 /* Author: Ziemowit Laski <zlaski@apple.com>.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* One-line substitute for objc/objc.h */
 typedef struct objc_object { struct objc_class *class_pointer; } *id;
diff --git a/gcc/testsuite/objc.dg/proto-hier-2.m b/gcc/testsuite/objc.dg/proto-hier-2.m
index 819cf4a5089..6b3f803d5cb 100644
--- a/gcc/testsuite/objc.dg/proto-hier-2.m
+++ b/gcc/testsuite/objc.dg/proto-hier-2.m
@@ -1,6 +1,7 @@
 /* Test protocol warning.  */
 /* Contributed by Devang Patel <dpatel@apple.com>.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 typedef struct objc_object { struct objc_class *class_pointer; } *id;
 
diff --git a/gcc/testsuite/objc.dg/proto-lossage-1.m b/gcc/testsuite/objc.dg/proto-lossage-1.m
index 2f7eb986140..4564a9432f1 100644
--- a/gcc/testsuite/objc.dg/proto-lossage-1.m
+++ b/gcc/testsuite/objc.dg/proto-lossage-1.m
@@ -2,6 +2,7 @@
    may be lost, leading to superfluous warnings.  */
 /* Author: Ziemowit Laski <zlaski@apple.com>.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* One-line substitute for objc/objc.h */
 typedef struct objc_object { struct objc_class *class_pointer; } *id;
diff --git a/gcc/testsuite/objc.dg/proto-lossage-5.m b/gcc/testsuite/objc.dg/proto-lossage-5.m
index 35c0956ed8e..a18b3578cbc 100644
--- a/gcc/testsuite/objc.dg/proto-lossage-5.m
+++ b/gcc/testsuite/objc.dg/proto-lossage-5.m
@@ -1,5 +1,6 @@
 /* Do not lose references to forward-declared protocols.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 @class MyBaseClass;
 @class MyClassThatFails;
 @protocol _MyProtocol;
diff --git a/gcc/testsuite/objc.dg/proto-qual-1.m b/gcc/testsuite/objc.dg/proto-qual-1.m
index 40eb0f9f5c5..6e908727678 100644
--- a/gcc/testsuite/objc.dg/proto-qual-1.m
+++ b/gcc/testsuite/objc.dg/proto-qual-1.m
@@ -3,6 +3,7 @@
 
 /* { dg-do run } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include "../objc-obj-c++-shared/runtime.h"
 #include <objc/Protocol.h>
diff --git a/gcc/testsuite/objc.dg/protocol-inheritance-1.m b/gcc/testsuite/objc.dg/protocol-inheritance-1.m
index 5241b29abbd..5367a9870be 100644
--- a/gcc/testsuite/objc.dg/protocol-inheritance-1.m
+++ b/gcc/testsuite/objc.dg/protocol-inheritance-1.m
@@ -1,6 +1,7 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
 /* { dg-do compile } */
 /* { dg-options "-Wno-protocol" } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/objc.dg/protocol-inheritance-2.m b/gcc/testsuite/objc.dg/protocol-inheritance-2.m
index 74c9174b5de..9776a40f1da 100644
--- a/gcc/testsuite/objc.dg/protocol-inheritance-2.m
+++ b/gcc/testsuite/objc.dg/protocol-inheritance-2.m
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/objc.dg/protocol-optional-1.m b/gcc/testsuite/objc.dg/protocol-optional-1.m
index bc4a3d07e97..29fe72ea00f 100644
--- a/gcc/testsuite/objc.dg/protocol-optional-1.m
+++ b/gcc/testsuite/objc.dg/protocol-optional-1.m
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/objc.dg/selector-1.m b/gcc/testsuite/objc.dg/selector-1.m
index f0781b68c63..5ff15a2e0a7 100644
--- a/gcc/testsuite/objc.dg/selector-1.m
+++ b/gcc/testsuite/objc.dg/selector-1.m
@@ -3,6 +3,7 @@
 /* { dg-options "-Wselector" } */
 /* { dg-do compile } */
 /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 typedef struct objc_object { struct objc_class *class_pointer; } *id;
 typedef struct objc_selector    *SEL;
diff --git a/gcc/testsuite/objc.dg/selector-2.m b/gcc/testsuite/objc.dg/selector-2.m
index 6cad2ffb092..5042104ed3e 100644
--- a/gcc/testsuite/objc.dg/selector-2.m
+++ b/gcc/testsuite/objc.dg/selector-2.m
@@ -1,6 +1,7 @@
 /* Test that we don't ICE when issuing a -Wselector warning.  */
 /* { dg-options "-Wselector" } */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/objc.dg/selector-3.m b/gcc/testsuite/objc.dg/selector-3.m
index c0c5f3d8fba..94838cd3803 100644
--- a/gcc/testsuite/objc.dg/selector-3.m
+++ b/gcc/testsuite/objc.dg/selector-3.m
@@ -3,6 +3,7 @@
 /* { dg-options "-Wselector" } */
 /* { dg-do compile } */
 /* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 typedef struct objc_object { struct objc_class *class_pointer; } *id;
 typedef const struct objc_selector    *SEL;
diff --git a/gcc/testsuite/objc.dg/selector-4.m b/gcc/testsuite/objc.dg/selector-4.m
index d34f8c89cd6..2a4947e322a 100644
--- a/gcc/testsuite/objc.dg/selector-4.m
+++ b/gcc/testsuite/objc.dg/selector-4.m
@@ -3,6 +3,7 @@
 /* Author: Ziemowit Laski <zlaski@apple.com>.  */
 
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 @interface Int1 
 + (int)and_eq:(int)arg1 and:(int)arg2;
diff --git a/gcc/testsuite/objc.dg/shadow-1.m b/gcc/testsuite/objc.dg/shadow-1.m
index 739a0d0312e..d18fd6e5f93 100644
--- a/gcc/testsuite/objc.dg/shadow-1.m
+++ b/gcc/testsuite/objc.dg/shadow-1.m
@@ -2,6 +2,7 @@
 /* Author: Dimitris Papavasiliou <dpapavas@gmail.com>.  */
 /* { dg-do compile } */
 /* { dg-additional-options "-Wno-shadow-ivar" } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 #include <objc/objc.h>
 
 @interface MyClass
diff --git a/gcc/testsuite/objc.dg/shadow-2.m b/gcc/testsuite/objc.dg/shadow-2.m
index 16261b94a21..26447fe1081 100644
--- a/gcc/testsuite/objc.dg/shadow-2.m
+++ b/gcc/testsuite/objc.dg/shadow-2.m
@@ -2,6 +2,7 @@
 /* Author: Dimitris Papavasiliou <dpapavas@gmail.com>.  */
 /* { dg-do compile } */
 /* { dg-additional-options "-Wno-shadow" } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 #include <objc/objc.h>
 
 @interface MyClass
diff --git a/gcc/testsuite/objc.dg/special/load-category-1.m b/gcc/testsuite/objc.dg/special/load-category-1.m
index cb221436f02..b72d0709044 100644
--- a/gcc/testsuite/objc.dg/special/load-category-1.m
+++ b/gcc/testsuite/objc.dg/special/load-category-1.m
@@ -1,6 +1,7 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
 /* { dg-do run } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <stdlib.h>
 #include <objc/objc.h>
diff --git a/gcc/testsuite/objc.dg/special/load-category-2.m b/gcc/testsuite/objc.dg/special/load-category-2.m
index 7dc74595206..2706351da22 100644
--- a/gcc/testsuite/objc.dg/special/load-category-2.m
+++ b/gcc/testsuite/objc.dg/special/load-category-2.m
@@ -1,6 +1,7 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
 /* { dg-do run } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/gcc/testsuite/objc.dg/special/load-category-3.m b/gcc/testsuite/objc.dg/special/load-category-3.m
index b89d8f15286..215e463fcbe 100644
--- a/gcc/testsuite/objc.dg/special/load-category-3.m
+++ b/gcc/testsuite/objc.dg/special/load-category-3.m
@@ -1,6 +1,7 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
 /* { dg-do run } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* This test is identical to load-category-2, but the classes and
    categories are created in inverted order in the modules, to test
diff --git a/gcc/testsuite/objc.dg/special/special.exp b/gcc/testsuite/objc.dg/special/special.exp
index d770e2accb3..f561d3895d4 100644
--- a/gcc/testsuite/objc.dg/special/special.exp
+++ b/gcc/testsuite/objc.dg/special/special.exp
@@ -39,6 +39,7 @@ dg-init
 # for all systems we point to the libobjc includes and use the -fgnu-runtime
 set add_flags "additional_flags=-I${srcdir}/../../libobjc"
 lappend add_flags "additional_flags=-fgnu-runtime"
+lappend add_flags "additional_flags=-Wno-objc-root-class"
 set lines [objc_target_compile "$srcdir/$subdir/unclaimed-category-1a.m" "unclaimed-category-1a.o" object $add_flags ]
 if ![string match "" $lines] then {
     fail "unclaimed-category-1a.o"
@@ -50,6 +51,7 @@ if ![string match "" $lines] then {
 if [istarget "*-*-darwin*" ] {
 set add_flags ""
 lappend add_flags "additional_flags=-fnext-runtime"
+lappend add_flags "additional_flags=-Wno-objc-root-class"
 set lines [objc_target_compile "$srcdir/$subdir/unclaimed-category-1a.m" "unclaimed-category-1a.o" object $add_flags ]
 if ![string match "" $lines] then {
     fail "unclaimed-category-1a.o"
@@ -66,6 +68,7 @@ if ![string match "" $lines] then {
 # and load-category-1a.m, link them together, and execute the result.
 set add_flags "additional_flags=-I${srcdir}/../../libobjc"
 lappend add_flags "additional_flags=-fgnu-runtime"
+lappend add_flags "additional_flags=-Wno-objc-root-class"
 set lines [objc_target_compile "$srcdir/$subdir/load-category-1a.m" "load-category-1a.o" object $add_flags ]
 if ![string match "" $lines] then {
     fail "load-category-1a.o"
@@ -77,6 +80,7 @@ if ![string match "" $lines] then {
 if [istarget "*-*-darwin*" ] {
 set add_flags ""
 lappend add_flags "additional_flags=-fnext-runtime"
+lappend add_flags "additional_flags=-Wno-objc-root-class"
 set lines [objc_target_compile "$srcdir/$subdir/load-category-1a.m" "load-category-1a.o" object $add_flags ]
 if ![string match "" $lines] then {
     fail "load-category-1a.o"
@@ -93,6 +97,7 @@ if ![string match "" $lines] then {
 # and load-category-2a.m, link them together, and execute the result.
 set add_flags "additional_flags=-I${srcdir}/../../libobjc"
 lappend add_flags "additional_flags=-fgnu-runtime"
+lappend add_flags "additional_flags=-Wno-objc-root-class"
 set lines [objc_target_compile "$srcdir/$subdir/load-category-2a.m" "load-category-2a.o" object $add_flags ]
 if ![string match "" $lines] then {
     fail "load-category-2a.o"
@@ -104,6 +109,7 @@ if ![string match "" $lines] then {
 if [istarget "*-*-darwin*" ] {
 set add_flags ""
 lappend add_flags "additional_flags=-fnext-runtime"
+lappend add_flags "additional_flags=-Wno-objc-root-class"
 set lines [objc_target_compile "$srcdir/$subdir/load-category-2a.m" "load-category-2a.o" object $add_flags ]
 if ![string match "" $lines] then {
     fail "load-category-2a.o"
@@ -120,6 +126,7 @@ if ![string match "" $lines] then {
 # and load-category-3a.m, link them together, and execute the result.
 set add_flags "additional_flags=-I${srcdir}/../../libobjc"
 lappend add_flags "additional_flags=-fgnu-runtime"
+lappend add_flags "additional_flags=-Wno-objc-root-class"
 set lines [objc_target_compile "$srcdir/$subdir/load-category-3a.m" "load-category-3a.o" object $add_flags ]
 if ![string match "" $lines] then {
     fail "load-category-3a.o"
@@ -131,6 +138,7 @@ if ![string match "" $lines] then {
 if [istarget "*-*-darwin*" ] {
 set add_flags ""
 lappend add_flags "additional_flags=-fnext-runtime"
+lappend add_flags "additional_flags=-Wno-objc-root-class"
 set lines [objc_target_compile "$srcdir/$subdir/load-category-3a.m" "load-category-3a.o" object $add_flags ]
 if ![string match "" $lines] then {
     fail "load-category-3a.o"
diff --git a/gcc/testsuite/objc.dg/special/unclaimed-category-1.h b/gcc/testsuite/objc.dg/special/unclaimed-category-1.h
index a32024df59f..cb5812ea327 100644
--- a/gcc/testsuite/objc.dg/special/unclaimed-category-1.h
+++ b/gcc/testsuite/objc.dg/special/unclaimed-category-1.h
@@ -1,4 +1,5 @@
 /* Contributed by Nicola Pero - Fri Dec 14 08:36:00 GMT 2001 */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* Test loading unclaimed categories - categories of a class defined
    separately from the class itself.  */
diff --git a/gcc/testsuite/objc.dg/special/unclaimed-category-1.m b/gcc/testsuite/objc.dg/special/unclaimed-category-1.m
index 7b434b4db54..a8e422d34e9 100644
--- a/gcc/testsuite/objc.dg/special/unclaimed-category-1.m
+++ b/gcc/testsuite/objc.dg/special/unclaimed-category-1.m
@@ -1,6 +1,7 @@
 /* Contributed by Nicola Pero - Fri Dec 14 08:36:00 GMT 2001 */
 /* { dg-do run } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 #include "../../objc-obj-c++-shared/runtime.h"
diff --git a/gcc/testsuite/objc.dg/stabs-1.m b/gcc/testsuite/objc.dg/stabs-1.m
index 452993ed916..b97e4d6a762 100644
--- a/gcc/testsuite/objc.dg/stabs-1.m
+++ b/gcc/testsuite/objc.dg/stabs-1.m
@@ -3,6 +3,7 @@
 
 /* { dg-do compile { target stabs } } */
 /* { dg-options "-gstabs" } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 @interface MyClass
 + newWithArg: arg;
diff --git a/gcc/testsuite/objc.dg/strings/strings.exp b/gcc/testsuite/objc.dg/strings/strings.exp
index 41da5cb5fc2..6042d3c14de 100644
--- a/gcc/testsuite/objc.dg/strings/strings.exp
+++ b/gcc/testsuite/objc.dg/strings/strings.exp
@@ -35,11 +35,11 @@ dg-init
 set tests [lsort [glob -nocomplain $srcdir/$subdir/*.m]]
 
 # Main loop.
-dg-runtest $tests "-fgnu-runtime" $DEFAULT_CFLAGS
+dg-runtest $tests "-fgnu-runtime -Wno-objc-root-class" $DEFAULT_CFLAGS
 
 # darwin targets can also run code with the NeXT runtime.
 if [istarget "*-*-darwin*" ] {
-  dg-runtest $tests "-fnext-runtime" $DEFAULT_CFLAGS
+  dg-runtest $tests "-fnext-runtime -Wno-objc-root-class" $DEFAULT_CFLAGS
 }
 
 # All done.
diff --git a/gcc/testsuite/objc.dg/stubify-1.m b/gcc/testsuite/objc.dg/stubify-1.m
index 641595ccfe4..4043492e6b8 100644
--- a/gcc/testsuite/objc.dg/stubify-1.m
+++ b/gcc/testsuite/objc.dg/stubify-1.m
@@ -5,6 +5,7 @@
 /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
 /* { dg-require-effective-target ilp32 } */
 /* { dg-options "-Os -mdynamic-no-pic -mmacosx-version-min=10.4 -msymbol-stubs" } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 typedef struct objc_object { } *id ;
 int x = 41 ;
diff --git a/gcc/testsuite/objc.dg/stubify-2.m b/gcc/testsuite/objc.dg/stubify-2.m
index 904ac44b252..3e9097e11ac 100644
--- a/gcc/testsuite/objc.dg/stubify-2.m
+++ b/gcc/testsuite/objc.dg/stubify-2.m
@@ -5,6 +5,7 @@
 /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
 /* { dg-require-effective-target ilp32 } */
 /* { dg-options "-mdynamic-no-pic -fdump-rtl-jump -mmacosx-version-min=10.4 -msymbol-stubs" } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 typedef struct objc_object { } *id ;
 int x = 41 ;
diff --git a/gcc/testsuite/objc.dg/super-class-2.m b/gcc/testsuite/objc.dg/super-class-2.m
index 144ea81b5e6..63792fd1d88 100644
--- a/gcc/testsuite/objc.dg/super-class-2.m
+++ b/gcc/testsuite/objc.dg/super-class-2.m
@@ -1,6 +1,7 @@
 /* Test calling super from within a category class method.  */
 /* Author: Ziemowit Laski <zlaski@apple.com>  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 typedef struct objc_object { struct objc_class *isa; } *id;
 
diff --git a/gcc/testsuite/objc.dg/super-dealloc-1.m b/gcc/testsuite/objc.dg/super-dealloc-1.m
index 0ab177bb73c..035de055b25 100644
--- a/gcc/testsuite/objc.dg/super-dealloc-1.m
+++ b/gcc/testsuite/objc.dg/super-dealloc-1.m
@@ -2,6 +2,7 @@
 /* Author: Ziemowit Laski <zlaski@apple.com>  */
 
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 @interface Foo {
   void *isa;
diff --git a/gcc/testsuite/objc.dg/super-dealloc-2.m b/gcc/testsuite/objc.dg/super-dealloc-2.m
index 80dcf495062..5d588c50fa9 100644
--- a/gcc/testsuite/objc.dg/super-dealloc-2.m
+++ b/gcc/testsuite/objc.dg/super-dealloc-2.m
@@ -2,6 +2,7 @@
 /* Author: Ziemowit Laski <zlaski@apple.com>  */
 
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 @interface Foo {
   void *isa;
diff --git a/gcc/testsuite/objc.dg/sync-3.m b/gcc/testsuite/objc.dg/sync-3.m
index 5cee890bba2..6ef72a1a4c2 100644
--- a/gcc/testsuite/objc.dg/sync-3.m
+++ b/gcc/testsuite/objc.dg/sync-3.m
@@ -1,6 +1,7 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
 /* { dg-options "-fobjc-exceptions" } */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* Test that the compiler is checking the argument of @synchronized(),
    and produce errors when invalid types are used.  */
diff --git a/gcc/testsuite/objc.dg/threedotthree-abi-1.m b/gcc/testsuite/objc.dg/threedotthree-abi-1.m
index 53154d321ba..8c22850e094 100644
--- a/gcc/testsuite/objc.dg/threedotthree-abi-1.m
+++ b/gcc/testsuite/objc.dg/threedotthree-abi-1.m
@@ -3,6 +3,7 @@
 /* { dg-do run { target *-*-darwin* } } */
 /* { dg-require-effective-target ilp32 } */
 /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <stdio.h>
 #include <string.h>
diff --git a/gcc/testsuite/objc.dg/torture/dg-torture.exp b/gcc/testsuite/objc.dg/torture/dg-torture.exp
index 28c2359392b..11f50fc1ded 100644
--- a/gcc/testsuite/objc.dg/torture/dg-torture.exp
+++ b/gcc/testsuite/objc.dg/torture/dg-torture.exp
@@ -7,11 +7,11 @@ dg-init
 # Gather a list of all tests.
 set tests [lsort [glob -nocomplain $srcdir/$subdir/*.m]]
 
-objc-dg-runtest $tests "" "-fgnu-runtime"
+objc-dg-runtest $tests "" "-fgnu-runtime -Wno-objc-root-class"
 
 # darwin targets can also run code with the NeXT runtime.
 if [istarget "*-*-darwin*" ] {
-  objc-dg-runtest $tests "" "-fnext-runtime"
+  objc-dg-runtest $tests "" "-fnext-runtime -Wno-objc-root-class"
 }
 
 dg-finish
diff --git a/gcc/testsuite/objc.dg/torture/strings/strings.exp b/gcc/testsuite/objc.dg/torture/strings/strings.exp
index 64e53c6c23f..3e2b3b0bd03 100644
--- a/gcc/testsuite/objc.dg/torture/strings/strings.exp
+++ b/gcc/testsuite/objc.dg/torture/strings/strings.exp
@@ -24,11 +24,11 @@ dg-init
 # Gather a list of all tests.
 set tests [lsort [glob -nocomplain $srcdir/$subdir/*.m]]
 
-objc-dg-runtest $tests "" "-fgnu-runtime"
+objc-dg-runtest $tests "" "-fgnu-runtime -Wno-objc-root-class"
 
 # Darwin targets also test with the NeXT runtime.
 if [istarget "*-*-darwin*" ] {
-  objc-dg-runtest $tests "" "-fnext-runtime"
+  objc-dg-runtest $tests "" "-fnext-runtime -Wno-objc-root-class"
 }
 
 dg-finish
diff --git a/gcc/testsuite/objc.dg/try-catch-11.m b/gcc/testsuite/objc.dg/try-catch-11.m
index e08f321e8c7..c792c83062f 100644
--- a/gcc/testsuite/objc.dg/try-catch-11.m
+++ b/gcc/testsuite/objc.dg/try-catch-11.m
@@ -4,6 +4,7 @@
 
 /* { dg-options "-fobjc-exceptions" } */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 typedef volatile int IOSharedLockData;
 
diff --git a/gcc/testsuite/objc.dg/try-catch-12.m b/gcc/testsuite/objc.dg/try-catch-12.m
index ce26b32d32b..6c9afc26de7 100644
--- a/gcc/testsuite/objc.dg/try-catch-12.m
+++ b/gcc/testsuite/objc.dg/try-catch-12.m
@@ -4,6 +4,7 @@
 
 /* { dg-options "-fobjc-exceptions" } */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 @interface TestMyTests
 - (void) testSpoon;
diff --git a/gcc/testsuite/objc.dg/type-size-2.m b/gcc/testsuite/objc.dg/type-size-2.m
index d02a8af219e..64444cfe255 100644
--- a/gcc/testsuite/objc.dg/type-size-2.m
+++ b/gcc/testsuite/objc.dg/type-size-2.m
@@ -4,6 +4,7 @@
 /* Contributed by Ziemowit Laski <zlaski@apple.com>.  */
 /* { dg-do run } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include "../objc-obj-c++-shared/runtime.h"
 #include <stdio.h>
diff --git a/gcc/testsuite/objc.dg/type-size-3.m b/gcc/testsuite/objc.dg/type-size-3.m
index bc66b0be67a..3f65516e75e 100644
--- a/gcc/testsuite/objc.dg/type-size-3.m
+++ b/gcc/testsuite/objc.dg/type-size-3.m
@@ -1,6 +1,7 @@
 /* Reject ivars that use flexible array members.  */
 /* Contributed by Nicola Pero  <nicola.pero@meta-innovation.com> */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 typedef struct
 {
diff --git a/gcc/testsuite/objc.dg/type-size-4.m b/gcc/testsuite/objc.dg/type-size-4.m
index 7e26da34a43..f10ed5b0118 100644
--- a/gcc/testsuite/objc.dg/type-size-4.m
+++ b/gcc/testsuite/objc.dg/type-size-4.m
@@ -2,6 +2,7 @@
 /* Contributed by Nicola Pero  <nicola.pero@meta-innovation.com> */
 /* PR objc/47832 */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 typedef struct
 {
diff --git a/gcc/testsuite/objc.dg/type-size-5.m b/gcc/testsuite/objc.dg/type-size-5.m
index d89af32b452..e1b11f7eef5 100644
--- a/gcc/testsuite/objc.dg/type-size-5.m
+++ b/gcc/testsuite/objc.dg/type-size-5.m
@@ -1,6 +1,7 @@
 /* Reject ivars that use flexible array members.  */
 /* Contributed by Nicola Pero  <nicola.pero@meta-innovation.com> */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 typedef struct
 {
diff --git a/gcc/testsuite/objc.dg/undeclared-selector.m b/gcc/testsuite/objc.dg/undeclared-selector.m
index 1cfc6c83481..389b0321817 100644
--- a/gcc/testsuite/objc.dg/undeclared-selector.m
+++ b/gcc/testsuite/objc.dg/undeclared-selector.m
@@ -2,6 +2,7 @@
 /* Author: Nicola Pero <nicola@brainstorm.co.uk>.  */
 /* { dg-do compile } */
 /* { dg-options "-Wundeclared-selector" } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/objc.dg/volatile-1.m b/gcc/testsuite/objc.dg/volatile-1.m
index 8b5381a9874..a7136316392 100644
--- a/gcc/testsuite/objc.dg/volatile-1.m
+++ b/gcc/testsuite/objc.dg/volatile-1.m
@@ -1,7 +1,8 @@
 /* Test for proper handling of volatile parameters in ObjC methods.  */
+/* Contributed by Ziemowit Laski  <zlaski@apple.com>  */
 /* { dg-do compile } */
 /* { dg-options "-O2" } */
-/* Contributed by Ziemowit Laski  <zlaski@apple.com>  */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 @interface Test
 -(void) test2: (volatile int) a;
-- 
2.24.1
From 611f4d600a7b0bf236b26806897be4fb195c7a1d Mon Sep 17 00:00:00 2001
From: Iain Sandoe <iain@sandoe.co.uk>

Date: Sun, 25 Oct 2020 09:54:21 +0000
Subject: [PATCH 3/3] Objective-C [3/3] : Implement Wobjc-root-class [PR77404].

Add Wno-objc-root-class where needed to the objective-c++
tests.

gcc/testsuite/ChangeLog:

	PR objc/77404
	* obj-c++.dg/attributes/class-attribute-1.mm:
	Add Wno-objc-root-class.
	* obj-c++.dg/attributes/class-attribute-2.mm: Likewise.
	* obj-c++.dg/attributes/class-attribute-3.mm: Likewise.
	* obj-c++.dg/attributes/method-deprecated-1.mm: Likewise.
	* obj-c++.dg/attributes/method-deprecated-2.mm: Likewise.
	* obj-c++.dg/attributes/method-deprecated-3.mm: Likewise.
	* obj-c++.dg/attributes/method-format-1.mm: Likewise.
	* obj-c++.dg/attributes/method-nonnull-1.mm: Likewise.
	* obj-c++.dg/attributes/method-noreturn-1.mm: Likewise.
	* obj-c++.dg/attributes/method-sentinel-1.mm: Likewise.
	* obj-c++.dg/attributes/nsobject-01.mm: Likewise.
	* obj-c++.dg/attributes/parameter-attribute-1.mm: Likewise.
	* obj-c++.dg/attributes/parameter-attribute-2.mm: Likewise.
	* obj-c++.dg/attributes/proto-attribute-1.mm: Likewise.
	* obj-c++.dg/attributes/proto-attribute-3.mm: Likewise.
	* obj-c++.dg/attributes/proto-attribute-4.mm: Likewise.
	* obj-c++.dg/attributes/unused-parameter-1.mm: Likewise.
	* obj-c++.dg/bad-receiver-type.mm: Likewise.
	* obj-c++.dg/bitfield-3.mm: Likewise.
	* obj-c++.dg/bitfield-5.mm: Likewise.
	* obj-c++.dg/class-extension-1.mm: Likewise.
	* obj-c++.dg/class-extension-2.mm: Likewise.
	* obj-c++.dg/class-extension-3.mm: Likewise.
	* obj-c++.dg/class-extension-4.mm: Likewise.
	* obj-c++.dg/class-protocol-1.mm: Likewise.
	* obj-c++.dg/comp-types-1.mm: Likewise.
	* obj-c++.dg/comp-types-10.mm: Likewise.
	* obj-c++.dg/comp-types-2.mm: Likewise.
	* obj-c++.dg/comp-types-3.mm: Likewise.
	* obj-c++.dg/comp-types-5.mm: Likewise.
	* obj-c++.dg/comp-types-6.mm: Likewise.
	* obj-c++.dg/comp-types-7.mm: Likewise.
	* obj-c++.dg/comp-types-8.mm: Likewise.
	* obj-c++.dg/demangle-2.mm: Likewise.
	* obj-c++.dg/demangle-3.mm: Likewise.
	* obj-c++.dg/duplicate-class-1.mm: Likewise.
	* obj-c++.dg/encode-1-next.mm: Likewise.
	* obj-c++.dg/encode-1.mm: Likewise.
	* obj-c++.dg/enhanced-proto-2.mm: Likewise.
	* obj-c++.dg/exceptions-1.mm: Likewise.
	* obj-c++.dg/exceptions-3.mm: Likewise.
	* obj-c++.dg/exceptions-4.mm: Likewise.
	* obj-c++.dg/exceptions-5.mm: Likewise.
	* obj-c++.dg/extern-c-1.mm: Likewise.
	* obj-c++.dg/fobjc-std-1.mm: Likewise.
	* obj-c++.dg/gnu-api-2-class-meta.mm: Likewise.
	* obj-c++.dg/gnu-api-2-class.mm: Likewise.
	* obj-c++.dg/gnu-api-2-ivar.mm: Likewise.
	* obj-c++.dg/gnu-api-2-method.mm: Likewise.
	* obj-c++.dg/gnu-api-2-objc.mm: Likewise.
	* obj-c++.dg/gnu-api-2-objc_msg_lookup.mm Likewise.:
	* obj-c++.dg/gnu-api-2-object.mm: Likewise.
	* obj-c++.dg/gnu-api-2-property.mm: Likewise.
	* obj-c++.dg/gnu-api-2-protocol.mm: Likewise.
	* obj-c++.dg/gnu-api-2-resolve-method.mm: Likewise.
	* obj-c++.dg/gnu-api-2-sel.mm: Likewise.
	* obj-c++.dg/invalid-method-2.mm: Likewise.
	* obj-c++.dg/ivar-invalid-type-1.mm: Likewise.
	* obj-c++.dg/ivar-problem-1.mm: Likewise.
	* obj-c++.dg/lto/lto.exp: Likewise.
	* obj-c++.dg/lto/trivial-1_0.mm: Likewise.
	* obj-c++.dg/method-1.mm: Likewise.
	* obj-c++.dg/method-12.mm: Likewise.
	* obj-c++.dg/method-18.mm: Likewise.
	* obj-c++.dg/method-19.mm: Likewise.
	* obj-c++.dg/method-20.mm: Likewise.
	* obj-c++.dg/method-3.mm: Likewise.
	* obj-c++.dg/method-4.mm: Likewise.
	* obj-c++.dg/method-5.mm: Likewise.
	* obj-c++.dg/method-8.mm: Likewise.
	* obj-c++.dg/method-9.mm: Likewise.
	* obj-c++.dg/method-namespace-1.mm: Likewise.
	* obj-c++.dg/plugin/diagnostic-test-expressions-1.mm:
	Likewise.
	* obj-c++.dg/pr23709.mm: Likewise.
	* obj-c++.dg/pragma-2.mm: Likewise.
	* obj-c++.dg/private-1.mm: Likewise.
	* obj-c++.dg/private-2.mm: Likewise.
	* obj-c++.dg/property/property.exp: Likewise.
	* obj-c++.dg/proto-lossage-1.mm: Likewise.
	* obj-c++.dg/proto-lossage-5.mm: Likewise.
	* obj-c++.dg/proto-qual-1.mm: Likewise.
	* obj-c++.dg/protocol-inheritance-1.mm: Likewise.
	* obj-c++.dg/protocol-inheritance-2.mm: Likewise.
	* obj-c++.dg/protocol-optional-1.mm: Likewise.
	* obj-c++.dg/selector-1.mm: Likewise.
	* obj-c++.dg/selector-2.mm: Likewise.
	* obj-c++.dg/selector-3.mm: Likewise.
	* obj-c++.dg/selector-4.mm: Likewise.
	* obj-c++.dg/strings/strings.exp: Likewise.
	* obj-c++.dg/stubify-1.mm: Likewise.
	* obj-c++.dg/stubify-2.mm: Likewise.
	* obj-c++.dg/super-dealloc-1.mm: Likewise.
	* obj-c++.dg/super-dealloc-2.mm: Likewise.
	* obj-c++.dg/sync-3.mm: Likewise.
	* obj-c++.dg/syntax-error-2.mm: Likewise.
	* obj-c++.dg/syntax-error-4.mm: Likewise.
	* obj-c++.dg/syntax-error-7.mm: Likewise.
	* obj-c++.dg/syntax-error-9.mm: Likewise.
	* obj-c++.dg/template-4.mm: Likewise.
	* obj-c++.dg/template-7.mm: Likewise.
	* obj-c++.dg/template-8.mm: Likewise.
	* obj-c++.dg/threedotthree-abi-1.mm: Likewise.
	* obj-c++.dg/torture/dg-torture.exp: Likewise.
	* obj-c++.dg/torture/strings/strings.exp: Likewise.
	* obj-c++.dg/try-catch-12.mm: Likewise.
	* obj-c++.dg/try-catch-13.mm: Likewise.
---
 .../obj-c++.dg/attributes/class-attribute-1.mm   |  1 +
 .../obj-c++.dg/attributes/class-attribute-2.mm   |  1 +
 .../obj-c++.dg/attributes/class-attribute-3.mm   |  1 +
 .../obj-c++.dg/attributes/method-deprecated-1.mm |  1 +
 .../obj-c++.dg/attributes/method-deprecated-2.mm |  1 +
 .../obj-c++.dg/attributes/method-deprecated-3.mm |  1 +
 .../obj-c++.dg/attributes/method-format-1.mm     |  1 +
 .../obj-c++.dg/attributes/method-nonnull-1.mm    |  1 +
 .../obj-c++.dg/attributes/method-noreturn-1.mm   |  1 +
 .../obj-c++.dg/attributes/method-sentinel-1.mm   |  1 +
 .../obj-c++.dg/attributes/nsobject-01.mm         |  2 +-
 .../attributes/parameter-attribute-1.mm          |  1 +
 .../attributes/parameter-attribute-2.mm          |  1 +
 .../obj-c++.dg/attributes/proto-attribute-1.mm   |  1 +
 .../obj-c++.dg/attributes/proto-attribute-3.mm   |  2 +-
 .../obj-c++.dg/attributes/proto-attribute-4.mm   |  1 +
 .../obj-c++.dg/attributes/unused-parameter-1.mm  |  1 +
 gcc/testsuite/obj-c++.dg/bad-receiver-type.mm    |  1 +
 gcc/testsuite/obj-c++.dg/bitfield-3.mm           |  1 +
 gcc/testsuite/obj-c++.dg/bitfield-5.mm           |  1 +
 gcc/testsuite/obj-c++.dg/class-extension-1.mm    |  1 +
 gcc/testsuite/obj-c++.dg/class-extension-2.mm    |  1 +
 gcc/testsuite/obj-c++.dg/class-extension-3.mm    |  1 +
 gcc/testsuite/obj-c++.dg/class-extension-4.mm    |  1 +
 gcc/testsuite/obj-c++.dg/class-protocol-1.mm     |  1 +
 gcc/testsuite/obj-c++.dg/comp-types-1.mm         |  1 +
 gcc/testsuite/obj-c++.dg/comp-types-10.mm        |  1 +
 gcc/testsuite/obj-c++.dg/comp-types-2.mm         |  1 +
 gcc/testsuite/obj-c++.dg/comp-types-3.mm         |  1 +
 gcc/testsuite/obj-c++.dg/comp-types-5.mm         |  1 +
 gcc/testsuite/obj-c++.dg/comp-types-6.mm         |  1 +
 gcc/testsuite/obj-c++.dg/comp-types-7.mm         |  1 +
 gcc/testsuite/obj-c++.dg/comp-types-8.mm         |  1 +
 gcc/testsuite/obj-c++.dg/demangle-2.mm           |  1 +
 gcc/testsuite/obj-c++.dg/demangle-3.mm           |  1 +
 gcc/testsuite/obj-c++.dg/duplicate-class-1.mm    |  1 +
 gcc/testsuite/obj-c++.dg/encode-1-next.mm        |  1 +
 gcc/testsuite/obj-c++.dg/encode-1.mm             |  1 +
 gcc/testsuite/obj-c++.dg/enhanced-proto-2.mm     |  1 +
 gcc/testsuite/obj-c++.dg/exceptions-1.mm         |  1 +
 gcc/testsuite/obj-c++.dg/exceptions-3.mm         |  1 +
 gcc/testsuite/obj-c++.dg/exceptions-4.mm         |  1 +
 gcc/testsuite/obj-c++.dg/exceptions-5.mm         |  1 +
 gcc/testsuite/obj-c++.dg/extern-c-1.mm           |  1 +
 gcc/testsuite/obj-c++.dg/fobjc-std-1.mm          |  1 +
 gcc/testsuite/obj-c++.dg/gnu-api-2-class-meta.mm |  1 +
 gcc/testsuite/obj-c++.dg/gnu-api-2-class.mm      |  1 +
 gcc/testsuite/obj-c++.dg/gnu-api-2-ivar.mm       |  1 +
 gcc/testsuite/obj-c++.dg/gnu-api-2-method.mm     |  1 +
 gcc/testsuite/obj-c++.dg/gnu-api-2-objc.mm       |  1 +
 .../obj-c++.dg/gnu-api-2-objc_msg_lookup.mm      |  1 +
 gcc/testsuite/obj-c++.dg/gnu-api-2-object.mm     |  1 +
 gcc/testsuite/obj-c++.dg/gnu-api-2-property.mm   |  1 +
 gcc/testsuite/obj-c++.dg/gnu-api-2-protocol.mm   |  1 +
 .../obj-c++.dg/gnu-api-2-resolve-method.mm       |  1 +
 gcc/testsuite/obj-c++.dg/gnu-api-2-sel.mm        |  1 +
 gcc/testsuite/obj-c++.dg/invalid-method-2.mm     |  1 +
 gcc/testsuite/obj-c++.dg/ivar-invalid-type-1.mm  |  1 +
 gcc/testsuite/obj-c++.dg/ivar-problem-1.mm       |  1 +
 gcc/testsuite/obj-c++.dg/lto/lto.exp             | 16 ++++++++--------
 gcc/testsuite/obj-c++.dg/lto/trivial-1_0.mm      |  2 +-
 gcc/testsuite/obj-c++.dg/method-1.mm             |  1 +
 gcc/testsuite/obj-c++.dg/method-12.mm            |  1 +
 gcc/testsuite/obj-c++.dg/method-18.mm            |  1 +
 gcc/testsuite/obj-c++.dg/method-19.mm            |  1 +
 gcc/testsuite/obj-c++.dg/method-20.mm            |  1 +
 gcc/testsuite/obj-c++.dg/method-3.mm             |  1 +
 gcc/testsuite/obj-c++.dg/method-4.mm             |  1 +
 gcc/testsuite/obj-c++.dg/method-5.mm             |  1 +
 gcc/testsuite/obj-c++.dg/method-8.mm             |  1 +
 gcc/testsuite/obj-c++.dg/method-9.mm             |  1 +
 gcc/testsuite/obj-c++.dg/method-namespace-1.mm   |  1 +
 .../plugin/diagnostic-test-expressions-1.mm      |  1 +
 gcc/testsuite/obj-c++.dg/pr23709.mm              |  1 +
 gcc/testsuite/obj-c++.dg/pragma-2.mm             |  1 +
 gcc/testsuite/obj-c++.dg/private-1.mm            |  1 +
 gcc/testsuite/obj-c++.dg/private-2.mm            |  1 +
 gcc/testsuite/obj-c++.dg/property/property.exp   |  4 ++--
 gcc/testsuite/obj-c++.dg/proto-lossage-1.mm      |  1 +
 gcc/testsuite/obj-c++.dg/proto-lossage-5.mm      |  1 +
 gcc/testsuite/obj-c++.dg/proto-qual-1.mm         |  1 +
 .../obj-c++.dg/protocol-inheritance-1.mm         |  1 +
 .../obj-c++.dg/protocol-inheritance-2.mm         |  1 +
 gcc/testsuite/obj-c++.dg/protocol-optional-1.mm  |  1 +
 gcc/testsuite/obj-c++.dg/selector-1.mm           |  1 +
 gcc/testsuite/obj-c++.dg/selector-2.mm           |  1 +
 gcc/testsuite/obj-c++.dg/selector-3.mm           |  1 +
 gcc/testsuite/obj-c++.dg/selector-4.mm           |  1 +
 gcc/testsuite/obj-c++.dg/strings/strings.exp     |  4 ++--
 gcc/testsuite/obj-c++.dg/stubify-1.mm            |  1 +
 gcc/testsuite/obj-c++.dg/stubify-2.mm            |  1 +
 gcc/testsuite/obj-c++.dg/super-dealloc-1.mm      |  1 +
 gcc/testsuite/obj-c++.dg/super-dealloc-2.mm      |  1 +
 gcc/testsuite/obj-c++.dg/sync-3.mm               |  1 +
 gcc/testsuite/obj-c++.dg/syntax-error-2.mm       |  1 +
 gcc/testsuite/obj-c++.dg/syntax-error-4.mm       |  1 +
 gcc/testsuite/obj-c++.dg/syntax-error-7.mm       |  1 +
 gcc/testsuite/obj-c++.dg/syntax-error-9.mm       |  1 +
 gcc/testsuite/obj-c++.dg/template-4.mm           |  1 +
 gcc/testsuite/obj-c++.dg/template-7.mm           |  1 +
 gcc/testsuite/obj-c++.dg/template-8.mm           |  1 +
 gcc/testsuite/obj-c++.dg/threedotthree-abi-1.mm  |  1 +
 gcc/testsuite/obj-c++.dg/torture/dg-torture.exp  |  4 ++--
 .../obj-c++.dg/torture/strings/strings.exp       |  4 ++--
 gcc/testsuite/obj-c++.dg/try-catch-12.mm         |  1 +
 gcc/testsuite/obj-c++.dg/try-catch-13.mm         |  1 +
 106 files changed, 117 insertions(+), 19 deletions(-)

diff --git a/gcc/testsuite/obj-c++.dg/attributes/class-attribute-1.mm b/gcc/testsuite/obj-c++.dg/attributes/class-attribute-1.mm
index f078339b867..7eafdbc926e 100644
--- a/gcc/testsuite/obj-c++.dg/attributes/class-attribute-1.mm
+++ b/gcc/testsuite/obj-c++.dg/attributes/class-attribute-1.mm
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* Test deprecate attribute with an @interface declaration.  */
 
diff --git a/gcc/testsuite/obj-c++.dg/attributes/class-attribute-2.mm b/gcc/testsuite/obj-c++.dg/attributes/class-attribute-2.mm
index 35015c0370a..629ba864b94 100644
--- a/gcc/testsuite/obj-c++.dg/attributes/class-attribute-2.mm
+++ b/gcc/testsuite/obj-c++.dg/attributes/class-attribute-2.mm
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/attributes/class-attribute-3.mm b/gcc/testsuite/obj-c++.dg/attributes/class-attribute-3.mm
index f96500de4dc..3b7c8c38481 100644
--- a/gcc/testsuite/obj-c++.dg/attributes/class-attribute-3.mm
+++ b/gcc/testsuite/obj-c++.dg/attributes/class-attribute-3.mm
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* Test that you get a warning when an unknown class attribute is ignored.  */
 
diff --git a/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-1.mm b/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-1.mm
index 8343856a5c6..68e8373920d 100644
--- a/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-1.mm
+++ b/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-1.mm
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-2.mm b/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-2.mm
index 1e5d87f3e63..8fb0e1510d0 100644
--- a/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-2.mm
+++ b/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-2.mm
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-3.mm b/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-3.mm
index 5c715a20b68..efa2d349557 100644
--- a/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-3.mm
+++ b/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-3.mm
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/attributes/method-format-1.mm b/gcc/testsuite/obj-c++.dg/attributes/method-format-1.mm
index 9ff34f92fb1..d3bb997b2aa 100644
--- a/gcc/testsuite/obj-c++.dg/attributes/method-format-1.mm
+++ b/gcc/testsuite/obj-c++.dg/attributes/method-format-1.mm
@@ -1,6 +1,7 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010.  */
 /* { dg-do compile } */
 /* { dg-options "-Wall" } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 #include <stdlib.h>
diff --git a/gcc/testsuite/obj-c++.dg/attributes/method-nonnull-1.mm b/gcc/testsuite/obj-c++.dg/attributes/method-nonnull-1.mm
index 83f918c5a3f..af48787d765 100644
--- a/gcc/testsuite/obj-c++.dg/attributes/method-nonnull-1.mm
+++ b/gcc/testsuite/obj-c++.dg/attributes/method-nonnull-1.mm
@@ -1,6 +1,7 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, May 2011.  */
 /* { dg-do compile } */
 /* { dg-options "-Wall" } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 #include <stdlib.h>
diff --git a/gcc/testsuite/obj-c++.dg/attributes/method-noreturn-1.mm b/gcc/testsuite/obj-c++.dg/attributes/method-noreturn-1.mm
index a83048bb7ed..413a0be4b2b 100644
--- a/gcc/testsuite/obj-c++.dg/attributes/method-noreturn-1.mm
+++ b/gcc/testsuite/obj-c++.dg/attributes/method-noreturn-1.mm
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 #include <stdlib.h>
diff --git a/gcc/testsuite/obj-c++.dg/attributes/method-sentinel-1.mm b/gcc/testsuite/obj-c++.dg/attributes/method-sentinel-1.mm
index 2b8e6fd259d..ece7a9f9caa 100644
--- a/gcc/testsuite/obj-c++.dg/attributes/method-sentinel-1.mm
+++ b/gcc/testsuite/obj-c++.dg/attributes/method-sentinel-1.mm
@@ -1,6 +1,7 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010.  */
 /* { dg-do compile } */
 /* { dg-options "-Wall" } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 #include <stdlib.h>
diff --git a/gcc/testsuite/obj-c++.dg/attributes/nsobject-01.mm b/gcc/testsuite/obj-c++.dg/attributes/nsobject-01.mm
index 498fbc7e8fd..3af785b9aef 100644
--- a/gcc/testsuite/obj-c++.dg/attributes/nsobject-01.mm
+++ b/gcc/testsuite/obj-c++.dg/attributes/nsobject-01.mm
@@ -1,5 +1,5 @@
 /* Test handling of the NSObject attribute.  */
-/*  { dg-additional-options "-fsyntax-only " } */
+/* { dg-additional-options "-fsyntax-only -Wno-objc-root-class" } */
 
 typedef struct AnObj * __attribute__ ((NSObject)) AnObjRef;
 typedef struct AnObj * __attribute__ ((__NSObject__)) AnotherObjRef;
diff --git a/gcc/testsuite/obj-c++.dg/attributes/parameter-attribute-1.mm b/gcc/testsuite/obj-c++.dg/attributes/parameter-attribute-1.mm
index a4ba25943ca..b4556ba0788 100644
--- a/gcc/testsuite/obj-c++.dg/attributes/parameter-attribute-1.mm
+++ b/gcc/testsuite/obj-c++.dg/attributes/parameter-attribute-1.mm
@@ -1,6 +1,7 @@
 /* Test __attribute__((unused)) for an Objective-C method parameter.  */
 /* { dg-do compile } */
 /* { dg-options "-Wunused-parameter" } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/attributes/parameter-attribute-2.mm b/gcc/testsuite/obj-c++.dg/attributes/parameter-attribute-2.mm
index 3908faf99d9..9d69e4209c8 100644
--- a/gcc/testsuite/obj-c++.dg/attributes/parameter-attribute-2.mm
+++ b/gcc/testsuite/obj-c++.dg/attributes/parameter-attribute-2.mm
@@ -1,5 +1,6 @@
 /* Test that we get warnings for unrecognized attributes.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-1.mm b/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-1.mm
index a852a7a6c2f..03726dc7bed 100644
--- a/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-1.mm
+++ b/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-1.mm
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-3.mm b/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-3.mm
index fc5251eeea1..263f92757b0 100644
--- a/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-3.mm
+++ b/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-3.mm
@@ -1,7 +1,7 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
 /* { dg-do compile } */
 /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
-
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* Test deprecate attribute with normal @protocol declarations.  */
 
diff --git a/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-4.mm b/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-4.mm
index d2e5f28a1b4..665e13da643 100644
--- a/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-4.mm
+++ b/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-4.mm
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 /* Test that you get a warning when an unknown protocol attribute is ignored.  */
 
diff --git a/gcc/testsuite/obj-c++.dg/attributes/unused-parameter-1.mm b/gcc/testsuite/obj-c++.dg/attributes/unused-parameter-1.mm
index 8fbb11e2014..c56a7f7d68c 100644
--- a/gcc/testsuite/obj-c++.dg/attributes/unused-parameter-1.mm
+++ b/gcc/testsuite/obj-c++.dg/attributes/unused-parameter-1.mm
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-additional-options "-Wno-objc-root-class" } */
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/bad-receiver-type.mm b/gcc/testsuite/obj-c++.dg/bad-receiver-type.mm
index 1d6699f99c5..9c00a068168 100644
--- a/gcc/testsuite/obj-c++.dg/bad-receiver-type.mm
+++ b/gcc/testsuite/obj-c++.dg/bad-receiver-type.mm
@@ -1,5 +1,6 @@
 // { dg-do compile } 
 // { dg-options "" }
+// { dg-additional-options "-Wno-objc-root-class" }
 
 @interface A
 
diff --git a/gcc/testsuite/obj-c++.dg/bitfield-3.mm b/gcc/testsuite/obj-c++.dg/bitfield-3.mm
index d81976ab624..c4ed984ef52 100644
--- a/gcc/testsuite/obj-c++.dg/bitfield-3.mm
+++ b/gcc/testsuite/obj-c++.dg/bitfield-3.mm
@@ -4,6 +4,7 @@
 /* { dg-do run { target *-*-darwin* } } */
 /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
 /* { dg-options "-fsigned-char" } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 typedef struct objc_object { struct objc_class *class_pointer; } *id;
 
diff --git a/gcc/testsuite/obj-c++.dg/bitfield-5.mm b/gcc/testsuite/obj-c++.dg/bitfield-5.mm
index 3b0065d7f61..d86c9b135d2 100644
--- a/gcc/testsuite/obj-c++.dg/bitfield-5.mm
+++ b/gcc/testsuite/obj-c++.dg/bitfield-5.mm
@@ -3,6 +3,7 @@
   (@interface vs. @implementation) checks take the bitfield width into account.  */
 /* Author: Ziemowit Laski   <zlaski@apple.com>  */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 @interface Base {
   int i;
diff --git a/gcc/testsuite/obj-c++.dg/class-extension-1.mm b/gcc/testsuite/obj-c++.dg/class-extension-1.mm
index 5c89a9838cf..c497c1d938d 100644
--- a/gcc/testsuite/obj-c++.dg/class-extension-1.mm
+++ b/gcc/testsuite/obj-c++.dg/class-extension-1.mm
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* This test tests the basic of class extensions.  */
 
diff --git a/gcc/testsuite/obj-c++.dg/class-extension-2.mm b/gcc/testsuite/obj-c++.dg/class-extension-2.mm
index 7f55b601fb3..108bc001d0e 100644
--- a/gcc/testsuite/obj-c++.dg/class-extension-2.mm
+++ b/gcc/testsuite/obj-c++.dg/class-extension-2.mm
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* This test tests class extensions and protocols.  */
 
diff --git a/gcc/testsuite/obj-c++.dg/class-extension-3.mm b/gcc/testsuite/obj-c++.dg/class-extension-3.mm
index 69e57053969..bed849030d6 100644
--- a/gcc/testsuite/obj-c++.dg/class-extension-3.mm
+++ b/gcc/testsuite/obj-c++.dg/class-extension-3.mm
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* This test tests warnings on class extensions.  */
 
diff --git a/gcc/testsuite/obj-c++.dg/class-extension-4.mm b/gcc/testsuite/obj-c++.dg/class-extension-4.mm
index 9e19aa70d3b..2cfbc5dd0e5 100644
--- a/gcc/testsuite/obj-c++.dg/class-extension-4.mm
+++ b/gcc/testsuite/obj-c++.dg/class-extension-4.mm
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* This test tests you can not declare a class extension after the class @implementation.  */
 
diff --git a/gcc/testsuite/obj-c++.dg/class-protocol-1.mm b/gcc/testsuite/obj-c++.dg/class-protocol-1.mm
index 78957cb061e..3b332643a60 100644
--- a/gcc/testsuite/obj-c++.dg/class-protocol-1.mm
+++ b/gcc/testsuite/obj-c++.dg/class-protocol-1.mm
@@ -1,6 +1,7 @@
 /* Check Class <protocol> types */
 /* Author: David Ayers <d.ayers@inode.at> */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <objc/objc.h>
 #include "../objc-obj-c++-shared/runtime.h"
diff --git a/gcc/testsuite/obj-c++.dg/comp-types-1.mm b/gcc/testsuite/obj-c++.dg/comp-types-1.mm
index 6d4e86e4b2a..6402abc213b 100644
--- a/gcc/testsuite/obj-c++.dg/comp-types-1.mm
+++ b/gcc/testsuite/obj-c++.dg/comp-types-1.mm
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 @interface A
 + new;
diff --git a/gcc/testsuite/obj-c++.dg/comp-types-10.mm b/gcc/testsuite/obj-c++.dg/comp-types-10.mm
index c7f0cb635c7..fdfd0933b89 100644
--- a/gcc/testsuite/obj-c++.dg/comp-types-10.mm
+++ b/gcc/testsuite/obj-c++.dg/comp-types-10.mm
@@ -2,6 +2,7 @@
 /* { dg-do compile } */
 /* { dg-prune-output ".*internal compiler error.*" } */
 /* { dg-options "-O3" } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 @class NSString;
 @protocol NSObject
diff --git a/gcc/testsuite/obj-c++.dg/comp-types-2.mm b/gcc/testsuite/obj-c++.dg/comp-types-2.mm
index 07043785a22..87750fd67df 100644
--- a/gcc/testsuite/obj-c++.dg/comp-types-2.mm
+++ b/gcc/testsuite/obj-c++.dg/comp-types-2.mm
@@ -1,6 +1,7 @@
 /* Test various ObjC types assignments and comparisons.  */
 /* Author: Nicola Pero <nicola@brainstorm.co.uk>.  */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/comp-types-3.mm b/gcc/testsuite/obj-c++.dg/comp-types-3.mm
index 2bea01534a7..d4d0790afcc 100644
--- a/gcc/testsuite/obj-c++.dg/comp-types-3.mm
+++ b/gcc/testsuite/obj-c++.dg/comp-types-3.mm
@@ -1,6 +1,7 @@
 /* Test simple ObjC types casts.  */
 /* Author: Nicola Pero <nicola@brainstorm.co.uk>.  */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/comp-types-5.mm b/gcc/testsuite/obj-c++.dg/comp-types-5.mm
index 99f6772bd42..2c4fc57f0ac 100644
--- a/gcc/testsuite/obj-c++.dg/comp-types-5.mm
+++ b/gcc/testsuite/obj-c++.dg/comp-types-5.mm
@@ -1,6 +1,7 @@
 /* Test errors for assignments and comparisons between ObjC and C++ types.  */
 /* Author: Nicola Pero <nicola@brainstorm.co.uk>.  */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/comp-types-6.mm b/gcc/testsuite/obj-c++.dg/comp-types-6.mm
index 23b84edd374..071a7563b89 100644
--- a/gcc/testsuite/obj-c++.dg/comp-types-6.mm
+++ b/gcc/testsuite/obj-c++.dg/comp-types-6.mm
@@ -1,6 +1,7 @@
 /* Test assignments and comparisons involving `one-off' protocols.  */
 /* Author: Nicola Pero <nicola@brainstorm.co.uk>.  */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/comp-types-7.mm b/gcc/testsuite/obj-c++.dg/comp-types-7.mm
index e23558114bc..628635575f5 100644
--- a/gcc/testsuite/obj-c++.dg/comp-types-7.mm
+++ b/gcc/testsuite/obj-c++.dg/comp-types-7.mm
@@ -1,6 +1,7 @@
 /* Test assignments and comparisons involving category protocols.  */
 /* Author: Nicola Pero <nicola@brainstorm.co.uk>.  */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/comp-types-8.mm b/gcc/testsuite/obj-c++.dg/comp-types-8.mm
index 6db76bb20f3..0221164ac85 100644
--- a/gcc/testsuite/obj-c++.dg/comp-types-8.mm
+++ b/gcc/testsuite/obj-c++.dg/comp-types-8.mm
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-additional-options "-Wno-return-type" } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* We used to ICE because we removed the cast to List_linked*
    in -[ListIndex_linked next]. */
diff --git a/gcc/testsuite/obj-c++.dg/demangle-2.mm b/gcc/testsuite/obj-c++.dg/demangle-2.mm
index f2820859137..14c7b3e18f8 100644
--- a/gcc/testsuite/obj-c++.dg/demangle-2.mm
+++ b/gcc/testsuite/obj-c++.dg/demangle-2.mm
@@ -1,6 +1,7 @@
 /* Test demangling an Objective-C method.  */
 /* { dg-do run } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <cstring>
 #include <cstdlib>
diff --git a/gcc/testsuite/obj-c++.dg/demangle-3.mm b/gcc/testsuite/obj-c++.dg/demangle-3.mm
index afb83d75bfe..d8d81784f86 100644
--- a/gcc/testsuite/obj-c++.dg/demangle-3.mm
+++ b/gcc/testsuite/obj-c++.dg/demangle-3.mm
@@ -1,6 +1,7 @@
 /* Test demangling an Objective-C method in error messages.  */
 /* { dg-do compile } */
 /* { dg-additional-options "-Wno-return-type" } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/duplicate-class-1.mm b/gcc/testsuite/obj-c++.dg/duplicate-class-1.mm
index 3a5e5104faa..77e52c6893f 100644
--- a/gcc/testsuite/obj-c++.dg/duplicate-class-1.mm
+++ b/gcc/testsuite/obj-c++.dg/duplicate-class-1.mm
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* Test that a duplicated @implementation for the same class does not
    crash the compiler.  */
diff --git a/gcc/testsuite/obj-c++.dg/encode-1-next.mm b/gcc/testsuite/obj-c++.dg/encode-1-next.mm
index 47673f20cb2..854dd728691 100644
--- a/gcc/testsuite/obj-c++.dg/encode-1-next.mm
+++ b/gcc/testsuite/obj-c++.dg/encode-1-next.mm
@@ -5,6 +5,7 @@
 
 /* { dg-do compile } */
 /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 struct Cxx {
   const struct Cxx *next;
diff --git a/gcc/testsuite/obj-c++.dg/encode-1.mm b/gcc/testsuite/obj-c++.dg/encode-1.mm
index 5f5ba20139e..6247c648274 100644
--- a/gcc/testsuite/obj-c++.dg/encode-1.mm
+++ b/gcc/testsuite/obj-c++.dg/encode-1.mm
@@ -3,6 +3,7 @@
 
 /* { dg-do compile } */
 /* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 struct Cxx {
   const struct Cxx *next;
diff --git a/gcc/testsuite/obj-c++.dg/enhanced-proto-2.mm b/gcc/testsuite/obj-c++.dg/enhanced-proto-2.mm
index 31c2e509b7a..5964dfb0968 100644
--- a/gcc/testsuite/obj-c++.dg/enhanced-proto-2.mm
+++ b/gcc/testsuite/obj-c++.dg/enhanced-proto-2.mm
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 @protocol MyProto1 
 @optional
diff --git a/gcc/testsuite/obj-c++.dg/exceptions-1.mm b/gcc/testsuite/obj-c++.dg/exceptions-1.mm
index 0f3b7e8ae14..75327ef7a9f 100644
--- a/gcc/testsuite/obj-c++.dg/exceptions-1.mm
+++ b/gcc/testsuite/obj-c++.dg/exceptions-1.mm
@@ -1,6 +1,7 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
 /* { dg-options "-fobjc-exceptions" } */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* This test checks the syntax @catch (...) which catches any
    exceptions.  At the moment, @catch (...) is identical to @catch (id
diff --git a/gcc/testsuite/obj-c++.dg/exceptions-3.mm b/gcc/testsuite/obj-c++.dg/exceptions-3.mm
index 622e4ca3b60..7cf77a7821a 100644
--- a/gcc/testsuite/obj-c++.dg/exceptions-3.mm
+++ b/gcc/testsuite/obj-c++.dg/exceptions-3.mm
@@ -1,6 +1,7 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
 /* { dg-options "-fobjc-exceptions" } */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* Test that the compiler is checking the argument of @catch(), and
    produce errors when invalid types are used.  */
diff --git a/gcc/testsuite/obj-c++.dg/exceptions-4.mm b/gcc/testsuite/obj-c++.dg/exceptions-4.mm
index 4aa00a6006f..1391c43b8e5 100644
--- a/gcc/testsuite/obj-c++.dg/exceptions-4.mm
+++ b/gcc/testsuite/obj-c++.dg/exceptions-4.mm
@@ -1,6 +1,7 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
 /* { dg-options "-fobjc-exceptions" } */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* Test warnings when parsing syntax errors in @catch().  */
 
diff --git a/gcc/testsuite/obj-c++.dg/exceptions-5.mm b/gcc/testsuite/obj-c++.dg/exceptions-5.mm
index 5aa08f35821..4547a756c74 100644
--- a/gcc/testsuite/obj-c++.dg/exceptions-5.mm
+++ b/gcc/testsuite/obj-c++.dg/exceptions-5.mm
@@ -1,6 +1,7 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
 /* { dg-options "-fobjc-exceptions" } */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* Test that you can use an unnamed argument with @catch.  This test is the same
    as exceptions-3.mm, but with no name for @catch arguments.  */
diff --git a/gcc/testsuite/obj-c++.dg/extern-c-1.mm b/gcc/testsuite/obj-c++.dg/extern-c-1.mm
index c5fec6fbe93..8b9147a807e 100644
--- a/gcc/testsuite/obj-c++.dg/extern-c-1.mm
+++ b/gcc/testsuite/obj-c++.dg/extern-c-1.mm
@@ -1,5 +1,6 @@
 /* Test extern c support inside @implementation */
 /* Devang Patel  <dpatel@apple.com>.  */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/fobjc-std-1.mm b/gcc/testsuite/obj-c++.dg/fobjc-std-1.mm
index 59db95091db..f7f4a199dc0 100644
--- a/gcc/testsuite/obj-c++.dg/fobjc-std-1.mm
+++ b/gcc/testsuite/obj-c++.dg/fobjc-std-1.mm
@@ -1,6 +1,7 @@
 /* Test warnings when using -fobjc-std=objc1.  */
 /* { dg-do compile } */
 /* { dg-options "-fobjc-std=objc1" } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/gnu-api-2-class-meta.mm b/gcc/testsuite/obj-c++.dg/gnu-api-2-class-meta.mm
index bdaef9828ca..92852c3ecea 100644
--- a/gcc/testsuite/obj-c++.dg/gnu-api-2-class-meta.mm
+++ b/gcc/testsuite/obj-c++.dg/gnu-api-2-class-meta.mm
@@ -21,6 +21,7 @@
 /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
 /* { dg-additional-options "-DOBJC_OLD_DISPATCH_PROTOTYPES" { target { *-*-darwin* } } } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* To get the modern GNU Objective-C Runtime API, you include
    objc/runtime.h.  */
diff --git a/gcc/testsuite/obj-c++.dg/gnu-api-2-class.mm b/gcc/testsuite/obj-c++.dg/gnu-api-2-class.mm
index ae39026c2d3..f6e3d8d22e0 100644
--- a/gcc/testsuite/obj-c++.dg/gnu-api-2-class.mm
+++ b/gcc/testsuite/obj-c++.dg/gnu-api-2-class.mm
@@ -8,6 +8,7 @@
 /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
 /* { dg-additional-options "-DOBJC_OLD_DISPATCH_PROTOTYPES" { target { *-*-darwin* } } } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* To get the modern GNU Objective-C Runtime API, you include
    objc/runtime.h.  */
diff --git a/gcc/testsuite/obj-c++.dg/gnu-api-2-ivar.mm b/gcc/testsuite/obj-c++.dg/gnu-api-2-ivar.mm
index 1c85d238d60..991edc7271e 100644
--- a/gcc/testsuite/obj-c++.dg/gnu-api-2-ivar.mm
+++ b/gcc/testsuite/obj-c++.dg/gnu-api-2-ivar.mm
@@ -5,6 +5,7 @@
 /* { dg-do run } */
 /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* To get the modern GNU Objective-C Runtime API, you include
    objc/runtime.h.  */
diff --git a/gcc/testsuite/obj-c++.dg/gnu-api-2-method.mm b/gcc/testsuite/obj-c++.dg/gnu-api-2-method.mm
index 97bf84b6fc4..07c3a22ec32 100644
--- a/gcc/testsuite/obj-c++.dg/gnu-api-2-method.mm
+++ b/gcc/testsuite/obj-c++.dg/gnu-api-2-method.mm
@@ -5,6 +5,7 @@
 /* { dg-do run } */
 /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* To get the modern GNU Objective-C Runtime API, you include
    objc/runtime.h.  */
diff --git a/gcc/testsuite/obj-c++.dg/gnu-api-2-objc.mm b/gcc/testsuite/obj-c++.dg/gnu-api-2-objc.mm
index 201ab7e7af2..e68e7a899fc 100644
--- a/gcc/testsuite/obj-c++.dg/gnu-api-2-objc.mm
+++ b/gcc/testsuite/obj-c++.dg/gnu-api-2-objc.mm
@@ -9,6 +9,7 @@
    systems that don't have the V2 APis).  XFAILing the run is not useful
    since it will XPASS on the sub-set that works.  */
 /* { dg-skip-if "Incompatible" { *-*-darwin* } { "-fnext-runtime" } { "" } } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* To get the modern GNU Objective-C Runtime API, you include
    objc/runtime.h.  */
diff --git a/gcc/testsuite/obj-c++.dg/gnu-api-2-objc_msg_lookup.mm b/gcc/testsuite/obj-c++.dg/gnu-api-2-objc_msg_lookup.mm
index dcbf6d21f14..1fb56dcac90 100644
--- a/gcc/testsuite/obj-c++.dg/gnu-api-2-objc_msg_lookup.mm
+++ b/gcc/testsuite/obj-c++.dg/gnu-api-2-objc_msg_lookup.mm
@@ -5,6 +5,7 @@
 
 /* { dg-do run } */
 /* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* To get the modern GNU Objective-C Runtime API, you include
    objc/runtime.h.  */
diff --git a/gcc/testsuite/obj-c++.dg/gnu-api-2-object.mm b/gcc/testsuite/obj-c++.dg/gnu-api-2-object.mm
index a2702d64707..4d99053103c 100644
--- a/gcc/testsuite/obj-c++.dg/gnu-api-2-object.mm
+++ b/gcc/testsuite/obj-c++.dg/gnu-api-2-object.mm
@@ -5,6 +5,7 @@
 /* { dg-do run } */
 /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* To get the modern GNU Objective-C Runtime API, you include
    objc/runtime.h.  */
diff --git a/gcc/testsuite/obj-c++.dg/gnu-api-2-property.mm b/gcc/testsuite/obj-c++.dg/gnu-api-2-property.mm
index 953e9bb156b..601f39fa7e9 100644
--- a/gcc/testsuite/obj-c++.dg/gnu-api-2-property.mm
+++ b/gcc/testsuite/obj-c++.dg/gnu-api-2-property.mm
@@ -4,6 +4,7 @@
 
 /* { dg-do run } */
 /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* To get the modern GNU Objective-C Runtime API, you include
    objc/runtime.h.  */
diff --git a/gcc/testsuite/obj-c++.dg/gnu-api-2-protocol.mm b/gcc/testsuite/obj-c++.dg/gnu-api-2-protocol.mm
index 9a2ceca1353..21ae06bfd27 100644
--- a/gcc/testsuite/obj-c++.dg/gnu-api-2-protocol.mm
+++ b/gcc/testsuite/obj-c++.dg/gnu-api-2-protocol.mm
@@ -5,6 +5,7 @@
 /* { dg-do run } */
 /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* To get the modern GNU Objective-C Runtime API, you include
    objc/runtime.h.  */
diff --git a/gcc/testsuite/obj-c++.dg/gnu-api-2-resolve-method.mm b/gcc/testsuite/obj-c++.dg/gnu-api-2-resolve-method.mm
index f8a54d392c3..dc311324c08 100644
--- a/gcc/testsuite/obj-c++.dg/gnu-api-2-resolve-method.mm
+++ b/gcc/testsuite/obj-c++.dg/gnu-api-2-resolve-method.mm
@@ -5,6 +5,7 @@
 
 /* { dg-do run } */
 /* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* To get the modern GNU Objective-C Runtime API, you include
    objc/runtime.h.  */
diff --git a/gcc/testsuite/obj-c++.dg/gnu-api-2-sel.mm b/gcc/testsuite/obj-c++.dg/gnu-api-2-sel.mm
index ff50058566b..dd8ff3eeefe 100644
--- a/gcc/testsuite/obj-c++.dg/gnu-api-2-sel.mm
+++ b/gcc/testsuite/obj-c++.dg/gnu-api-2-sel.mm
@@ -4,6 +4,7 @@
 
 /* { dg-do run } */
 /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* To get the modern GNU Objective-C Runtime API, you include
    objc/runtime.h.  */
diff --git a/gcc/testsuite/obj-c++.dg/invalid-method-2.mm b/gcc/testsuite/obj-c++.dg/invalid-method-2.mm
index e3a8ed1ff17..8eee0ff6432 100644
--- a/gcc/testsuite/obj-c++.dg/invalid-method-2.mm
+++ b/gcc/testsuite/obj-c++.dg/invalid-method-2.mm
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* Test that using an invalid type in a method declaration produces a
    friendly error without a compiler crash.  */
diff --git a/gcc/testsuite/obj-c++.dg/ivar-invalid-type-1.mm b/gcc/testsuite/obj-c++.dg/ivar-invalid-type-1.mm
index 4c1480a6be9..974e919d639 100644
--- a/gcc/testsuite/obj-c++.dg/ivar-invalid-type-1.mm
+++ b/gcc/testsuite/obj-c++.dg/ivar-invalid-type-1.mm
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 #include <objc/objc.h>
 
 @interface MyRootClass
diff --git a/gcc/testsuite/obj-c++.dg/ivar-problem-1.mm b/gcc/testsuite/obj-c++.dg/ivar-problem-1.mm
index 4ed5afaf4ef..1736f9c445a 100644
--- a/gcc/testsuite/obj-c++.dg/ivar-problem-1.mm
+++ b/gcc/testsuite/obj-c++.dg/ivar-problem-1.mm
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* This test checks what happens if there are 16 instance variables.
    In that case, the class was not created correctly.  In this testcase,
diff --git a/gcc/testsuite/obj-c++.dg/lto/lto.exp b/gcc/testsuite/obj-c++.dg/lto/lto.exp
index 6ba5f9c48fd..936872a3bfe 100644
--- a/gcc/testsuite/obj-c++.dg/lto/lto.exp
+++ b/gcc/testsuite/obj-c++.dg/lto/lto.exp
@@ -41,10 +41,10 @@ if { ![check_effective_target_lto] } {
 global LTO_OPTIONS
 
 set LTO_OPTIONS [list	\
-  {-O0 -flto -fgnu-runtime}	\
-  {-O2 -flto -fgnu-runtime}	\
-  {-O0 -flto -flto-partition=none -fgnu-runtime} 	\
-  {-O2 -flto -flto-partition=none -fgnu-runtime}	\
+  {-O0 -flto -fgnu-runtime -Wno-objc-root-class}	\
+  {-O2 -flto -fgnu-runtime -Wno-objc-root-class}	\
+  {-O0 -flto -flto-partition=none -fgnu-runtime -Wno-objc-root-class} 	\
+  {-O2 -flto -flto-partition=none -fgnu-runtime -Wno-objc-root-class}	\
 ]
 
 obj-c++_init
@@ -67,10 +67,10 @@ foreach src $tests {
 # darwin targets can also run code with the NeXT runtime.
 if [istarget "*-*-darwin*" ] {
 set LTO_OPTIONS [list	\
-  {-O0 -flto -fnext-runtime}	\
-  {-O2 -flto -fnext-runtime}	\
-  {-O0 -flto -flto-partition=none -fnext-runtime} 	\
-  {-O2 -flto -flto-partition=none -fnext-runtime}	\
+  {-O0 -flto -fnext-runtime -Wno-objc-root-class}	\
+  {-O2 -flto -fnext-runtime -Wno-objc-root-class}	\
+  {-O0 -flto -flto-partition=none -fnext-runtime -Wno-objc-root-class} 	\
+  {-O2 -flto -flto-partition=none -fnext-runtime -Wno-objc-root-class}	\
 ]
   foreach src $tests {
     # If we're only testing specific files and this isn't one of them, skip it.
diff --git a/gcc/testsuite/obj-c++.dg/lto/trivial-1_0.mm b/gcc/testsuite/obj-c++.dg/lto/trivial-1_0.mm
index 55f62f03cfc..c3620c36025 100644
--- a/gcc/testsuite/obj-c++.dg/lto/trivial-1_0.mm
+++ b/gcc/testsuite/obj-c++.dg/lto/trivial-1_0.mm
@@ -1,5 +1,5 @@
 /* { dg-lto-do run } */
-/* { dg-skip-if "Needs OBJC2 ABI" { "*-*-darwin*" && lp64 } } */
+
 extern "C" {
 extern int printf (const char *,...) ;
 extern void abort (void) ;
diff --git a/gcc/testsuite/obj-c++.dg/method-1.mm b/gcc/testsuite/obj-c++.dg/method-1.mm
index 7317ae2aa87..5bb851ad5f6 100644
--- a/gcc/testsuite/obj-c++.dg/method-1.mm
+++ b/gcc/testsuite/obj-c++.dg/method-1.mm
@@ -3,6 +3,7 @@
 /* Author: Ziemowit Laski <zlaski@apple.com>.  */
 
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/method-12.mm b/gcc/testsuite/obj-c++.dg/method-12.mm
index 45461445178..d3145abadb3 100644
--- a/gcc/testsuite/obj-c++.dg/method-12.mm
+++ b/gcc/testsuite/obj-c++.dg/method-12.mm
@@ -3,6 +3,7 @@
 /* { dg-options "-Wstrict-selector-match" } */
 /* { dg-do compile } */
 /* { dg-skip-if "Object interface removed" { *-*-darwin[1-2]* && { lp64 } } { "-fnext-runtime" } { "" } } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <objc/Protocol.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/method-18.mm b/gcc/testsuite/obj-c++.dg/method-18.mm
index 411caac111a..c753f33279d 100644
--- a/gcc/testsuite/obj-c++.dg/method-18.mm
+++ b/gcc/testsuite/obj-c++.dg/method-18.mm
@@ -1,5 +1,6 @@
 /* Contributed by Igor Seleznev <selez@mail.ru>.  */
 /* This used to be broken.  */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/method-19.mm b/gcc/testsuite/obj-c++.dg/method-19.mm
index 225becae0f1..a3b977ef356 100644
--- a/gcc/testsuite/obj-c++.dg/method-19.mm
+++ b/gcc/testsuite/obj-c++.dg/method-19.mm
@@ -4,6 +4,7 @@
 /* Author: Ziemowit Laski <zlaski@apple.com>.  */
 /* { dg-do run } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+// { dg-additional-options "-Wno-objc-root-class" }
 #include <objc/objc.h>
 #include "../objc-obj-c++-shared/runtime.h"
 
diff --git a/gcc/testsuite/obj-c++.dg/method-20.mm b/gcc/testsuite/obj-c++.dg/method-20.mm
index 96982254aa9..a7fe41d0905 100644
--- a/gcc/testsuite/obj-c++.dg/method-20.mm
+++ b/gcc/testsuite/obj-c++.dg/method-20.mm
@@ -2,6 +2,7 @@
    used as method selectors.  */
 /* Author: Ziemowit Laski <zlaski@apple.com>.  */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 @interface Foo
 - (void)insertNewButtonImage:(Foo *)newButtonImage in:(Foo *)buttonCell;
diff --git a/gcc/testsuite/obj-c++.dg/method-3.mm b/gcc/testsuite/obj-c++.dg/method-3.mm
index 9dab8c5b332..17b0c99fb96 100644
--- a/gcc/testsuite/obj-c++.dg/method-3.mm
+++ b/gcc/testsuite/obj-c++.dg/method-3.mm
@@ -3,6 +3,7 @@
 
 /* { dg-do compile } */
 /* { dg-options "-Wno-strict-selector-match" } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/method-4.mm b/gcc/testsuite/obj-c++.dg/method-4.mm
index e94f8f1b770..1f2f93eb93d 100644
--- a/gcc/testsuite/obj-c++.dg/method-4.mm
+++ b/gcc/testsuite/obj-c++.dg/method-4.mm
@@ -3,6 +3,7 @@
 
 /* { dg-do compile } */
 /* { dg-options "-Wstrict-selector-match" } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/method-5.mm b/gcc/testsuite/obj-c++.dg/method-5.mm
index 17c841a4661..10364cc3809 100644
--- a/gcc/testsuite/obj-c++.dg/method-5.mm
+++ b/gcc/testsuite/obj-c++.dg/method-5.mm
@@ -3,6 +3,7 @@
 
 /* { dg-do compile } */
 /* { dg-options "-Wno-strict-selector-match" } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/method-8.mm b/gcc/testsuite/obj-c++.dg/method-8.mm
index cde1bc27469..9c5c17a96b4 100644
--- a/gcc/testsuite/obj-c++.dg/method-8.mm
+++ b/gcc/testsuite/obj-c++.dg/method-8.mm
@@ -1,5 +1,6 @@
 /* Tests of duplication.  */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 @interface class1
 - (int) meth1;   /* { dg-message "previous declaration" } */
diff --git a/gcc/testsuite/obj-c++.dg/method-9.mm b/gcc/testsuite/obj-c++.dg/method-9.mm
index 787e25d67ff..bee076e7c98 100644
--- a/gcc/testsuite/obj-c++.dg/method-9.mm
+++ b/gcc/testsuite/obj-c++.dg/method-9.mm
@@ -1,6 +1,7 @@
 /* Test for lookup of class (factory) methods.  */
 /* Author: Ziemowit Laski <zlaski@apple.com>.  */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 @interface MyBase 
 - (void) rootInstanceMethod;
diff --git a/gcc/testsuite/obj-c++.dg/method-namespace-1.mm b/gcc/testsuite/obj-c++.dg/method-namespace-1.mm
index 6095f572cca..86006a73b8d 100644
--- a/gcc/testsuite/obj-c++.dg/method-namespace-1.mm
+++ b/gcc/testsuite/obj-c++.dg/method-namespace-1.mm
@@ -1,5 +1,6 @@
 /* Test for usage of namespace inside @implementation. */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 @interface MyDocument
 @end
 
diff --git a/gcc/testsuite/obj-c++.dg/plugin/diagnostic-test-expressions-1.mm b/gcc/testsuite/obj-c++.dg/plugin/diagnostic-test-expressions-1.mm
index 988b290ce69..128b3bd8fe9 100644
--- a/gcc/testsuite/obj-c++.dg/plugin/diagnostic-test-expressions-1.mm
+++ b/gcc/testsuite/obj-c++.dg/plugin/diagnostic-test-expressions-1.mm
@@ -1,6 +1,7 @@
 /* { dg-do compile } */
 /* { dg-options "-O -fdiagnostics-show-caret" } */
 /* { dg-excess-errors "tree range 0:0-0:0" { target { *-*-darwin* } } }  */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* This file is similar to diagnostic-test-expressions-1.c
    (see the notes in that file); this file adds test
diff --git a/gcc/testsuite/obj-c++.dg/pr23709.mm b/gcc/testsuite/obj-c++.dg/pr23709.mm
index 018b53ac456..7936956854f 100644
--- a/gcc/testsuite/obj-c++.dg/pr23709.mm
+++ b/gcc/testsuite/obj-c++.dg/pr23709.mm
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 @interface A
 +(void)method: (int)parameter {} /* { dg-error "expected" } */
diff --git a/gcc/testsuite/obj-c++.dg/pragma-2.mm b/gcc/testsuite/obj-c++.dg/pragma-2.mm
index 14c4d7928a2..09feac7971f 100644
--- a/gcc/testsuite/obj-c++.dg/pragma-2.mm
+++ b/gcc/testsuite/obj-c++.dg/pragma-2.mm
@@ -1,5 +1,6 @@
 /* It is OK to use #pragma inside @implementation body. This test checks that.  */
 /* Ziemowit Laski  <zlaski@apple.com>.  */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 @interface A
 {
diff --git a/gcc/testsuite/obj-c++.dg/private-1.mm b/gcc/testsuite/obj-c++.dg/private-1.mm
index 0c25aea5566..2173b900530 100644
--- a/gcc/testsuite/obj-c++.dg/private-1.mm
+++ b/gcc/testsuite/obj-c++.dg/private-1.mm
@@ -1,6 +1,7 @@
 /* Test errors for accessing @private and @protected variables.  */
 /* Based on work by: Nicola Pero <nicola@brainstorm.co.uk>.  */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 #include <objc/objc.h>
 
 @interface MySuperClass
diff --git a/gcc/testsuite/obj-c++.dg/private-2.mm b/gcc/testsuite/obj-c++.dg/private-2.mm
index 3e6ff118d23..93b8a8fd5c5 100644
--- a/gcc/testsuite/obj-c++.dg/private-2.mm
+++ b/gcc/testsuite/obj-c++.dg/private-2.mm
@@ -2,6 +2,7 @@
 /* Based on work by: Nicola Pero <nicola@brainstorm.co.uk>.  */
 
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/property/property.exp b/gcc/testsuite/obj-c++.dg/property/property.exp
index d18f6100fcf..31e683c5c00 100644
--- a/gcc/testsuite/obj-c++.dg/property/property.exp
+++ b/gcc/testsuite/obj-c++.dg/property/property.exp
@@ -31,12 +31,12 @@ dg-init
 set tests [lsort [glob -nocomplain $srcdir/$subdir/*.mm]]
 
 # Main loop.
-dg-runtest $tests "-fgnu-runtime" $DEFAULT_OBJCXXFLAGS
+dg-runtest $tests "-fgnu-runtime -Wno-objc-root-class" $DEFAULT_OBJCXXFLAGS
 
 # Darwin targets can also run code with the NeXT runtime.
 # but Properties are not supported by the runtime lib before Darwin 9.
 if [istarget "*-*-darwin\[9123\]*" ] {
-  dg-runtest $tests "-fnext-runtime" $DEFAULT_OBJCXXFLAGS
+  dg-runtest $tests "-fnext-runtime -Wno-objc-root-class" $DEFAULT_OBJCXXFLAGS
 }
 
 # All done.
diff --git a/gcc/testsuite/obj-c++.dg/proto-lossage-1.mm b/gcc/testsuite/obj-c++.dg/proto-lossage-1.mm
index 2f7eb986140..82cd05374b2 100644
--- a/gcc/testsuite/obj-c++.dg/proto-lossage-1.mm
+++ b/gcc/testsuite/obj-c++.dg/proto-lossage-1.mm
@@ -2,6 +2,7 @@
    may be lost, leading to superfluous warnings.  */
 /* Author: Ziemowit Laski <zlaski@apple.com>.  */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* One-line substitute for objc/objc.h */
 typedef struct objc_object { struct objc_class *class_pointer; } *id;
diff --git a/gcc/testsuite/obj-c++.dg/proto-lossage-5.mm b/gcc/testsuite/obj-c++.dg/proto-lossage-5.mm
index 35c0956ed8e..2a30bc2a9af 100644
--- a/gcc/testsuite/obj-c++.dg/proto-lossage-5.mm
+++ b/gcc/testsuite/obj-c++.dg/proto-lossage-5.mm
@@ -1,5 +1,6 @@
 /* Do not lose references to forward-declared protocols.  */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 @class MyBaseClass;
 @class MyClassThatFails;
 @protocol _MyProtocol;
diff --git a/gcc/testsuite/obj-c++.dg/proto-qual-1.mm b/gcc/testsuite/obj-c++.dg/proto-qual-1.mm
index 7ef0e9a98ef..b2350648f22 100644
--- a/gcc/testsuite/obj-c++.dg/proto-qual-1.mm
+++ b/gcc/testsuite/obj-c++.dg/proto-qual-1.mm
@@ -3,6 +3,7 @@
 
 /* { dg-do run } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/gcc/testsuite/obj-c++.dg/protocol-inheritance-1.mm b/gcc/testsuite/obj-c++.dg/protocol-inheritance-1.mm
index 5241b29abbd..c505c0083fa 100644
--- a/gcc/testsuite/obj-c++.dg/protocol-inheritance-1.mm
+++ b/gcc/testsuite/obj-c++.dg/protocol-inheritance-1.mm
@@ -1,6 +1,7 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
 /* { dg-do compile } */
 /* { dg-options "-Wno-protocol" } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/protocol-inheritance-2.mm b/gcc/testsuite/obj-c++.dg/protocol-inheritance-2.mm
index 74c9174b5de..f2bc1cadc18 100644
--- a/gcc/testsuite/obj-c++.dg/protocol-inheritance-2.mm
+++ b/gcc/testsuite/obj-c++.dg/protocol-inheritance-2.mm
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/protocol-optional-1.mm b/gcc/testsuite/obj-c++.dg/protocol-optional-1.mm
index bc4a3d07e97..4ecf43629b9 100644
--- a/gcc/testsuite/obj-c++.dg/protocol-optional-1.mm
+++ b/gcc/testsuite/obj-c++.dg/protocol-optional-1.mm
@@ -1,5 +1,6 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/selector-1.mm b/gcc/testsuite/obj-c++.dg/selector-1.mm
index d34f8c89cd6..b0cdc9cc81b 100644
--- a/gcc/testsuite/obj-c++.dg/selector-1.mm
+++ b/gcc/testsuite/obj-c++.dg/selector-1.mm
@@ -3,6 +3,7 @@
 /* Author: Ziemowit Laski <zlaski@apple.com>.  */
 
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 @interface Int1 
 + (int)and_eq:(int)arg1 and:(int)arg2;
diff --git a/gcc/testsuite/obj-c++.dg/selector-2.mm b/gcc/testsuite/obj-c++.dg/selector-2.mm
index 840ee19fee4..fa9ab4199f2 100644
--- a/gcc/testsuite/obj-c++.dg/selector-2.mm
+++ b/gcc/testsuite/obj-c++.dg/selector-2.mm
@@ -1,6 +1,7 @@
 /* Test that we don't ICE when issuing a -Wselector warning.  */
 /* { dg-options "-Wselector" } */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <objc/objc.h>
 
diff --git a/gcc/testsuite/obj-c++.dg/selector-3.mm b/gcc/testsuite/obj-c++.dg/selector-3.mm
index a1321a7b741..0c9805626ed 100644
--- a/gcc/testsuite/obj-c++.dg/selector-3.mm
+++ b/gcc/testsuite/obj-c++.dg/selector-3.mm
@@ -2,6 +2,7 @@
 /* This is the "-fgnu-runtime" variant of objc.dg/selector-1.m.  */
 /* { dg-options "-Wselector -fgnu-runtime" } */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 typedef struct objc_object { struct objc_class *class_pointer; } *id;
 typedef const struct objc_selector    *SEL;
diff --git a/gcc/testsuite/obj-c++.dg/selector-4.mm b/gcc/testsuite/obj-c++.dg/selector-4.mm
index 690cc44b698..b6ddcbe43eb 100644
--- a/gcc/testsuite/obj-c++.dg/selector-4.mm
+++ b/gcc/testsuite/obj-c++.dg/selector-4.mm
@@ -3,6 +3,7 @@
 
 /* { dg-options "-Wselector -fnext-runtime" } */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 typedef struct objc_object { struct objc_class *class_pointer; } *id;
 typedef struct objc_selector *SEL;
diff --git a/gcc/testsuite/obj-c++.dg/strings/strings.exp b/gcc/testsuite/obj-c++.dg/strings/strings.exp
index 1bfb3be7e00..0243f24f306 100644
--- a/gcc/testsuite/obj-c++.dg/strings/strings.exp
+++ b/gcc/testsuite/obj-c++.dg/strings/strings.exp
@@ -34,11 +34,11 @@ dg-init
 set tests [lsort [glob -nocomplain $srcdir/$subdir/*.mm]]
 
 # Main loop.
-dg-runtest $tests "-fgnu-runtime" $DEFAULT_OBJCXXFLAGS
+dg-runtest $tests "-fgnu-runtime -Wno-objc-root-class" $DEFAULT_OBJCXXFLAGS
 
 # darwin targets can also run code with the NeXT runtime.
 if [istarget "*-*-darwin*" ] {
-  dg-runtest $tests "-fnext-runtime" $DEFAULT_OBJCXXFLAGS
+  dg-runtest $tests "-fnext-runtime -Wno-objc-root-class" $DEFAULT_OBJCXXFLAGS
 }
 
 # All done.
diff --git a/gcc/testsuite/obj-c++.dg/stubify-1.mm b/gcc/testsuite/obj-c++.dg/stubify-1.mm
index a32e282519c..21de46333fd 100644
--- a/gcc/testsuite/obj-c++.dg/stubify-1.mm
+++ b/gcc/testsuite/obj-c++.dg/stubify-1.mm
@@ -5,6 +5,7 @@
 /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
 /* { dg-require-effective-target ilp32 } */
 /* { dg-options "-Os -mdynamic-no-pic -fno-exceptions -mmacosx-version-min=10.4 -msymbol-stubs" } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 typedef struct objc_object { } *id ;
 int x = 41 ;
diff --git a/gcc/testsuite/obj-c++.dg/stubify-2.mm b/gcc/testsuite/obj-c++.dg/stubify-2.mm
index 69fea8def42..cbc52b1a9e5 100644
--- a/gcc/testsuite/obj-c++.dg/stubify-2.mm
+++ b/gcc/testsuite/obj-c++.dg/stubify-2.mm
@@ -5,6 +5,7 @@
 /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
 /* { dg-require-effective-target ilp32 } */
 /* { dg-options "-mdynamic-no-pic -fdump-rtl-jump -mmacosx-version-min=10.4 -msymbol-stubs" } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 typedef struct objc_object { } *id ;
 int x = 41 ;
diff --git a/gcc/testsuite/obj-c++.dg/super-dealloc-1.mm b/gcc/testsuite/obj-c++.dg/super-dealloc-1.mm
index 0ab177bb73c..39ddd01f694 100644
--- a/gcc/testsuite/obj-c++.dg/super-dealloc-1.mm
+++ b/gcc/testsuite/obj-c++.dg/super-dealloc-1.mm
@@ -2,6 +2,7 @@
 /* Author: Ziemowit Laski <zlaski@apple.com>  */
 
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 @interface Foo {
   void *isa;
diff --git a/gcc/testsuite/obj-c++.dg/super-dealloc-2.mm b/gcc/testsuite/obj-c++.dg/super-dealloc-2.mm
index 80dcf495062..6dac31c17f4 100644
--- a/gcc/testsuite/obj-c++.dg/super-dealloc-2.mm
+++ b/gcc/testsuite/obj-c++.dg/super-dealloc-2.mm
@@ -2,6 +2,7 @@
 /* Author: Ziemowit Laski <zlaski@apple.com>  */
 
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 @interface Foo {
   void *isa;
diff --git a/gcc/testsuite/obj-c++.dg/sync-3.mm b/gcc/testsuite/obj-c++.dg/sync-3.mm
index 95def43d05d..2949d6a8a13 100644
--- a/gcc/testsuite/obj-c++.dg/sync-3.mm
+++ b/gcc/testsuite/obj-c++.dg/sync-3.mm
@@ -1,6 +1,7 @@
 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
 /* { dg-options "-fobjc-exceptions" } */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 /* Test that the compiler is checking the argument of @synchronized(),
    and produce errors when invalid types are used.  */
diff --git a/gcc/testsuite/obj-c++.dg/syntax-error-2.mm b/gcc/testsuite/obj-c++.dg/syntax-error-2.mm
index ba8804a89e2..bf4d5ffb4a7 100644
--- a/gcc/testsuite/obj-c++.dg/syntax-error-2.mm
+++ b/gcc/testsuite/obj-c++.dg/syntax-error-2.mm
@@ -1,4 +1,5 @@
 /* Recover gracefully from a syntax error.  */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 @implementation Whatever  /* { dg-warning "cannot find interface declaration for .Whatever." } */
 
diff --git a/gcc/testsuite/obj-c++.dg/syntax-error-4.mm b/gcc/testsuite/obj-c++.dg/syntax-error-4.mm
index 0df061839b4..97587f98495 100644
--- a/gcc/testsuite/obj-c++.dg/syntax-error-4.mm
+++ b/gcc/testsuite/obj-c++.dg/syntax-error-4.mm
@@ -1,5 +1,6 @@
 /* Yet another stray infinite loop... */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 @interface t
 {
diff --git a/gcc/testsuite/obj-c++.dg/syntax-error-7.mm b/gcc/testsuite/obj-c++.dg/syntax-error-7.mm
index 5bdccc7b05f..c406d8fe769 100644
--- a/gcc/testsuite/obj-c++.dg/syntax-error-7.mm
+++ b/gcc/testsuite/obj-c++.dg/syntax-error-7.mm
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 @interface Foo
 -(void) someMethod;
diff --git a/gcc/testsuite/obj-c++.dg/syntax-error-9.mm b/gcc/testsuite/obj-c++.dg/syntax-error-9.mm
index 1876c32dd20..ad8837c28af 100644
--- a/gcc/testsuite/obj-c++.dg/syntax-error-9.mm
+++ b/gcc/testsuite/obj-c++.dg/syntax-error-9.mm
@@ -1,3 +1,4 @@
+// { dg-additional-options "-Wno-objc-root-class" }
 @implementation SaturnDoc /* { dg-warning "cannot find interface declaration" } */
 - read: (void*)aStream ggg /* { dg-error "expected .:. at end of input" } */
 /* { dg-error "-:expected ..*. at end of input" "" { target *-*-* } .+1 } */
diff --git a/gcc/testsuite/obj-c++.dg/template-4.mm b/gcc/testsuite/obj-c++.dg/template-4.mm
index 5301df5c0e0..02795e76e28 100644
--- a/gcc/testsuite/obj-c++.dg/template-4.mm
+++ b/gcc/testsuite/obj-c++.dg/template-4.mm
@@ -4,6 +4,7 @@
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
 /* { dg-options "-mno-constant-cfstrings" { target *-*-darwin* } } */
 /* { dg-additional-sources "../objc-obj-c++-shared/nsconstantstring-class-impl.mm" } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <stdarg.h>
 #include <stdlib.h>
diff --git a/gcc/testsuite/obj-c++.dg/template-7.mm b/gcc/testsuite/obj-c++.dg/template-7.mm
index 8621abebaf1..b3697a584a0 100644
--- a/gcc/testsuite/obj-c++.dg/template-7.mm
+++ b/gcc/testsuite/obj-c++.dg/template-7.mm
@@ -3,6 +3,7 @@
 // Author: Fariborz Jahanian <fjahanian@apple.com>
 // { dg-do compile }
 // { dg-options "" }
+// { dg-additional-options "-Wno-objc-root-class" }
 typedef struct objc_class *Class;
 
 @interface Object
diff --git a/gcc/testsuite/obj-c++.dg/template-8.mm b/gcc/testsuite/obj-c++.dg/template-8.mm
index df215b8525d..1b9f4d16ae9 100644
--- a/gcc/testsuite/obj-c++.dg/template-8.mm
+++ b/gcc/testsuite/obj-c++.dg/template-8.mm
@@ -5,6 +5,7 @@
 /* { dg-do run } */
 /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <objc/objc.h>
 #include <objc/runtime.h>
diff --git a/gcc/testsuite/obj-c++.dg/threedotthree-abi-1.mm b/gcc/testsuite/obj-c++.dg/threedotthree-abi-1.mm
index c48181049f1..32f4fd84e88 100644
--- a/gcc/testsuite/obj-c++.dg/threedotthree-abi-1.mm
+++ b/gcc/testsuite/obj-c++.dg/threedotthree-abi-1.mm
@@ -3,6 +3,7 @@
 /* { dg-do run { target *-*-darwin* } } */
 /* { dg-require-effective-target ilp32 } */
 /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 #include <stdio.h>
 #include <string.h>
diff --git a/gcc/testsuite/obj-c++.dg/torture/dg-torture.exp b/gcc/testsuite/obj-c++.dg/torture/dg-torture.exp
index c3d3f8e29fd..4e4620791e8 100644
--- a/gcc/testsuite/obj-c++.dg/torture/dg-torture.exp
+++ b/gcc/testsuite/obj-c++.dg/torture/dg-torture.exp
@@ -7,11 +7,11 @@ dg-init
 # Gather a list of all tests.
 set tests [lsort [glob -nocomplain $srcdir/$subdir/*.mm]]
  
-obj-c++-dg-runtest $tests "" "-fgnu-runtime"
+obj-c++-dg-runtest $tests "" "-fgnu-runtime  -Wno-objc-root-class"
 
 # darwin targets can also run code with the NeXT runtime.
 if [istarget "*-*-darwin*" ] {
-  obj-c++-dg-runtest $tests "" "-fnext-runtime"
+  obj-c++-dg-runtest $tests "" "-fnext-runtime  -Wno-objc-root-class"
 }
 
 dg-finish
diff --git a/gcc/testsuite/obj-c++.dg/torture/strings/strings.exp b/gcc/testsuite/obj-c++.dg/torture/strings/strings.exp
index 401bc5856bf..6181c30b198 100644
--- a/gcc/testsuite/obj-c++.dg/torture/strings/strings.exp
+++ b/gcc/testsuite/obj-c++.dg/torture/strings/strings.exp
@@ -24,11 +24,11 @@ dg-init
 # Gather a list of all tests.
 set tests [lsort [glob -nocomplain $srcdir/$subdir/*.mm]]
 
-obj-c++-dg-runtest $tests "" "-fgnu-runtime"
+obj-c++-dg-runtest $tests "" "-fgnu-runtime  -Wno-objc-root-class"
 
 # Darwin targets can also run code with the NeXT runtime.
 if [istarget "*-*-darwin*" ] {
-  obj-c++-dg-runtest $tests "" "-fnext-runtime"
+  obj-c++-dg-runtest $tests "" "-fnext-runtime  -Wno-objc-root-class"
 }
 
 dg-finish
diff --git a/gcc/testsuite/obj-c++.dg/try-catch-12.mm b/gcc/testsuite/obj-c++.dg/try-catch-12.mm
index e08f321e8c7..6a608055784 100644
--- a/gcc/testsuite/obj-c++.dg/try-catch-12.mm
+++ b/gcc/testsuite/obj-c++.dg/try-catch-12.mm
@@ -4,6 +4,7 @@
 
 /* { dg-options "-fobjc-exceptions" } */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 typedef volatile int IOSharedLockData;
 
diff --git a/gcc/testsuite/obj-c++.dg/try-catch-13.mm b/gcc/testsuite/obj-c++.dg/try-catch-13.mm
index 050d8113555..0e6f01b23e9 100644
--- a/gcc/testsuite/obj-c++.dg/try-catch-13.mm
+++ b/gcc/testsuite/obj-c++.dg/try-catch-13.mm
@@ -4,6 +4,7 @@
 
 /* { dg-options "-fobjc-exceptions" } */
 /* { dg-do compile } */
+// { dg-additional-options "-Wno-objc-root-class" }
 
 @interface TestMyTests
 - (void) testSpoon;
-- 
2.24.1

Comments

Joseph Myers Nov. 12, 2020, 7:44 p.m. | #1
On Thu, 12 Nov 2020, Iain Sandoe wrote:

> OK for the c-family parts?


OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

Patch

=========

gcc/c-family/ChangeLog:

	PR objc/77404
	* c-attribs.c (handle_objc_root_class_attribute): New
	* c-objc.h (objc_start_class_interface): Add a location
	value for the position of the class name.
	* c.opt: Add Wobjc-root-class.
	* stub-objc.c (objc_start_class_interface): Add a location
	value for the position of the class name.

gcc/c/ChangeLog:

         PR objc/77404
	* c-parser.c (c_parser_objc_class_definition): Pass the
	location of the class name to the interface declaration.

gcc/cp/ChangeLog:

         PR objc/77404
	* parser.c (cp_parser_objc_class_interface): Pass the
	location of the class name to the interface declaration.

gcc/objc/ChangeLog:

         PR objc/77404
	* objc-act.c (objc_start_class_interface): Accept the location
	of the class name, use it in existing diagnostic.
	(start_class): Accept obj_root_class type attributes.  Warn when
	the interface for an implementation does not contain a super
	class (unless the diagnostic is suppressed by the the command
	line flag or the objc_root_class type attribute).

gcc/testsuite/ChangeLog:

         PR objc/77404
	* objc.dg/attributes/root-class-01.m: New test.
	* objc.dg/root-class-00.m: New test.
	* obj-c++.dg/attributes/root-class-01.mm: New test.
	* obj-c++.dg/root-class-00.mm: New test.

gcc/ChangeLog:

         PR objc/77404
	* doc/extend.texi: Document the objc_root_class attribute.
	* doc/invoke.texi: Document -Wobjc-root-class.
---
  gcc/c-family/c-attribs.c                      | 19 +++++++++++++++++++
  gcc/c-family/c-objc.h                         |  2 +-
  gcc/c-family/c.opt                            |  5 +++++
  gcc/c-family/stub-objc.c                      |  1 +
  gcc/c/c-parser.c                              |  3 ++-
  gcc/cp/parser.c                               |  3 ++-
  gcc/doc/extend.texi                           |  6 ++++++
  gcc/doc/invoke.texi                           |  9 ++++++++-
  gcc/objc/objc-act.c                           | 12 ++++++++++--
  .../obj-c++.dg/attributes/root-class-01.mm    | 11 +++++++++++
  gcc/testsuite/obj-c++.dg/root-class-00.mm     | 10 ++++++++++
  .../objc.dg/attributes/root-class-01.m        | 11 +++++++++++
  gcc/testsuite/objc.dg/root-class-00.m         | 10 ++++++++++
  13 files changed, 96 insertions(+), 6 deletions(-)
  create mode 100644 gcc/testsuite/obj-c++.dg/attributes/root-class-01.mm
  create mode 100644 gcc/testsuite/obj-c++.dg/root-class-00.mm
  create mode 100644 gcc/testsuite/objc.dg/attributes/root-class-01.m
  create mode 100644 gcc/testsuite/objc.dg/root-class-00.m

diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index 067dfabe0a4..6718fff6efb 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -160,6 +160,7 @@  static tree handle_patchable_function_entry_attribute  
(tree *, tree, tree,
  						       int, bool *);
  static tree handle_copy_attribute (tree *, tree, tree, int, bool *);
  static tree handle_nsobject_attribute (tree *, tree, tree, int, bool *);
+static tree handle_objc_root_class_attribute (tree *, tree, tree, int,  
bool *);
 
  /* Helper to define attribute exclusions.  */
  #define ATTR_EXCL(name, function, type, variable)	\
@@ -517,6 +518,8 @@  const struct attribute_spec c_common_attribute_table[] =
    /* Attributes used by Objective-C.  */
    { "NSObject",		      0, 0, true, false, false, false,
  			      handle_nsobject_attribute, NULL },
+  { "objc_root_class",	      0, 0, true, false, false, false,
+			      handle_objc_root_class_attribute, NULL },
    { NULL,                     0, 0, false, false, false, false, NULL, NULL }
  };
 
@@ -5232,6 +5235,22 @@  handle_nsobject_attribute (tree *node, tree name,  
tree args,
    return NULL_TREE;
  }
 
+/* Handle a "objc_root_class" attributes; arguments as in
+   struct attribute_spec.handler.  */
+
+static tree
+handle_objc_root_class_attribute (tree */*node*/, tree name, tree /*args*/,
+				  int /*flags*/, bool *no_add_attrs)
+{
+  /* This has no meaning outside Objective-C.  */
+  if (!c_dialect_objc())
+    warning (OPT_Wattributes, "%qE is only applicable to Objective-C"
+	     " class interfaces, attribute ignored", name);
+
+  *no_add_attrs = true;
+  return NULL_TREE;
+}
+
  /* Attempt to partially validate a single attribute ATTR as if
     it were to be applied to an entity OPER.  */
 
diff --git a/gcc/c-family/c-objc.h b/gcc/c-family/c-objc.h
index 6e96731882b..9414aecc668 100644
--- a/gcc/c-family/c-objc.h
+++ b/gcc/c-family/c-objc.h
@@ -124,7 +124,7 @@  extern tree objc_get_protocol_qualified_type (tree,  
tree);
  extern tree objc_get_class_reference (tree);
  extern tree objc_get_class_ivars (tree);
  extern bool objc_detect_field_duplicates (bool);
-extern void objc_start_class_interface (tree, tree, tree, tree);
+extern void objc_start_class_interface (tree, location_t, tree, tree, tree);
  extern void objc_start_category_interface (tree, tree, tree, tree);
  extern void objc_start_protocol (tree, tree, tree);
  extern void objc_continue_interface (void);
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 5fada472db1..1dad951e253 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -1002,6 +1002,11 @@  Enum(cpp_normalize_level) String(id)  
Value(normalized_identifier_C)
  EnumValue
  Enum(cpp_normalize_level) String(nfc) Value(normalized_C)
 
+Wobjc-root-class
+ObjC ObjC++ Var(warn_objc_root_class) Warning Init(1)
+Warn if a class interface has no superclass.  Root classes may use an  
attribute
+to suppress this warning.
+
  Wold-style-cast
  C++ ObjC++ Var(warn_old_style_cast) Warning
  Warn if a C-style cast is used in a program.
diff --git a/gcc/c-family/stub-objc.c b/gcc/c-family/stub-objc.c
index 2f535578789..26941aa2cb4 100644
--- a/gcc/c-family/stub-objc.c
+++ b/gcc/c-family/stub-objc.c
@@ -137,6 +137,7 @@  objc_set_method_opt (bool ARG_UNUSED (optional))
 
  void
  objc_start_class_interface (tree ARG_UNUSED (name),
+			    location_t /*name_loc*/,
  			    tree ARG_UNUSED (super),
  			    tree ARG_UNUSED (protos),
  			    tree ARG_UNUSED (attribs))
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 377914cad16..f4c4cf7bf8f 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -10801,6 +10801,7 @@  c_parser_objc_class_definition (c_parser *parser,  
tree attributes)
        return;
      }
    id1 = c_parser_peek_token (parser)->value;
+  location_t loc1 = c_parser_peek_token (parser)->location;
    c_parser_consume_token (parser);
    if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
      {
@@ -10860,7 +10861,7 @@  c_parser_objc_class_definition (c_parser *parser,  
tree attributes)
        tree proto = NULL_TREE;
        if (c_parser_next_token_is (parser, CPP_LESS))
  	proto = c_parser_objc_protocol_refs (parser);
-      objc_start_class_interface (id1, superclass, proto, attributes);
+      objc_start_class_interface (id1, loc1, superclass, proto, attributes);
      }
    else
      objc_start_class_implementation (id1, superclass);
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 6eb9280f056..9d050f72fc1 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -33584,6 +33584,7 @@  cp_parser_objc_class_interface (cp_parser* parser,  
tree attributes)
    bool is_class_extension;
 
    cp_lexer_consume_token (parser->lexer);  /* Eat '@interface'.  */
+  location_t nam_loc = cp_lexer_peek_token (parser->lexer)->location;
    name = cp_parser_identifier (parser);
    if (name == error_mark_node)
      {
@@ -33603,7 +33604,7 @@  cp_parser_objc_class_interface (cp_parser* parser,  
tree attributes)
      objc_start_category_interface (name, categ, protos, attributes);
    else
      {
-      objc_start_class_interface (name, super, protos, attributes);
+      objc_start_class_interface (name, nam_loc, super, protos, attributes);
        /* Handle instance variable declarations, if any.  */
        cp_parser_objc_class_ivars (parser);
        objc_continue_interface ();
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 8c51e6faac8..aaa5faf76c7 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -8558,6 +8558,12 @@  and caught in another, the class must have default  
visibility.
  Otherwise the two shared objects are unable to use the same
  typeinfo node and exception handling will break.
 
+@item objc_root_class @r{(Objective-C and Objective-C++ only)}
+@cindex @code{objc_root_class} type attribute
+This attribute marks a class as being a root class, and thus allows
+the compiler to elide any warnings about a missing superclass and to
+make additional checks for mandatory methods as needed.
+
  @end table
 
  To specify multiple attributes, separate them by commas within the
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 2b0a275a409..b3dc2dbdb0c 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -277,7 +277,7 @@  Objective-C and Objective-C++ Dialects}.
  -fzero-link @gol
  -gen-decls @gol
  -Wassign-intercept  -Wno-property-assign-default @gol
--Wno-protocol  -Wselector @gol
+-Wno-protocol -Wobjc-root-class -Wselector @gol
  -Wstrict-selector-match @gol
  -Wundeclared-selector}
 
@@ -4357,6 +4357,13 @@  from the superclass.  If you use the  
@option{-Wno-protocol} option, then
  methods inherited from the superclass are considered to be implemented,
  and no warning is issued for them.
 
+@item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)}
+@opindex Wobjc-root-class
+Warn if a class interface lacks a superclass. Most classes will inherit
+from @code{NSObject} (or @code{Object}) for example.  When declaring
+classes intended to be root classes, the warning can be suppressed by
+marking their interfaces with @code{__attribute__((objc_root_class))}.
+
  @item -Wselector @r{(Objective-C and Objective-C++ only)}
  @opindex Wselector
  @opindex Wno-selector
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index fc247220a62..0cab12eec50 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -571,11 +571,11 @@  lookup_protocol_in_reflist (tree rproto_list, tree  
lproto)
  }
 
  void
-objc_start_class_interface (tree klass, tree super_class,
+objc_start_class_interface (tree klass, location_t name_loc, tree  
super_class,
  			    tree protos, tree attributes)
  {
    if (flag_objc1_only && attributes)
-    error_at (input_location, "class attributes are not available in  
Objective-C 1.0");
+    error_at (name_loc, "class attributes are not available in Objective-C  
1.0");
 
    objc_interface_context
      = objc_ivar_context
@@ -7030,6 +7030,12 @@  start_class (enum tree_code code, tree class_name,  
tree super_name,
  	  CLASS_SUPER_NAME (objc_implementation_context)
  	    = CLASS_SUPER_NAME (implementation_template);
  	}
+
+      if (!CLASS_SUPER_NAME (objc_implementation_context)
+	  && !lookup_attribute ("objc_root_class",
+				TYPE_ATTRIBUTES (implementation_template)))
+	  warning (OPT_Wobjc_root_class, "class %qE defined without"
+		      " specifying a base class", class_name);
        break;
 
      case CLASS_INTERFACE_TYPE:
@@ -7062,6 +7068,8 @@  start_class (enum tree_code code, tree class_name,  
tree super_name,
  		TREE_DEPRECATED (klass) = 1;
  	      else if (is_attribute_p  ("objc_exception", name))
  		CLASS_HAS_EXCEPTION_ATTR (klass) = 1;
+	      else if (is_attribute_p  ("objc_root_class", name))
+		;
  	      else if (is_attribute_p  ("visibility", name))
  		;
  	      else
diff --git a/gcc/testsuite/obj-c++.dg/attributes/root-class-01.mm  
b/gcc/testsuite/obj-c++.dg/attributes/root-class-01.mm
new file mode 100644
index 00000000000..84da94aa1ff
--- /dev/null
+++ b/gcc/testsuite/obj-c++.dg/attributes/root-class-01.mm
@@ -0,0 +1,11 @@ 
+/* Test Wobjc-root-class warning is suppressed by the objc_root_class attr.
+   Note that we don't issue a warning unless the TU contains an  
implementation
+   for the class.  This should compile without warning.  */
+/*  { dg-additional-options "-fsyntax-only " } */
+
+__attribute__((objc_root_class))
+@interface ARootObject
+@end
+
+@implementation ARootObject
+@end
diff --git a/gcc/testsuite/obj-c++.dg/root-class-00.mm  
b/gcc/testsuite/obj-c++.dg/root-class-00.mm
new file mode 100644
index 00000000000..f951b0de8cc
--- /dev/null
+++ b/gcc/testsuite/obj-c++.dg/root-class-00.mm
@@ -0,0 +1,10 @@ 
+/* Test Wobjc-root-class.
+   Note that we don't issue a warning unless the TU contains an  
implementation
+   for the class.  */
+/*  { dg-additional-options "-fsyntax-only " } */
+
+@interface ARootObject
+@end
+
+@implementation ARootObject /* { dg-warning {class 'ARootObject' defined  
without specifying a base class} } */
+@end
diff --git a/gcc/testsuite/objc.dg/attributes/root-class-01.m  
b/gcc/testsuite/objc.dg/attributes/root-class-01.m
new file mode 100644
index 00000000000..84da94aa1ff
--- /dev/null
+++ b/gcc/testsuite/objc.dg/attributes/root-class-01.m
@@ -0,0 +1,11 @@ 
+/* Test Wobjc-root-class warning is suppressed by the objc_root_class attr.
+   Note that we don't issue a warning unless the TU contains an  
implementation
+   for the class.  This should compile without warning.  */
+/*  { dg-additional-options "-fsyntax-only " } */
+
+__attribute__((objc_root_class))
+@interface ARootObject
+@end
+
+@implementation ARootObject
+@end
diff --git a/gcc/testsuite/objc.dg/root-class-00.m  
b/gcc/testsuite/objc.dg/root-class-00.m
new file mode 100644
index 00000000000..1f73f735761
--- /dev/null
+++ b/gcc/testsuite/objc.dg/root-class-00.m
@@ -0,0 +1,10 @@ 
+/* Test Wobjc-root-class.
+   Note that we don't issue a warning unless the TU contains an  
implementation
+   for the class.  */
+/*  { dg-additional-options "-fsyntax-only " } */
+
+@interface ARootObject
+@end
+
+@implementation ARootObject