aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/obj-c++.dg/attributes')
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/attributes.exp43
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/categ-attribute-1.mm31
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/categ-attribute-2.mm32
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/class-attribute-1.mm61
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/class-attribute-2.mm21
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/class-attribute-3.mm14
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/invalid-attribute-1.mm6
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-attribute-1.mm40
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-attribute-2.mm33
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-attribute-3.mm24
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-1.mm33
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-2.mm23
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-3.mm21
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-format-1.mm43
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-nonnull-1.mm46
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-noreturn-1.mm34
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-sentinel-1.mm36
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/parameter-attribute-1.mm45
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/parameter-attribute-2.mm25
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-1.mm21
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-2.mm33
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-3.mm62
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-4.mm31
-rw-r--r--gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/unused-parameter-1.mm50
24 files changed, 808 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/attributes.exp b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/attributes.exp
new file mode 100644
index 000000000..6b5b29977
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/attributes.exp
@@ -0,0 +1,43 @@
+# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+#
+# This file is part of GCC.
+#
+# GCC is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GCC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# Load support procs.
+load_lib obj-c++-dg.exp
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_OBJCXXFLAGS
+if ![info exists DEFAULT_OBJCXXFLAGS] then {
+ set DEFAULT_OBJCXXFLAGS " -ansi -pedantic-errors -Wno-long-long"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Gather a list of all tests.
+set tests [lsort [glob -nocomplain $srcdir/$subdir/*.mm]]
+
+# Main loop.
+dg-runtest $tests "-fgnu-runtime" $DEFAULT_OBJCXXFLAGS
+
+# darwin targets can also run code with the NeXT runtime.
+if [istarget "*-*-darwin*" ] {
+ dg-runtest $tests "-fnext-runtime" $DEFAULT_OBJCXXFLAGS
+}
+
+# All done.
+dg-finish
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/categ-attribute-1.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/categ-attribute-1.mm
new file mode 100644
index 000000000..63d837fb6
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/categ-attribute-1.mm
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+
+#include <objc/objc.h>
+#include "../../objc-obj-c++-shared/TestsuiteObject.h"
+
+@interface obj : TestsuiteObject {
+@public
+ int var;
+}
+- (int) mth;
+@end
+
+@implementation obj
+- (int) mth { return var; }
+@end
+
+__attribute ((deprecated))
+@interface obj (dep_categ) /* { dg-warning "category attributes are not available in this version" } */
+- (int) depmth;
+@end
+
+@implementation obj (dep_categ)
+- (int) depmth { return var + 1; }
+@end
+
+int foo (void)
+{
+ obj *p = [obj new];
+ int q = [p depmth];
+ return [p mth];
+}
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/categ-attribute-2.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/categ-attribute-2.mm
new file mode 100644
index 000000000..934279eca
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/categ-attribute-2.mm
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+
+#include <objc/objc.h>
+#include "../../objc-obj-c++-shared/TestsuiteObject.h"
+
+@interface obj : TestsuiteObject {
+@public
+ int var;
+}
+- (int) mth;
+@end
+
+@implementation obj
+- (int) mth { return var; }
+@end
+
+__attribute__ ((deprecated("no dep_categ")))
+@interface obj (dep_categ) /* { dg-warning "category attributes are not available in this version" } */
+- (int) depmth;
+@end
+
+__attribute__ ((deprecated))
+@implementation obj (dep_categ) /* { dg-warning "prefix attributes are ignored before" } */
+- (int) depmth { return var + 1; }
+@end
+
+int foo (void)
+{
+ obj *p = [obj new];
+ int q = [p depmth];
+ return [p mth];
+}
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/class-attribute-1.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/class-attribute-1.mm
new file mode 100644
index 000000000..f078339b8
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/class-attribute-1.mm
@@ -0,0 +1,61 @@
+/* { dg-do compile } */
+/* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
+
+/* Test deprecate attribute with an @interface declaration. */
+
+#include <objc/objc.h>
+#include <objc/runtime.h>
+
+__attribute__ ((deprecated))
+@interface DeprecatedClass
+{
+ Class isa;
+}
++ (id) classObject;
++ (id) new;
+@end
+
+@implementation DeprecatedClass
++ (id) classObject { return self; }
++ (id) new { return nil; }
+@end
+
+@interface DeprecatedClass (Category) /* { dg-warning "is deprecated" } */
+@end
+
+@interface Subclass : DeprecatedClass /* { dg-warning "is deprecated" } */
+@end
+
+DeprecatedClass *object; /* { dg-warning "is deprecated" } */
+
+int function (DeprecatedClass *object) /* { dg-warning "is deprecated" } */
+{
+ /* Note how the following deprecation warning is generated by
+ "DeprecatedClass *", not by "[DeprecatedClass ...]. */
+ DeprecatedClass *x = [DeprecatedClass new]; /* { dg-warning "is deprecated" } */
+
+ if (x == object)
+ return 0;
+ else
+ return 1;
+}
+
+id function2 (void)
+{
+ return DeprecatedClass.classObject; /* { dg-warning "is deprecated" } */
+}
+
+@interface NormalClass
+{
+ Class isa;
+ DeprecatedClass *object; /* { dg-warning "is deprecated" } */
+}
+- (DeprecatedClass *)method; /* { dg-warning "is deprecated" } */
+@end
+
+@implementation NormalClass
+- (DeprecatedClass *)method /* { dg-warning "is deprecated" } */
+{
+ return nil;
+}
+@end
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/class-attribute-2.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/class-attribute-2.mm
new file mode 100644
index 000000000..35015c037
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/class-attribute-2.mm
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+
+#include <objc/objc.h>
+
+__attribute__ ((deprecated))
+@interface DeprecatedClass
+{
+ Class isa;
+}
++ (id) new;
+@end
+
+__attribute__ ((deprecated))
+@implementation DeprecatedClass /* { dg-warning "prefix attributes are ignored" } */
++ (id) new { return nil; }
+@end
+
+void function (void)
+{
+ DeprecatedClass *object = [DeprecatedClass new]; /* { dg-warning "is deprecated" } */
+}
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/class-attribute-3.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/class-attribute-3.mm
new file mode 100644
index 000000000..f96500de4
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/class-attribute-3.mm
@@ -0,0 +1,14 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010. */
+/* { dg-do compile } */
+
+/* Test that you get a warning when an unknown class attribute is ignored. */
+
+#include <objc/objc.h>
+
+__attribute__ ((unknown_attribute))
+@interface MyClass /* { dg-warning "ignored" } */
+{
+ Class isa;
+}
++ (id) new;
+@end
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/invalid-attribute-1.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/invalid-attribute-1.mm
new file mode 100644
index 000000000..96ee178d7
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/invalid-attribute-1.mm
@@ -0,0 +1,6 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, January 2011. */
+/* { dg-do compile } */
+
+#include <objc/objc.h>
+
+__attribute__ ((deprecated)) @class A; /* { dg-error "attributes may not be specified before the ..class. Objective-C.. keyword" } */
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-attribute-1.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-attribute-1.mm
new file mode 100644
index 000000000..60d7822f0
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-attribute-1.mm
@@ -0,0 +1,40 @@
+/* { dg-do compile } */
+
+#include <objc/objc.h>
+#include "../../objc-obj-c++-shared/TestsuiteObject.h"
+
+@interface obj : TestsuiteObject {
+@public
+ int var;
+}
+- (int) mth;
++ (id) dep_cls_mth __attribute__((deprecated)) ;
+- (int) dep_ins_mth __attribute__((deprecated)) ;
+- (int) dep_ins_mtharg: (int) i __attribute__((deprecated)) ;
+- (int) dep_ins_mtharg1: (int) i __attribute__((deprecated)) add: (int) j;/* { dg-error "method attributes must be specified at the end " } */
+- (int) nodef __attribute__((deprecated)) { return var-2; } ; /* { dg-error "expected ';' before '\{' token" } */
+__attribute__((deprecated))
+- (int) bad_pref_mth; /* { dg-warning "prefix attributes are ignored for methods" } */
+@end
+
+@implementation obj
+- (int) mth { return var; }
++ (id) dep_cls_mth { return self; }
+- (int) dep_ins_mth { return var ; }
+- (int) dep_ins_mtharg: (int) i { return var + i ; }
+- (int) dep_ins_mtharg1: (int) i add: (int) j { return var + i + j ; }
+- (int) bad_pref_mth { return var; };
+- (int) nodef { return var-2; } ;
+@end
+
+int foo (void)
+{
+ obj *p = [obj new];
+ id n = [obj dep_cls_mth]; /* { dg-warning "is deprecated" } */
+
+ [p dep_ins_mth]; /* { dg-warning "is deprecated" } */
+ [p dep_ins_mtharg:2]; /* { dg-warning "is deprecated" } */
+ [p dep_ins_mtharg1:3 add:3];
+
+ return [p mth];
+}
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-attribute-2.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-attribute-2.mm
new file mode 100644
index 000000000..90369cc66
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-attribute-2.mm
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+
+#include <objc/objc.h>
+#include "../../objc-obj-c++-shared/TestsuiteObject.h"
+
+@interface obj : TestsuiteObject {
+@public
+ int var;
+}
+- (int) depmth __attribute__((deprecated));
+- (int) depmtharg:(int) iarg __attribute__((deprecated));
+- (int) unusedarg:(int) __attribute__((unused)) uarg ;
+- (int) depunusedarg:(int) __attribute__((unused)) uarg __attribute__((deprecated)) ;
+@end
+
+@implementation obj
+- (int) depmth __attribute__((deprecated)) { return var; } /* { dg-warning "method attributes can not be specified in @implementation context" } */
+- (int) depmtharg:(int) iarg { return var + iarg ; }
+- (int) unusedarg:(int) __attribute__((unused)) uarg { return var; }
+- (int) depunusedarg:(int) __attribute__((unused)) uarg { return var; }
+@end
+
+int foo (void)
+{
+ obj *p = [obj new];
+
+ [p depmth]; /* { dg-warning "is deprecated" } */
+ [p depmtharg:1]; /* { dg-warning "is deprecated" } */
+ [p unusedarg:2]; /* { dg-bogus "is deprecated" } */
+ [p depunusedarg:3 ]; /* { dg-warning "is deprecated" } */
+
+ return [p depmtharg:0]; /* { dg-warning "is deprecated" } */
+}
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-attribute-3.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-attribute-3.mm
new file mode 100644
index 000000000..3993c5f17
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-attribute-3.mm
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+
+#include "../../objc-obj-c++-shared/TestsuiteObject.h"
+
+@interface obj : TestsuiteObject {
+@public
+ int var;
+}
+- (int) vargsn: (int) count, ... __attribute__((deprecated));
+@end
+
+@implementation obj
+- (int) vargsn: (int) count, ...
+{
+ return 0;
+}
+@end
+
+int foo (void)
+{
+ obj *p = [obj new];
+
+ return [p vargsn:0]; /* { dg-warning "'vargsn:' is deprecated .declared at" } */
+}
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-1.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-1.mm
new file mode 100644
index 000000000..8343856a5
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-1.mm
@@ -0,0 +1,33 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010. */
+/* { dg-do compile } */
+
+#include <objc/objc.h>
+
+@interface MyClass
+{
+ Class isa;
+}
++ (int) method;
+- (int) method;
++ (int) deprecatedClassMethod __attribute__((deprecated));
+- (int) deprecatedInstanceMethod __attribute__((deprecated));
+@end
+
+/* Test that deprecation warnings are produced, but not if the
+ receiver is of type 'id'. */
+void foo (void)
+{
+ Class c;
+ id object;
+ MyClass *another_object;
+
+ [c method];
+ [object method];
+ [c deprecatedClassMethod];
+ [object deprecatedInstanceMethod];
+
+ [object method];
+ [another_object method];
+ [MyClass deprecatedClassMethod]; /* { dg-warning "is deprecated" } */
+ [another_object deprecatedInstanceMethod]; /* { dg-warning "is deprecated" } */
+}
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-2.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-2.mm
new file mode 100644
index 000000000..1e5d87f3e
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-2.mm
@@ -0,0 +1,23 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010. */
+/* { dg-do compile } */
+
+#include <objc/objc.h>
+
+@interface MyClass
+{
+ Class isa;
+}
++ (int) deprecatedClassMethod: (id)firstObject, ... __attribute__((sentinel)) __attribute__((deprecated));
+- (int) deprecatedInstanceMethod: (id)firstobject, ... __attribute__((sentinel)) __attribute__((deprecated));
+@end
+
+/* Test that deprecation warnings are produced even if the method is
+ also marked with another attribute too (this is to test the
+ processing of multiple attributes). */
+void foo (void)
+{
+ MyClass *object = nil;
+
+ [MyClass deprecatedClassMethod: object, nil]; /* { dg-warning "is deprecated" } */
+ [object deprecatedInstanceMethod: object, nil]; /* { dg-warning "is deprecated" } */
+}
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-3.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-3.mm
new file mode 100644
index 000000000..5c715a20b
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-deprecated-3.mm
@@ -0,0 +1,21 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010. */
+/* { dg-do compile } */
+
+#include <objc/objc.h>
+
+/* Test that __attribute__ ((__deprecated__)) works as well as __attribute__ ((deprecated)). */
+@interface MyClass
+{
+ Class isa;
+}
++ (int) deprecatedClassMethod: (id)firstObject, ... __attribute__((__deprecated__));
+- (int) deprecatedInstanceMethod: (id)firstobject, ... __attribute__((__deprecated__));
+@end
+
+void foo (void)
+{
+ MyClass *object = nil;
+
+ [MyClass deprecatedClassMethod: object, nil]; /* { dg-warning "is deprecated" } */
+ [object deprecatedInstanceMethod: object, nil]; /* { dg-warning "is deprecated" } */
+}
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-format-1.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-format-1.mm
new file mode 100644
index 000000000..11ce8eebb
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-format-1.mm
@@ -0,0 +1,43 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010. */
+/* { dg-do compile } */
+/* { dg-options "-Wall" } */
+
+#include <objc/objc.h>
+#include <stdlib.h>
+
+@interface LogObject
+{
+ Class isa;
+}
++ (void) log: (int)level message: (const char *) my_format, ... __attribute__ ((format (printf, 2, 3)));
+- (void) log: (int)level message: (const char *) my_format, ... __attribute__ ((format (printf, 2, 3)));
+
++ (void) debug: (const char *) my_format, ... __attribute__ ((format (printf, 1, 2)));
+- (void) debug: (const char *) my_format, ... __attribute__ ((format (printf, 1, 2)));
+
+/* Just make sure a missing or invalid attribute won't crash the compiler. */
+- (void) log2: (int)level message: (const char *) my_format, ... __attribute__ ((format (printf, 2))); /* { dg-error "wrong" } */
++ (void) debug2: (const char *) my_format, ... __attribute__ ((format (printf))); /* { dg-error "wrong" } */
+- (void) debug2: (const char *) my_format, ... __attribute__ ((format (printf))); /* { dg-error "wrong" } */
++ (void) alert: (const char *) my_format __attribute__ ((format (printf, 1, 2))); /* { dg-error "args to be formatted is not ..." } */
+- (void) alert: (const char *) my_format __attribute__ ((format (printf, 1, 2))); /* { dg-error "args to be formatted is not ..." } */
+@end
+
+void test (LogObject *object)
+{
+ [object log: 2 message: "attribute only applies to variadic functions"];
+ [object log: 2 message: "attribute %s only applies to variadic functions", "'format'"];
+ [object log: 2 message: "attribute %s only applies to variadic functions"]; /* { dg-warning "expects a matching" } */
+
+ [object debug: "attribute only applies to variadic functions"];
+ [object debug: "attribute %s only applies to variadic functions", "'format'"];
+ [object debug: "attribute %s only applies to variadic functions"]; /* { dg-warning "expects a matching" } */
+
+ [LogObject log: 2 message: "attribute only applies to variadic functions"];
+ [LogObject log: 2 message: "attribute %s only applies to variadic functions", "'format'"];
+ [LogObject log: 2 message: "attribute %s only applies to variadic functions"]; /* { dg-warning "expects a matching" } */
+
+ [LogObject debug: "attribute only applies to variadic functions"];
+ [LogObject debug: "attribute %s only applies to variadic functions", "'format'"];
+ [LogObject debug: "attribute %s only applies to variadic functions"]; /* { dg-warning "expects a matching" } */
+}
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-nonnull-1.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-nonnull-1.mm
new file mode 100644
index 000000000..c554894b2
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-nonnull-1.mm
@@ -0,0 +1,46 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, May 2011. */
+/* { dg-do compile } */
+/* { dg-options "-Wall" } */
+
+#include <objc/objc.h>
+#include <stdlib.h>
+
+@interface MyArray
+{
+ Class isa;
+}
++ (void) addObject: (id)object __attribute__ ((nonnull));
+- (void) addObject: (id)object __attribute__ ((nonnull));
+
++ (void) insertObject: (id)object atIndex: (size_t)index __attribute__ ((nonnull (1)));
+- (void) insertObject: (id)object atIndex: (size_t)index __attribute__ ((nonnull (1)));
+
++ (void) insertObject: (id)object atIndex: (size_t)index andObject: (id)anotherObject atIndex: (size_t)anotherIndex __attribute__ ((nonnull (1, 3)));
+- (void) insertObject: (id)object atIndex: (size_t)index andObject: (id)anotherObject atIndex: (size_t)anotherIndex __attribute__ ((nonnull (1, 3)));
+
+/* Test the behaviour with invalid code. */
++ (void) removeObject: (id)object __attribute__ ((nonnull (0))); /* { dg-error "out-of-range" } */
+- (void) removeObject: (id)object __attribute__ ((nonnull (0))); /* { dg-error "out-of-range" } */
+
++ (void) removeObject: (id)object __attribute__ ((nonnull (2))); /* { dg-error "out-of-range" } */
+- (void) removeObject: (id)object __attribute__ ((nonnull (2))); /* { dg-error "out-of-range" } */
+
++ (void) removeObjectAtIndex: (size_t)object __attribute__ ((nonnull (1))); /* { dg-error "non-pointer operand" } */
+- (void) removeObjectAtIndex: (size_t)object __attribute__ ((nonnull (1))); /* { dg-error "non-pointer operand" } */
+
++ (void) removeObject: (id)object __attribute__ ((nonnull (MyArray))); /* { dg-error "" } */
+- (void) removeObject: (id)object __attribute__ ((nonnull (MyArray))); /* { dg-error "" } */
+@end
+
+void test (MyArray *object)
+{
+ [object addObject: object];
+ [object addObject: nil]; /* { dg-warning "null argument where non-null required" } */
+
+ [object insertObject: object atIndex: 4];
+ [object insertObject: nil atIndex: 4]; /* { dg-warning "null argument where non-null required" } */
+
+ [object insertObject: object atIndex: 2 andObject: object atIndex: 3];
+ [object insertObject: nil atIndex: 2 andObject: object atIndex: 3]; /* { dg-warning "null argument where non-null required" } */
+ [object insertObject: object atIndex: 2 andObject: nil atIndex: 3]; /* { dg-warning "null argument where non-null required" } */
+}
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-noreturn-1.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-noreturn-1.mm
new file mode 100644
index 000000000..717d6e65e
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-noreturn-1.mm
@@ -0,0 +1,34 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010. */
+/* { dg-do compile } */
+
+#include <objc/objc.h>
+#include <stdlib.h>
+
+@interface MyClass
+{
+ Class isa;
+}
++ (id) method1 __attribute__ ((noreturn));
+- (id) method2 __attribute__ ((noreturn));
++ (id) method3 __attribute__ ((noreturn));
+- (id) method4 __attribute__ ((noreturn));
+@end
+
+@implementation MyClass
++ (id) method1
+{
+ return self; /* { dg-warning "function declared .noreturn. has a .return. statement" } */
+} /* { dg-warning ".noreturn. function does return" "" { target *-*-* } 20 } */
+- (id) method2
+{
+ return self; /* { dg-warning "function declared .noreturn. has a .return. statement" } */
+} /* { dg-warning ".noreturn. function does return" "" { target *-*-* } 24 } */
++ (id) method3
+{
+ abort ();
+}
+- (id) method4
+{
+ abort ();
+}
+@end
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-sentinel-1.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-sentinel-1.mm
new file mode 100644
index 000000000..2b8e6fd25
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/method-sentinel-1.mm
@@ -0,0 +1,36 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010. */
+/* { dg-do compile } */
+/* { dg-options "-Wall" } */
+
+#include <objc/objc.h>
+#include <stdlib.h>
+/* Ensure a compatible definition of nil. */
+#include "../../objc-obj-c++-shared/objc-test-suite-types.h"
+
+@interface NSArray
+{
+ Class isa;
+}
++ (id) arrayWithObject: (id)object __attribute__ ((sentinel)); /* { dg-warning "attribute only applies to variadic functions" } */
++ (id) arrayWithObjects: (id)firstObject, ... __attribute__ ((sentinel));
+
+- (id) initWithObject: (id)object __attribute__ ((sentinel)); /* { dg-warning "attribute only applies to variadic functions" } */
+- (id) initWithObjects: (id)firstObject, ... __attribute__ ((sentinel));
+@end
+
+void test (id object)
+{
+ NSArray *array;
+
+ array = [NSArray arrayWithObject: object];
+ array = [NSArray arrayWithObjects: object, nil];
+ array = [NSArray arrayWithObjects: object, object, nil];
+ array = [NSArray arrayWithObjects: object]; /* { dg-warning "not enough variable arguments" } */
+ array = [NSArray arrayWithObjects: object, object]; /* { dg-warning "missing sentinel" } */
+
+ [array initWithObject: object];
+ [array initWithObjects: object, nil];
+ [array initWithObjects: object, object, nil];
+ [array initWithObjects: object]; /* { dg-warning "not enough variable arguments" } */
+ [array initWithObjects: object, object]; /* { dg-warning "missing sentinel" } */
+}
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/parameter-attribute-1.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/parameter-attribute-1.mm
new file mode 100644
index 000000000..a4ba25943
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/parameter-attribute-1.mm
@@ -0,0 +1,45 @@
+/* Test __attribute__((unused)) for an Objective-C method parameter. */
+/* { dg-do compile } */
+/* { dg-options "-Wunused-parameter" } */
+
+#include <objc/objc.h>
+
+@interface MyRootClass
+{
+ Class isa;
+}
+- (id) method1: (id) argument1;
+- (id) method2: (id) __attribute__((unused)) argument1;
+- (id) method3: (id) __attribute__((unused)) argument1
+ andArgument: (id) argument2;
+- (id) method4: (id) __attribute__((unused)) argument1
+ andArgument: (id) __attribute__((unused)) argument2;
+- (id) method5: (id) argument1
+ andArgument: (id) __attribute__ ((unused)) argument2;
+@end
+
+@implementation MyRootClass
+- (id) method1: (id) argument1 /* { dg-warning "unused parameter .argument1." } */
+{
+ return nil;
+}
+- (id) method2: (id) __attribute__((unused)) argument1
+{
+ return nil;
+}
+- (id) method3: (id) __attribute__((unused)) argument1
+ andArgument: (id) argument2 /* { dg-warning "unused parameter .argument2." } */
+{
+ return nil;
+}
+- (id) method4: (id) __attribute__((unused)) argument1
+ andArgument: (id) __attribute__((unused)) argument2
+{
+ return nil;
+}
+- (id) method5: (id) argument1
+ andArgument: (id) __attribute__ ((unused)) argument2 /* { dg-warning "unused parameter .argument1." } */
+{
+ return nil;
+}
+@end
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/parameter-attribute-2.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/parameter-attribute-2.mm
new file mode 100644
index 000000000..3908faf99
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/parameter-attribute-2.mm
@@ -0,0 +1,25 @@
+/* Test that we get warnings for unrecognized attributes. */
+/* { dg-do compile } */
+
+#include <objc/objc.h>
+
+@interface MyRootClass
+{
+ Class isa;
+}
+/* TODO: Emit warnings in the @interface as well. Currently we only emit
+ them in @implementation. */
++ (id) method1: (id) __attribute__ ((xxxxx)) argument1;
++ (id) method2: (id) __attribute__ ((noinline)) argument1;
+@end
+
+@implementation MyRootClass
++ (id) method1: (id) __attribute__ ((xxxxx)) argument1 /* { dg-warning ".xxxxx. attribute directive ignored" } */
+{
+ return argument1;
+}
++ (id) method2: (id) __attribute__ ((noinline)) argument1 /* { dg-warning ".noinline. attribute ignored" } */
+{
+ return argument1;
+}
+@end
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-1.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-1.mm
new file mode 100644
index 000000000..a852a7a6c
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-1.mm
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+
+#include <objc/objc.h>
+
+__attribute ((deprecated))
+@protocol dep_proto
+- (int) depprotomth;
+@end
+
+@interface obj <dep_proto> /* { dg-warning "is deprecated" } */
+{
+@public
+ int var;
+}
+- (int) mth;
+@end
+
+@implementation obj
+- (int) mth { return var; }
+- (int) depprotomth { return var + 1; }
+@end
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-2.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-2.mm
new file mode 100644
index 000000000..aba58ff33
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-2.mm
@@ -0,0 +1,33 @@
+/* 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" } { "" } } */
+
+/* Test deprecate attribute with a forward declarations of
+ @protocol. */
+
+#include <stdlib.h>
+#include <objc/objc.h>
+#include <objc/runtime.h>
+
+__attribute__ ((deprecated))
+@protocol DeprecatedProtocol1;
+
+@protocol NonDeprecatedProtocol1;
+
+void function1 (id <DeprecatedProtocol1> object); /* { dg-warning "is deprecated" } */
+void function2 (id <NonDeprecatedProtocol1> object);
+
+@class Class4;
+
+void function3 (Class4 <DeprecatedProtocol1> *object); /* { dg-warning "is deprecated" } */
+void function4 (Class4 <NonDeprecatedProtocol1> *object);
+void function5 (Class4 <NonDeprecatedProtocol1, DeprecatedProtocol1> *object); /* { dg-warning "is deprecated" } */
+
+int function6 (void)
+{
+ Protocol *p1 = @protocol (DeprecatedProtocol1); /* { dg-warning "is deprecated" } */
+ Protocol *p2 = @protocol (NonDeprecatedProtocol1);
+
+ return (p1 == p2);
+}
+
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-3.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-3.mm
new file mode 100644
index 000000000..fc5251eee
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-3.mm
@@ -0,0 +1,62 @@
+/* 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" } { "" } } */
+
+
+/* Test deprecate attribute with normal @protocol declarations. */
+
+
+#include <stdlib.h>
+#include <objc/objc.h>
+#include <objc/runtime.h>
+
+__attribute__ ((deprecated))
+@protocol DeprecatedProtocol1
+- (void) aMethod;
+@end
+
+@protocol NonDeprecatedProtocol1
+- (void) anotherMethod;
+@end
+
+@protocol Protocol2 <DeprecatedProtocol1> /* { dg-warning "is deprecated" } */
+- (void) someOtherMethod;
+@end
+
+@protocol Protocol3 <NonDeprecatedProtocol1>
+- (void) someOtherMethod2;
+@end
+
+@protocol Protocol4 <NonDeprecatedProtocol1, DeprecatedProtocol1> /* { dg-warning "is deprecated" } */
+- (void) someOtherMethod3;
+@end
+
+
+@interface Class1 <DeprecatedProtocol1> /* { dg-warning "is deprecated" } */
+@end
+
+@interface Class2 <NonDeprecatedProtocol1>
+@end
+
+@interface Class3 <NonDeprecatedProtocol1, DeprecatedProtocol1> /* { dg-warning "is deprecated" } */
+@end
+
+@interface Class2 (Category1) <DeprecatedProtocol1> /* { dg-warning "is deprecated" } */
+@end
+
+void function1 (id <DeprecatedProtocol1> object); /* { dg-warning "is deprecated" } */
+void function2 (id <NonDeprecatedProtocol1> object);
+
+@class Class4;
+
+void function3 (Class4 <DeprecatedProtocol1> *object); /* { dg-warning "is deprecated" } */
+void function4 (Class4 <NonDeprecatedProtocol1> *object);
+void function5 (Class4 <NonDeprecatedProtocol1, DeprecatedProtocol1> *object); /* { dg-warning "is deprecated" } */
+
+int function6 (void)
+{
+ Protocol *p1 = @protocol (DeprecatedProtocol1); /* { dg-warning "is deprecated" } */
+ Protocol *p2 = @protocol (NonDeprecatedProtocol1);
+
+ return (p1 == p2);
+}
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-4.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-4.mm
new file mode 100644
index 000000000..d2e5f28a1
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-4.mm
@@ -0,0 +1,31 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010. */
+/* { dg-do compile } */
+
+/* Test that you get a warning when an unknown protocol attribute is ignored. */
+
+#include <objc/objc.h>
+
+__attribute__ ((unknown_attribute))
+@protocol MyProtocol /* { dg-warning "ignored" } */
+- (id) new;
+@end
+
+__attribute__ ((unknown_attribute))
+@protocol MyProtocol2; /* { dg-warning "ignored" } */
+
+/* Use the protocols to double-check that no more warnings are
+ generated. */
+
+@interface MyClass <MyProtocol>
+@end
+
+int test (id <MyProtocol2> x)
+{
+ if (@protocol (MyProtocol) == @protocol (MyProtocol2))
+ return 1;
+
+ if (x)
+ return 2;
+
+ return 3;
+}
diff --git a/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/unused-parameter-1.mm b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/unused-parameter-1.mm
new file mode 100644
index 000000000..8fbb11e20
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/obj-c++.dg/attributes/unused-parameter-1.mm
@@ -0,0 +1,50 @@
+/* { dg-do compile } */
+
+#include <objc/objc.h>
+
+@interface MyRootClass
+{
+ Class isa;
+}
+- (id) method1: (id) argument1;
+- (id) method2: (id) __attribute__((unused)) argument1;
+- (id) method3: (id) __attribute__((unused)) argument1
+ andArgument: (id) argument2;
+- (id) method4: (id) __attribute__((unused)) argument1
+ andArgument: (id) __attribute__((unused)) argument2;
+- (id) method5: (id) argument1
+ andArgument: (id) __attribute__ ((unused)) argument2;
+- (id) method6: (id) argument1
+ andArgument: (id) argument2;
+@end
+
+@implementation MyRootClass
+- (id) method1: (id) argument1
+{
+ return nil;
+}
+- (id) method2: (id) __attribute__((unused)) argument1
+{
+ return nil;
+}
+- (id) method3: (id) __attribute__((unused)) argument1
+ andArgument: (id) argument2
+{
+ return nil;
+}
+- (id) method4: (id) __attribute__((unused)) argument1
+ andArgument: (id) __attribute__((unused)) argument2
+{
+ return nil;
+}
+- (id) method5: (id) argument1
+ andArgument: (id) __attribute__ ((unused)) argument2
+{
+ return nil;
+}
+- (id) method6: (id) argument1
+ andArgument: (id) argument2
+{
+ return nil;
+}
+@end