aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.apple
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.apple')
-rw-r--r--gcc/testsuite/gcc.apple/Wextra-tokens.c21
-rw-r--r--gcc/testsuite/gcc.apple/Wfour-char-constants-1.c12
-rw-r--r--gcc/testsuite/gcc.apple/Wfour-char-constants-2.c12
-rw-r--r--gcc/testsuite/gcc.apple/Wlong-double.c11
-rw-r--r--gcc/testsuite/gcc.apple/Wmost.c19
-rw-r--r--gcc/testsuite/gcc.apple/align-test-1.c605
-rw-r--r--gcc/testsuite/gcc.apple/align-test-2.c152
-rw-r--r--gcc/testsuite/gcc.apple/align-test-3.c123
-rw-r--r--gcc/testsuite/gcc.apple/align-test-4.c224
-rw-r--r--gcc/testsuite/gcc.apple/align-test-4.h43
-rw-r--r--gcc/testsuite/gcc.apple/align-test-5a.c87
-rw-r--r--gcc/testsuite/gcc.apple/align-test-5b.c87
-rw-r--r--gcc/testsuite/gcc.apple/align-test-5c.c87
-rw-r--r--gcc/testsuite/gcc.apple/altivec-1.c124
-rw-r--r--gcc/testsuite/gcc.apple/applecc.c14
-rw-r--r--gcc/testsuite/gcc.apple/const-cfstring-1.c29
-rw-r--r--gcc/testsuite/gcc.apple/const-cfstring-2.c13
-rw-r--r--gcc/testsuite/gcc.apple/const-cfstring-3.c29
-rw-r--r--gcc/testsuite/gcc.apple/dg.exp40
-rw-r--r--gcc/testsuite/gcc.apple/execute/bitfield-1.c52
-rw-r--r--gcc/testsuite/gcc.apple/execute/execute.exp43
-rw-r--r--gcc/testsuite/gcc.apple/framework1.c12
-rw-r--r--gcc/testsuite/gcc.apple/import.c9
-rw-r--r--gcc/testsuite/gcc.apple/importee.h3
-rw-r--r--gcc/testsuite/gcc.apple/inttypes-1.c21
-rw-r--r--gcc/testsuite/gcc.apple/no-warning.c8
-rw-r--r--gcc/testsuite/gcc.apple/one.framework/Headers/one.h3
-rw-r--r--gcc/testsuite/gcc.apple/pascal-strings-1.c46
-rw-r--r--gcc/testsuite/gcc.apple/pascal-strings-2.c45
-rw-r--r--gcc/testsuite/gcc.apple/preprocess.s16
-rw-r--r--gcc/testsuite/gcc.apple/special/liblongcall.c9
-rw-r--r--gcc/testsuite/gcc.apple/special/longcall-prog.c17
-rw-r--r--gcc/testsuite/gcc.apple/special/longcall.exp69
-rw-r--r--gcc/testsuite/gcc.apple/special/special.exp42
-rw-r--r--gcc/testsuite/gcc.apple/special/zerofill.c5
-rw-r--r--gcc/testsuite/gcc.apple/string-insns.c9
36 files changed, 2141 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.apple/Wextra-tokens.c b/gcc/testsuite/gcc.apple/Wextra-tokens.c
new file mode 100644
index 00000000000..08b3cb7745c
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/Wextra-tokens.c
@@ -0,0 +1,21 @@
+/* APPLE LOCAL file -Wextra-tokens */
+/* Lifted from gcc.dg/cpp/extratokens2.c. */
+/* Copyright (C) 2002 Free Software Foundation, Inc. */
+
+/* { dg-do preprocess } */
+/* { dg-options "-fno-show-column -Wextra-tokens" } */
+
+/* Tests that -Wextra-tokens correctly enables the checks
+ that are disabled by default. */
+
+#if 1
+#if 0
+#else foo /* { dg-warning "extra tokens" "bad warning" } */
+#endif / /* { dg-warning "extra tokens" "bad warning" } */
+#endif
+
+# 36 "file.c" 3
+
+/* ... but in a system header, it's acceptable. */
+#ifdef KERNEL
+#endif KERNEL /* { dg-bogus "extra tokens" "bad warning" } */
diff --git a/gcc/testsuite/gcc.apple/Wfour-char-constants-1.c b/gcc/testsuite/gcc.apple/Wfour-char-constants-1.c
new file mode 100644
index 00000000000..536396454b7
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/Wfour-char-constants-1.c
@@ -0,0 +1,12 @@
+/* APPLE LOCAL file -Wfour-char-constants */
+/* We warn by default on Darwin, so no specific option needed. */
+
+/* { dg-do compile { target "*-*-darwin*" } } */
+/* { dg-options "" } */
+
+int glob1 = 'a';
+int glob2 = 'ab'; /* { dg-warning "multi-character character constant" } */
+int glob3 = 'abc'; /* { dg-warning "multi-character character constant" } */
+int glob4 = 'abcd'; /* say nothing */
+int glob5 = 'abcde'; /* { dg-warning "character constant too long" } */
+
diff --git a/gcc/testsuite/gcc.apple/Wfour-char-constants-2.c b/gcc/testsuite/gcc.apple/Wfour-char-constants-2.c
new file mode 100644
index 00000000000..14115ba6fea
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/Wfour-char-constants-2.c
@@ -0,0 +1,12 @@
+/* APPLE LOCAL file -Wfour-char-constants */
+/* Explicitly enable the warning. */
+
+/* { dg-do compile } */
+/* { dg-options "-Wfour-char-constants" } */
+
+int glob1 = 'a';
+int glob2 = 'ab'; /* { dg-warning "multi-character character constant" } */
+int glob3 = 'abc'; /* { dg-warning "multi-character character constant" } */
+int glob4 = 'abcd'; /* { dg-warning "multi-character character constant" } */
+int glob5 = 'abcde'; /* { dg-warning "character constant too long" } */
+
diff --git a/gcc/testsuite/gcc.apple/Wlong-double.c b/gcc/testsuite/gcc.apple/Wlong-double.c
new file mode 100644
index 00000000000..2a42912b660
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/Wlong-double.c
@@ -0,0 +1,11 @@
+/* APPLE LOCAL file -Wlong-double */
+
+/* We warn by default, so no specific option needed. */
+
+/* { dg-do compile { target "*-*-darwin*" } } */
+/* { dg-options "" } */
+
+long double ld; /* { dg-warning "use of `long double' type" } */
+/* { dg-warning "is reported only once" "" { target *-*-* } 8 } */
+/* { dg-warning "disable this warning" "" { target *-*-* } 8 } */
+
diff --git a/gcc/testsuite/gcc.apple/Wmost.c b/gcc/testsuite/gcc.apple/Wmost.c
new file mode 100644
index 00000000000..6e1d3342539
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/Wmost.c
@@ -0,0 +1,19 @@
+/* APPLE LOCAL file -Wmost */
+
+/* { dg-do compile } */
+/* { dg-options "-Wmost" } */
+
+int baz (void);
+
+int
+foo ()
+{
+ int loc;
+
+ bar (); /* { dg-warning "implicit declaration" } */
+
+ if (loc = baz ()) /* be quiet about this */
+ return 1;
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.apple/align-test-1.c b/gcc/testsuite/gcc.apple/align-test-1.c
new file mode 100644
index 00000000000..f9bdb7b2c21
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/align-test-1.c
@@ -0,0 +1,605 @@
+/* APPLE LOCAL file Macintosh alignment */
+
+/* { dg-do run } */
+/* { dg-options "-Wno-long-long" } */
+
+/*
+ * Macintosh compiler alignment test for C.
+ * Fred Forsman
+ * Apple Computer, Inc.
+ * (C) 2000-2002.
+ * Last modified 2002-4-29
+ */
+
+#include <stdio.h>
+#include <stddef.h>
+#include <string.h>
+
+#define Q(x) #x, x
+
+typedef unsigned char UINT8;
+
+static int bad_option = 0;
+static int flag_verbose = 0;
+static int nbr_failures = 0;
+
+/* === basic types === */
+
+typedef struct B1 {
+ char f1;
+ UINT8 f2;
+} B1;
+
+typedef struct B2 {
+ short f1;
+ UINT8 f2;
+} B2;
+
+typedef struct B3 {
+ long f1;
+ UINT8 f2;
+} B3;
+
+typedef struct B4 {
+ int f1;
+ UINT8 f2;
+} B4;
+
+typedef struct B5 {
+ float f1;
+ UINT8 f2;
+} B5;
+
+/* doubles, long longs, and vectors are treated separately below. */
+
+/* === enums === */
+
+typedef enum E1 {
+ e1_b = 0,
+ e1_e = 255
+} E1;
+
+typedef enum E2 {
+ e2_b = -256,
+ e2_e = 255
+} E2;
+
+typedef enum E3 {
+ e3_b = 0,
+ e3_e = 32767
+} E3;
+
+typedef enum E4 {
+ e4_b = 0,
+ e4_e = 65536
+} E4;
+
+/* === pointers === */
+
+typedef struct P1 {
+ char * f1;
+ UINT8 f2;
+} P1;
+
+typedef struct P2 {
+ long * f1;
+ UINT8 f2;
+} P2;
+
+typedef struct P3 {
+ double * f1;
+ UINT8 f2;
+} P3;
+
+typedef struct P4 {
+ long long * f1;
+ UINT8 f2;
+} P4;
+
+typedef struct P5 {
+ void (* f1) (void);
+ UINT8 f2;
+} P5;
+
+#ifdef __VEC__
+typedef struct P61 {
+ vector signed short * f1;
+ UINT8 f2;
+} P6;
+#endif
+
+/* === vectors === */
+
+#ifdef __VEC__
+typedef struct V1 {
+ vector signed short f1;
+ UINT8 f2;
+} V1;
+
+typedef struct V2 {
+ V1 f1;
+ UINT8 f2;
+} V2;
+
+typedef struct V3 {
+ UINT8 f1;
+ vector signed short f2;
+} V3;
+
+typedef struct V4 {
+ V3 f1;
+ UINT8 f2;
+} V4;
+#endif
+
+/* === doubles === */
+
+typedef struct D1 {
+ double f1;
+ UINT8 f2;
+} D1;
+
+typedef struct D2 {
+ D1 f1;
+ UINT8 f2;
+} D2;
+
+typedef struct D3 {
+ UINT8 f1;
+ double f2;
+} D3;
+
+typedef struct D4 {
+ D3 f1;
+ UINT8 f2;
+} D4;
+
+typedef struct D5 {
+ UINT8 f1;
+ D3 f2;
+} D5;
+
+typedef struct D6 {
+ double f1;
+ UINT8 f2;
+ double f3;
+} D6;
+
+typedef struct D7 {
+ UINT8 f1;
+ D1 f2;
+} D7;
+
+/* === long longs === */
+
+typedef struct LL1 {
+ long long f1;
+ UINT8 f2;
+} LL1;
+
+typedef struct LL2 {
+ LL1 f1;
+ UINT8 f2;
+} LL2;
+
+typedef struct LL3 {
+ UINT8 f1;
+ long long f2;
+} LL3;
+
+typedef struct LL4 {
+ LL3 f1;
+ UINT8 f2;
+} LL4;
+
+typedef struct LL5 {
+ UINT8 f1;
+ LL3 f2;
+} LL5;
+
+/* === arrays === */
+
+typedef struct A1 {
+ short f1[4];
+ UINT8 f2;
+} A1;
+
+typedef struct A2 {
+ A1 f1;
+ UINT8 f2;
+} A2;
+
+typedef struct A3 {
+ double f1[4];
+ UINT8 f2;
+} A3;
+
+typedef struct A4 {
+ A3 f1;
+ UINT8 f2;
+} A4;
+
+typedef struct A5 {
+ long long f1[4];
+ UINT8 f2;
+} A5;
+
+typedef struct A6 {
+ A5 f1;
+ UINT8 f2;
+} A6;
+
+#ifdef __VEC__
+typedef struct A7 {
+ vector signed short f1[4];
+ UINT8 f2;
+} A7;
+
+typedef struct A8 {
+ A7 f1;
+ UINT8 f2;
+} A8;
+#endif
+
+typedef struct A9 {
+ D1 f1[4];
+ UINT8 f2;
+} A9;
+
+typedef struct A10 {
+ A9 f1;
+ UINT8 f2;
+} A10;
+
+/* === unions === */
+
+typedef union U1 {
+ UINT8 f1;
+ double f2;
+} U1;
+
+typedef struct U2 {
+ U1 f1;
+ UINT8 f2;
+} U2;
+
+typedef union U3 {
+ UINT8 f1;
+ long long f2;
+} U3;
+
+typedef struct U4 {
+ U3 f1;
+ UINT8 f2;
+} U4;
+
+#ifdef __VEC__
+typedef union U5 {
+ UINT8 f1;
+ vector signed short f2;
+} U5;
+
+typedef struct U6 {
+ U5 f1;
+ UINT8 f2;
+} U6;
+#endif
+
+typedef union U7 {
+ UINT8 f1;
+ short f2[4];
+} U7;
+
+typedef struct U8 {
+ U7 f1;
+ UINT8 f2;
+} U8;
+
+/* === misc === */
+
+typedef struct { /* unnamed struct */
+ long long f1;
+ UINT8 f2;
+} M0;
+
+typedef struct M1 {
+ UINT8 f1[8];
+} M1;
+
+typedef struct M2 {
+ M1 f1;
+ UINT8 f2;
+} M2;
+
+typedef struct M3 {
+ UINT8 f1;
+ M1 f2;
+} M3;
+
+typedef struct M4 { /* M4 & M5: see corresponding mac68k tests (M68K11 & M68K12) */
+ UINT8 f1[9];
+} M4;
+
+typedef struct M5 {
+ UINT8 f1;
+ M4 f2;
+} M5;
+
+/* === mac68k === */
+
+#pragma options align=mac68k
+
+typedef struct M68K0 {
+ long f1;
+ UINT8 f2;
+} M68K0;
+
+typedef struct M68K1 {
+ double f1;
+ UINT8 f2;
+} M68K1;
+
+#pragma options align=reset
+
+typedef struct M68K2 {
+ M68K1 f1;
+ UINT8 f2;
+} M68K2;
+
+#ifdef __VEC__
+#pragma options align=mac68k
+
+typedef struct M68K3 {
+ vector signed short f1;
+ UINT8 f2;
+} M68K3;
+
+typedef struct M68K4 {
+ M68K3 f1;
+ UINT8 f2;
+} M68K4;
+
+#pragma options align=reset
+
+typedef struct M68K5 {
+ M68K3 f1;
+ UINT8 f2;
+} M68K5;
+
+#pragma options align=mac68k
+
+typedef struct M68K6 {
+ UINT8 f1;
+ vector signed short f2;
+} M68K6;
+
+#pragma options align=reset
+#endif
+
+#pragma options align=mac68k
+
+typedef struct M68K7 {
+ UINT8 f1;
+} M68K7;
+
+typedef union M68K8 {
+ UINT8 f1;
+} M68K8;
+
+typedef struct M68K9 {
+ UINT8 f1;
+ int f2;
+ UINT8 f3;
+} M68K9;
+
+#pragma options align=reset
+
+typedef struct M68K10 {
+ UINT8 f1;
+ M68K9 f2;
+} M68K10;
+
+#pragma options align=mac68k
+
+typedef struct M68K11 { /* M68K11 & M68K12: see corresponding power tests (M4 & M5) */
+ UINT8 f1[9];
+} M68K11;
+
+typedef struct M68K12 {
+ UINT8 f1;
+ M68K11 f2;
+} M68K12;
+
+typedef struct M68K13 {
+ UINT8 f1;
+ UINT8 f2[5];
+} M68K13;
+
+#pragma options align=reset
+
+
+static void check(char * rec_name, int actual, int expected, char * comment)
+{
+ if (flag_verbose || (actual != expected)) {
+ printf("%-20s = %2d (%2d) ", rec_name, actual, expected);
+ if (actual != expected) {
+ printf("*** FAIL");
+ nbr_failures++;
+ } else
+ printf(" PASS");
+ printf(": %s\n", comment);
+ }
+}
+
+static void check_option(char *option)
+{
+ if (*option == '-') {
+ if (strcmp(option, "-v") == 0)
+ flag_verbose = 1;
+ else {
+ fprintf(stderr, "*** unrecognized option '%s'.\n", option);
+ bad_option = 1;
+ }
+ } else {
+ fprintf(stderr, "*** unrecognized option '%s'.\n", option);
+ bad_option = 1;
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ int i;
+
+ for (i = 1; i < argc; i++)
+ check_option(argv[i]);
+
+ if (bad_option)
+ return 1;
+
+ /* === basic data types === */
+
+ check(Q(sizeof(char)), 1, "char data type");
+ check(Q(sizeof(signed char)), 1, "signed char data type");
+ check(Q(sizeof(unsigned char)), 1, "unsigned char data type");
+ check(Q(sizeof(short)), 2, "short data type");
+ check(Q(sizeof(signed short)), 2, "signed short data type");
+ check(Q(sizeof(unsigned short)), 2, "unsigned short data type");
+ check(Q(sizeof(long)), 4, "short long type");
+ check(Q(sizeof(signed long)), 4, "signed long data type");
+ check(Q(sizeof(unsigned long)), 4, "unsigned long data type");
+ check(Q(sizeof(int)), 4, "short int type");
+ check(Q(sizeof(signed int)), 4, "signed int data type");
+ check(Q(sizeof(unsigned int)), 4, "unsigned int data type");
+ check(Q(sizeof(float)), 4, "float type");
+ check(Q(sizeof(double)), 8, "double data type");
+ check(Q(sizeof(long long)), 8, "long long data type");
+ check(Q(sizeof(signed long long)), 8, "signed long long data type");
+ check(Q(sizeof(unsigned long long)), 8, "unsigned long long data type");
+
+ check(Q(sizeof(B1)), 2, "char as 1st field");
+ check(Q(sizeof(B2)), 4, "short as 1st field");
+ check(Q(sizeof(B3)), 8, "long as 1st field");
+ check(Q(sizeof(B4)), 8, "int as 1st field");
+ check(Q(sizeof(B5)), 8, "float as 1st field");
+
+ /* === enums === */
+
+ check(Q(sizeof(E1)), 4, "enum with range 0..255");
+ check(Q(sizeof(E2)), 4, "enum with range -256..255");
+ check(Q(sizeof(E3)), 4, "enum with range 0..32767");
+ check(Q(sizeof(E4)), 4, "enum with range 0..65536");
+
+ /* === pointers === */
+
+ check(Q(sizeof(P1)), 8, "char * as 1st field");
+ check(Q(sizeof(P2)), 8, "long * as 1st field");
+ check(Q(sizeof(P3)), 8, "double * as 1st field");
+ check(Q(sizeof(P4)), 8, "long long * as 1st field");
+ check(Q(sizeof(P5)), 8, "function * as 1st field");
+
+#ifdef __VEC__
+ check(Q(sizeof(P6)), 8, "vector signed short * as 1st field");
+#endif
+
+#ifdef __VEC__
+ /* === vectors === */
+
+ /* ??? Do we want to test all the possible vector data types? ??? */
+ check(Q(sizeof(vector signed short)), 16, "vector signed short data type");
+
+ check(Q(sizeof(V1)), 32, "vector as 1st field");
+ check(Q(sizeof(V2)), 48, "embedding struct with vector as 1st field");
+ check(Q(sizeof(V3)), 32, "vector as 2nd field");
+ check(Q(offsetof(V3, f2)), 16, "offset of vector as 2nd field");
+ check(Q(sizeof(V4)), 48, "embedding struct with vector as 2nd field");
+#endif
+
+ /* === doubles === */
+
+ check(Q(sizeof(D1)), 16, "double as 1st field");
+ check(Q(sizeof(D2)), 24, "embedding struct with double as 1st field");
+ check(Q(sizeof(D3)), 12, "double as 2nd field");
+ check(Q(offsetof(D3, f2)), 4, "offset of double as 2nd field");
+ check(Q(sizeof(D4)), 16, "embedding struct with double as 2nd field");
+ check(Q(sizeof(D5)), 16, "struct with double as 2nd field");
+ check(Q(offsetof(D5, f2)), 4, "offset of struct with double as 2nd field");
+ check(Q(sizeof(D6)), 24, "struct with double, char, double");
+ check(Q(offsetof(D6, f3)), 12, "offset of 2nd double in struct with double, char, double");
+ check(Q(sizeof(D7)), 20, "struct with double as 2nd field of another struct");
+ check(Q(offsetof(D7, f2)), 4, "offset of struct with double as 2nd field of another struct");
+
+ /* === long longs === */
+
+ check(Q(sizeof(LL1)), 16, "long long as 1st field");
+ check(Q(sizeof(LL2)), 24, "embedding struct with long long as 1st field");
+ check(Q(sizeof(LL3)), 12, "long long as 2nd field");
+ check(Q(offsetof(LL3, f2)), 4, "offset of long long as 2nd field");
+ check(Q(sizeof(LL4)), 16, "embedding struct with long long as 2nd field");
+ check(Q(sizeof(LL5)), 16, "struct with long long as 2nd field");
+ check(Q(offsetof(LL5, f2)), 4, "offset of struct with long long as 2nd field");
+
+ /* === arrays === */
+
+ check(Q(sizeof(A1)), 10, "array of shorts as 1st field");
+ check(Q(sizeof(A2)), 12, "embedding struct with array of shorts as 1st field");
+ check(Q(sizeof(A3)), 40, "array of doubles as 1st field");
+ check(Q(sizeof(A4)), 48, "embedding struct with array of doubles as 1st field");
+ check(Q(sizeof(A5)), 40, "array of long longs as 1st field");
+ check(Q(sizeof(A6)), 48, "embedding struct with array of long longs as 1st field");
+#ifdef __VEC__
+ check(Q(sizeof(A7)), 80, "array of vectors as 1st field");
+ check(Q(sizeof(A8)), 96, "embedding struct with array of vectors as 1st field");
+#endif
+ check(Q(sizeof(A9)), 72, "array of structs as 1st field");
+ check(Q(sizeof(A10)), 80, "embedding struct with array of structs as 1st field");
+
+ /* === unions === */
+
+ check(Q(sizeof(U1)), 8, "union with double");
+ check(Q(sizeof(U2)), 16, "embedding union with double");
+ check(Q(sizeof(U3)), 8, "union with long long");
+ check(Q(sizeof(U4)), 16, "embedding union with long long");
+#if __VEC__
+ check(Q(sizeof(U5)), 16, "union with vector");
+ check(Q(sizeof(U6)), 32, "embedding union with vector");
+#endif
+ check(Q(sizeof(U7)), 8, "union with array of shorts");
+ check(Q(sizeof(U8)), 10, "embedding union with array of shorts");
+
+ /* === misc === */
+
+ check(Q(sizeof(M0)), 16, "untagged struct with long long as 1st field");
+ check(Q(sizeof(M1)), 8, "array[8] of char");
+ check(Q(sizeof(M2)), 9, "embedding struct with array[8] of char as 1st field");
+ check(Q(sizeof(M3)), 9, "embedding struct with array[8] of char as 2nd field");
+ check(Q(offsetof(M3, f2)), 1, "offset of struct with array[8] of char as 2nd field");
+ check(Q(sizeof(M4)), 9, "odd size struct: array[9] of char");
+ check(Q(sizeof(M5)), 10, "embedding odd size struct");
+
+ /* === mac68k mode === */
+
+ check(Q(sizeof(M68K0)), 6, "mac68k struct with long");
+ check(Q(sizeof(M68K1)), 10, "mac68k struct with double as 1st field");
+ check(Q(sizeof(M68K2)), 12, "embedding mac68k struct with double as 1st field");
+#ifdef __VEC__
+ check(Q(sizeof(M68K3)), 32, "mac68k struct with vector as 1st field");
+ check(Q(sizeof(M68K4)), 48, "embedding mac68k struct with vector as 1st field in a mac68k struct");
+ check(Q(sizeof(M68K5)), 48, "embedding mac68k struct with vector as 1st field in a power struct");
+ check(Q(offsetof(M68K6, f2)), 16, "offset of vector as 2nd field in a mac68k struct");
+#endif
+ check(Q(sizeof(M68K7)), 2, "padding of mac68k struct with one char");
+ check(Q(sizeof(M68K8)), 2, "padding of mac68k union with one char");
+ check(Q(sizeof(M68K9)), 8, "padding of mac68k struct");
+ check(Q(offsetof(M68K9, f2)), 2, "offset of int as 2nd field in a mac68k struct");
+ check(Q(sizeof(M68K10)), 10, "power struct with embedded mac68k struct");
+ check(Q(offsetof(M68K10, f2)), 2, "offset of mac68k struct as 2nd field in a power struct");
+ check(Q(sizeof(M68K11)), 10, "odd size struct (before padding): array[9] of char");
+ check(Q(sizeof(M68K12)), 12, "embedding odd size struct (before padding)");
+ check(Q(sizeof(M68K13)), 6, "array of char at odd addr in mac68k struct");
+ check(Q(offsetof(M68K13, f2)), 1, "offset of array of char at odd addr in mac68k struct");
+
+ if (nbr_failures > 0)
+ return 1;
+ else
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.apple/align-test-2.c b/gcc/testsuite/gcc.apple/align-test-2.c
new file mode 100644
index 00000000000..1e0ecc819c1
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/align-test-2.c
@@ -0,0 +1,152 @@
+/* APPLE LOCAL file Macintosh alignment */
+
+/* { dg-do run } */
+/* { dg-options "-Wno-long-long" } */
+
+/*
+ * Macintosh compiler alignment test for alignment extensions in GCC 3.
+ * Fred Forsman
+ * Apple Computer, Inc.
+ * (C) 2000-2002.
+ * Last modified 2002-1-22.
+ */
+
+ /* Check whether we are testing GCC 3 or later. */
+#ifdef __GNUC__
+#if __GNUC__ >= 3
+ #define GCC3 1
+#endif
+#endif
+
+#include <stdio.h>
+#include <stddef.h>
+#include <string.h>
+
+#define Q(x) #x, x
+
+typedef unsigned char UINT8;
+typedef unsigned long UINT32;
+
+static int bad_option = 0;
+static int flag_verbose = 0;
+static int nbr_failures = 0;
+
+/* === alignment modes === */
+
+typedef struct S1 {
+ UINT8 f1;
+} S1;
+
+#pragma options align=mac68k
+
+typedef struct S2 {
+ UINT8 f1;
+} S2;
+
+#pragma options align=native
+
+typedef struct S3 {
+ UINT8 f1;
+} S3;
+
+#pragma options align=reset
+/* Should be mac68k mode here. */
+
+#pragma options align=reset
+/* Should be power mode here. */
+
+typedef struct S4 {
+ UINT8 f1;
+ double f2;
+} S4;
+
+#pragma options align=natural
+
+typedef struct S5 {
+ UINT8 f1;
+ double f2;
+} S5;
+
+typedef struct S6 {
+ UINT8 f1;
+ double f2;
+ UINT8 f3;
+} S6;
+
+#pragma options align=reset
+/* Should be power mode here. */
+
+#pragma options align=packed
+
+typedef struct S7 {
+ UINT8 f1;
+ UINT32 f2;
+} S7;
+
+#pragma options align=reset
+/* Should be power mode here. */
+
+typedef struct S8 {
+ UINT8 f1;
+ UINT32 f2;
+} S8;
+
+static void check(char * rec_name, int actual, int expected, char * comment)
+{
+ if (flag_verbose || (actual != expected)) {
+ printf("%-20s = %2d (%2d) ", rec_name, actual, expected);
+ if (actual != expected) {
+ printf("*** FAIL");
+ nbr_failures++;
+ } else
+ printf(" PASS");
+ printf(": %s\n", comment);
+ }
+}
+
+static void check_option(char *option)
+{
+ if (*option == '-') {
+ if (strcmp(option, "-v") == 0)
+ flag_verbose = 1;
+ else {
+ fprintf(stderr, "*** unrecognized option '%s'.\n", option);
+ bad_option = 1;
+ }
+ } else {
+ fprintf(stderr, "*** unrecognized option '%s'.\n", option);
+ bad_option = 1;
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ int i;
+
+ for (i = 1; i < argc; i++)
+ check_option(argv[i]);
+
+ if (bad_option)
+ return 1;
+
+#ifndef GCC3
+ printf("This test requires GCC 3");
+ return 1;
+#endif
+
+ check(Q(sizeof(S1)), 1, "struct with 1 char; power mode");
+ check(Q(sizeof(S2)), 2, "struct with 1 char; mac68k mode");
+ check(Q(sizeof(S3)), 1, "struct with 1 char; native mode");
+ check(Q(sizeof(S4)), 12, "struct with char, double; power mode");
+ check(Q(offsetof(S4, f2)), 4, "offset of double in a struct with char, double; power mode");
+ check(Q(sizeof(S5)), 16, "struct with char, double; natural mode");
+ check(Q(offsetof(S5, f2)), 8, "offset of double in a struct with char, double; natural mode");
+ check(Q(sizeof(S6)), 24, "struct with char, double, char; natural mode");
+ check(Q(sizeof(S7)), 5, "struct with char, long; packed mode");
+ check(Q(sizeof(S8)), 8, "struct with char, long; power mode");
+
+ if (nbr_failures > 0)
+ return 1;
+ else
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.apple/align-test-3.c b/gcc/testsuite/gcc.apple/align-test-3.c
new file mode 100644
index 00000000000..1351031bec3
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/align-test-3.c
@@ -0,0 +1,123 @@
+/* APPLE LOCAL file Macintosh alignment */
+
+/* { dg-do run } */
+/* { dg-options "-Wno-long-long" } */
+
+/*
+ * GCC alignment test for alignment problems due to interactions
+ * between FSF and Macintosh alignment modes.
+ * Fred Forsman
+ * Apple Computer, Inc.
+ * (C) 2000-2002.
+ * Last modified 2002-1-22.
+ */
+
+ /* Check whether we are testing GCC 3 or later. */
+#ifdef __GNUC__
+#if __GNUC__ >= 3
+#define GCC3 1
+#else
+#define GCC3 0
+#endif
+#endif
+
+#include <stdio.h>
+#include <stddef.h>
+#include <string.h>
+
+#define Q(x) #x, x
+
+typedef unsigned char UINT8;
+typedef unsigned long UINT32;
+
+static int bad_option = 0;
+static int flag_verbose = 0;
+static int nbr_failures = 0;
+
+/* === alignment modes === */
+
+#pragma options align=power
+#pragma options align=mac68k
+#pragma pack(1)
+
+typedef struct S0 {
+ UINT32 f1;
+ UINT8 f2;
+} S0;
+
+#pragma options align=reset
+
+/* We should be back in mac68k alignment, if #pragma option align=reset
+ can rest a #pragma pack(n). So check for mac68k alignment. */
+
+typedef struct S1 {
+ UINT32 f1;
+ UINT8 f2;
+} S1;
+
+#if GCC3
+#pragma options align=power
+#pragma options align=mac68k
+//#pragma pack(push, 1)
+//#pragma pack(pop)
+#pragma pack(1)
+#pragma pack()
+
+/* We should be back in mac68k alignment, if #pragma pack()
+ can reset a #pragma pack(n). So check for mac68k alignment. */
+
+typedef struct S2 {
+ UINT32 f1;
+ UINT8 f2;
+} S2;
+#endif /* GCC3 */
+
+static void check(char * rec_name, int actual, int expected, char * comment)
+{
+ if (flag_verbose || (actual != expected)) {
+ printf("%-20s = %2d (%2d) ", rec_name, actual, expected);
+ if (actual != expected) {
+ printf("*** FAIL");
+ nbr_failures++;
+ } else
+ printf(" PASS");
+ printf(": %s\n", comment);
+ }
+}
+
+static void check_option(char *option)
+{
+ if (*option == '-') {
+ if (strcmp(option, "-v") == 0)
+ flag_verbose = 1;
+ else {
+ fprintf(stderr, "*** unrecognized option '%s'.\n", option);
+ bad_option = 1;
+ }
+ } else {
+ fprintf(stderr, "*** unrecognized option '%s'.\n", option);
+ bad_option = 1;
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ int i;
+
+ for (i = 1; i < argc; i++)
+ check_option(argv[i]);
+
+ if (bad_option)
+ return 1;
+
+ check(Q(sizeof(S0)), 5, "struct with 1 long, 1 char; pack(1) mode");
+ check(Q(sizeof(S1)), 6, "struct with 1 long, 1 char; should be mac68k mode");
+#if GCC3
+ check(Q(sizeof(S2)), 6, "struct with 1 long, 1 char; should be mac68k mode");
+#endif
+
+ if (nbr_failures > 0)
+ return 1;
+ else
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.apple/align-test-4.c b/gcc/testsuite/gcc.apple/align-test-4.c
new file mode 100644
index 00000000000..f07a10911f9
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/align-test-4.c
@@ -0,0 +1,224 @@
+/* APPLE LOCAL file Macintosh alignment */
+
+/* { dg-do run } */
+/* { dg-options "-Wno-long-long" } */
+
+/*
+ * GCC alignment test for bit-fields.
+ * This came up initially as an alignment problem in the kernel.
+ * Fred Forsman
+ * Apple Computer, Inc.
+ * (C) 2000-2002.
+ * Last modified 2002-2-18.
+ */
+
+ /* Check whether we are testing GCC 3 or later. */
+#ifdef __GNUC__
+#if __GNUC__ >= 3
+#define GCC3 1
+#else
+#define GCC3 0
+#endif
+#endif
+
+#include <stdio.h>
+#include <stddef.h>
+#include <string.h>
+
+/*
+ * The following defined determines whether we should compare against
+ * the values produced by GCC 2.95 or against the values I expect given
+ * my understanding of the alignment rules.
+ */
+#define USE_GCC2_VALUES 1
+
+#define NAME2(name,mode) mode##_##name
+#define NAME(name,mode) NAME2(name,mode)
+
+#define STR(s) #s
+#define SIZEOF3(name) STR(sizeof(name)), sizeof(name)
+#define SIZEOF2(name,mode) SIZEOF3(mode##_##name)
+#define SIZEOF(name,mode) SIZEOF2(name,mode)
+
+#define OFFSETOF3(name,field) STR(offsetof(name,field)), offsetof(name,field)
+#define OFFSETOF2(name,mode,field) OFFSETOF3(mode##_##name,field)
+#define OFFSETOF(name,mode,field) OFFSETOF2(name,mode,field)
+
+typedef unsigned char UINT8;
+typedef unsigned long UINT32;
+
+static int bad_option = 0;
+static int flag_verbose = 0;
+static int nbr_failures = 0;
+
+/* === mac68k alignment problem in kernel === */
+
+typedef unsigned PEF_UBits32, ByteCount;
+typedef short SInt16;
+
+/* === power === */
+#pragma options align=power
+#define MODE power
+#include "align-test-4.h"
+
+/* === mac68k === */
+#pragma options align=mac68k
+#undef MODE
+#define MODE mac68k
+#include "align-test-4.h"
+
+/* === pack(2) === */
+#pragma pack(2)
+#undef MODE
+#define MODE pack2
+#include "align-test-4.h"
+
+
+static void check(char * rec_name, int actual, int expected, char * comment)
+{
+ if (flag_verbose || (actual != expected)) {
+ printf("%-30s = %2d (%2d) ", rec_name, actual, expected);
+ if (actual != expected) {
+ printf("*** FAIL");
+ nbr_failures++;
+ } else
+ printf(" PASS");
+ printf(": %s\n", comment);
+ }
+}
+
+static void check_option(char *option)
+{
+ if (*option == '-') {
+ if (strcmp(option, "-v") == 0)
+ flag_verbose = 1;
+ else {
+ fprintf(stderr, "*** unrecognized option '%s'.\n", option);
+ bad_option = 1;
+ }
+ } else {
+ fprintf(stderr, "*** unrecognized option '%s'.\n", option);
+ bad_option = 1;
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ int i;
+
+ for (i = 1; i < argc; i++)
+ check_option(argv[i]);
+
+ if (bad_option)
+ return 1;
+
+#undef MODE
+#define MODE power
+
+#if USE_GCC2_VALUES
+ check(SIZEOF(LoaderExport, MODE), 12, "kernel struct");
+ check(OFFSETOF(LoaderExport, MODE, offset), 4, "offset of offset");
+ check(OFFSETOF(LoaderExport, MODE, sectionNumber), 8, "offset of sectionNumber");
+ check(SIZEOF(S1, MODE), 8, "bitfields & char");
+ check(SIZEOF(S2, MODE), 8, "int & char");
+ check(SIZEOF(S3, MODE), 12, "char, bitfields(32), char");
+ check(OFFSETOF(S3, MODE, f3), 8, "offset of 2nd char");
+ check(SIZEOF(S4, MODE), 8, "char, bitfields(32), char");
+ check(OFFSETOF(S4, MODE, f3), 7, "offset of 2nd char");
+ check(SIZEOF(S5, MODE), 4, "char, bitfields(16), char");
+ check(OFFSETOF(S5, MODE, f3), 3, "offset of 2nd char");
+ check(SIZEOF(S6, MODE), 4, "char, bitfields(8), char");
+ check(OFFSETOF(S6, MODE, f3), 2, "offset of 2nd char");
+#else
+ check(SIZEOF(LoaderExport, MODE), 12, "kernel struct");
+ check(OFFSETOF(LoaderExport, MODE, offset), 4, "offset of offset");
+ check(OFFSETOF(LoaderExport, MODE, sectionNumber), 8, "offset of sectionNumber");
+ check(SIZEOF(S1, MODE), 8, "bitfields & char");
+ check(SIZEOF(S2, MODE), 8, "int & char");
+ check(SIZEOF(S3, MODE), 12, "char, bitfields(32), char");
+ check(OFFSETOF(S3, MODE, f3), 8, "offset of 2nd char");
+ check(SIZEOF(S4, MODE), 12, "char, bitfields(32), char");
+ check(OFFSETOF(S4, MODE, f3), 8, "offset of 2nd char");
+ check(SIZEOF(S5, MODE), 12, "char, bitfields(16), char");
+ check(OFFSETOF(S5, MODE, f3), 8, "offset of 2nd char");
+ check(SIZEOF(S6, MODE), 12, "char, bitfields(8), char");
+ check(OFFSETOF(S6, MODE, f3), 8, "offset of 2nd char");
+#endif
+
+#undef MODE
+#define MODE mac68k
+
+#if USE_GCC2_VALUES
+ check(SIZEOF(LoaderExport, MODE), 10, "kernel struct");
+ check(OFFSETOF(LoaderExport, MODE, offset), 4, "offset of offset");
+ check(OFFSETOF(LoaderExport, MODE, sectionNumber), 8, "offset of sectionNumber");
+#if 1
+ // GCC 2 is wrong on the following.
+ check(SIZEOF(S1, MODE), 6, "bitfields & char");
+#else
+ check(SIZEOF(S1, MODE), 8, "bitfields & char");
+#endif
+ check(SIZEOF(S2, MODE), 6, "int & char");
+ check(SIZEOF(S3, MODE), 6, "char, bitfields(32), char");
+ check(OFFSETOF(S3, MODE, f3), 5, "offset of 2nd char");
+ check(SIZEOF(S4, MODE), 6, "char, bitfields(32), char");
+ check(OFFSETOF(S4, MODE, f3), 5, "offset of 2nd char");
+ check(SIZEOF(S5, MODE), 4, "char, bitfields(16), char");
+ check(OFFSETOF(S5, MODE, f3), 3, "offset of 2nd char");
+ check(SIZEOF(S6, MODE), 4, "char, bitfields(8), char");
+ check(OFFSETOF(S6, MODE, f3), 2, "offset of 2nd char");
+#else
+ check(SIZEOF(LoaderExport, MODE), 10, "kernel struct");
+ check(OFFSETOF(LoaderExport, MODE, offset), 4, "offset of offset");
+ check(OFFSETOF(LoaderExport, MODE, sectionNumber), 8, "offset of sectionNumber");
+ check(SIZEOF(S1, MODE), 6, "bitfields & char");
+ check(SIZEOF(S2, MODE), 6, "int & char");
+ check(SIZEOF(S3, MODE), 8, "char, bitfields(32), char");
+ check(OFFSETOF(S3, MODE, f3), 6, "offset of 2nd char");
+ check(SIZEOF(S4, MODE), 8, "char, bitfields(32), char");
+ check(OFFSETOF(S4, MODE, f3), 6, "offset of 2nd char");
+ check(SIZEOF(S5, MODE), 6, "char, bitfields(16), char");
+ check(OFFSETOF(S5, MODE, f3), 4, "offset of 2nd char");
+ check(SIZEOF(S6, MODE), 4, "char, bitfields(8), char");
+ check(OFFSETOF(S6, MODE, f3), 2, "offset of 2nd char");
+#endif
+
+#undef MODE
+#define MODE pack2
+
+#if USE_GCC2_VALUES
+ check(SIZEOF(LoaderExport, MODE), 10, "kernel struct");
+ check(OFFSETOF(LoaderExport, MODE, offset), 4, "offset of offset");
+ check(OFFSETOF(LoaderExport, MODE, sectionNumber), 8, "offset of sectionNumber");
+ /* GCC2 used to have this as '8', but it should really be 6. */
+ check(SIZEOF(S1, MODE), 6, "bitfields & char");
+ check(SIZEOF(S2, MODE), 6, "int & char");
+ check(SIZEOF(S3, MODE), 6, "char, bitfields(32), char");
+ check(OFFSETOF(S3, MODE, f3), 5, "offset of 2nd char");
+ check(SIZEOF(S4, MODE), 6, "char, bitfields(32), char");
+ check(OFFSETOF(S4, MODE, f3), 5, "offset of 2nd char");
+ check(SIZEOF(S5, MODE), 4, "char, bitfields(16), char");
+ check(OFFSETOF(S5, MODE, f3), 3, "offset of 2nd char");
+ check(SIZEOF(S6, MODE), 4, "char, bitfields(8), char");
+ check(OFFSETOF(S6, MODE, f3), 2, "offset of 2nd char");
+#else
+ check(SIZEOF(LoaderExport, MODE), 10, "kernel struct");
+ check(OFFSETOF(LoaderExport, MODE, offset), 4, "offset of offset");
+ check(OFFSETOF(LoaderExport, MODE, sectionNumber), 8, "offset of sectionNumber");
+ check(SIZEOF(S1, MODE), 6, "bitfields & char");
+ check(SIZEOF(S2, MODE), 6, "int & char");
+ check(SIZEOF(S3, MODE), 8, "char, bitfields(32), char");
+ check(OFFSETOF(S3, MODE, f3), 6, "offset of 2nd char");
+ check(SIZEOF(S4, MODE), 8, "char, bitfields(32), char");
+ check(OFFSETOF(S4, MODE, f3), 6, "offset of 2nd char");
+ check(SIZEOF(S5, MODE), 6, "char, bitfields(16), char");
+ check(OFFSETOF(S5, MODE, f3), 4, "offset of 2nd char");
+ check(SIZEOF(S6, MODE), 4, "char, bitfields(8), char");
+ check(OFFSETOF(S6, MODE, f3), 2, "offset of 2nd char");
+#endif
+
+ if (nbr_failures > 0)
+ return 1;
+ else
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.apple/align-test-4.h b/gcc/testsuite/gcc.apple/align-test-4.h
new file mode 100644
index 00000000000..f7c18727fee
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/align-test-4.h
@@ -0,0 +1,43 @@
+/* APPLE LOCAL file Macintosh alignment */
+
+typedef struct {
+ PEF_UBits32 symClass : 8;
+ PEF_UBits32 nameOffset : 24;
+ ByteCount offset;
+ SInt16 sectionNumber;
+} NAME(LoaderExport, MODE);
+
+typedef struct {
+ unsigned f1 : 32;
+ char f2;
+} NAME(S1, MODE);
+
+typedef struct {
+ unsigned f1;
+ char f2;
+} NAME(S2, MODE);
+
+typedef struct {
+ char f1;
+ unsigned f2 : 32;
+ char f3;
+} NAME(S3, MODE);
+
+typedef struct {
+ char f1;
+ unsigned f2_1 : 8;
+ unsigned f2_2 : 24;
+ char f3;
+} NAME(S4, MODE);
+
+typedef struct {
+ char f1;
+ unsigned f2 : 16;
+ char f3;
+} NAME(S5, MODE);
+
+typedef struct {
+ char f1;
+ unsigned f2 : 8;
+ char f3;
+} NAME(S6, MODE);
diff --git a/gcc/testsuite/gcc.apple/align-test-5a.c b/gcc/testsuite/gcc.apple/align-test-5a.c
new file mode 100644
index 00000000000..6833535fcec
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/align-test-5a.c
@@ -0,0 +1,87 @@
+/* APPLE LOCAL file Macintosh alignment */
+/* align-test-5*.c are all the same code but with different options. */
+
+/* { dg-do run } */
+/* { dg-options "-malign-natural -DSIZE=16" } */
+
+/*
+ * GCC alignment test for command line options for setting alignment modes.
+ * Fred Forsman
+ * Apple Computer, Inc.
+ * (C) 2000-2002.
+ * Last modified 2002-2-18.
+ *
+ */
+
+ /* Check whether we are testing GCC 3 or later. */
+#ifdef __GNUC__
+#if __GNUC__ >= 3
+#define GCC3 1
+#else
+#define GCC3 0
+#endif
+#endif
+
+#include <stdio.h>
+#include <stddef.h>
+#include <string.h>
+
+#define Q(x) #x, x
+
+typedef unsigned char UINT8;
+typedef unsigned long UINT32;
+
+static int bad_option = 0;
+static int flag_verbose = 0;
+static int nbr_failures = 0;
+
+typedef struct S0 {
+ UINT8 f1;
+ double f2;
+} S0;
+
+static void check(char * rec_name, int actual, int expected, char * comment)
+{
+ if (flag_verbose || (actual != expected)) {
+ printf("%-20s = %2d (%2d) ", rec_name, actual, expected);
+ if (actual != expected) {
+ printf("*** FAIL");
+ nbr_failures++;
+ } else
+ printf(" PASS");
+ printf(": %s\n", comment);
+ }
+}
+
+static void check_option(char *option)
+{
+ if (*option == '-') {
+ if (strcmp(option, "-v") == 0)
+ flag_verbose = 1;
+ else {
+ fprintf(stderr, "*** unrecognized option '%s'.\n", option);
+ bad_option = 1;
+ }
+ } else {
+ fprintf(stderr, "*** unrecognized option '%s'.\n", option);
+ bad_option = 1;
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ int i;
+
+ for (i = 1; i < argc; i++)
+ check_option(argv[i]);
+
+ if (bad_option)
+ return 1;
+
+ check(Q(sizeof(S0)), SIZE, "struct with 1 char, 1 double");
+
+ if (nbr_failures > 0)
+ return 1;
+ else
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.apple/align-test-5b.c b/gcc/testsuite/gcc.apple/align-test-5b.c
new file mode 100644
index 00000000000..6845bd34766
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/align-test-5b.c
@@ -0,0 +1,87 @@
+/* APPLE LOCAL file Macintosh alignment */
+/* align-test-5*.c are all the same code but with different options. */
+
+/* { dg-do run } */
+/* { dg-options "-malign-power -DSIZE=12" } */
+
+/*
+ * GCC alignment test for command line options for setting alignment modes.
+ * Fred Forsman
+ * Apple Computer, Inc.
+ * (C) 2000-2002.
+ * Last modified 2002-2-18.
+ *
+ */
+
+ /* Check whether we are testing GCC 3 or later. */
+#ifdef __GNUC__
+#if __GNUC__ >= 3
+#define GCC3 1
+#else
+#define GCC3 0
+#endif
+#endif
+
+#include <stdio.h>
+#include <stddef.h>
+#include <string.h>
+
+#define Q(x) #x, x
+
+typedef unsigned char UINT8;
+typedef unsigned long UINT32;
+
+static int bad_option = 0;
+static int flag_verbose = 0;
+static int nbr_failures = 0;
+
+typedef struct S0 {
+ UINT8 f1;
+ double f2;
+} S0;
+
+static void check(char * rec_name, int actual, int expected, char * comment)
+{
+ if (flag_verbose || (actual != expected)) {
+ printf("%-20s = %2d (%2d) ", rec_name, actual, expected);
+ if (actual != expected) {
+ printf("*** FAIL");
+ nbr_failures++;
+ } else
+ printf(" PASS");
+ printf(": %s\n", comment);
+ }
+}
+
+static void check_option(char *option)
+{
+ if (*option == '-') {
+ if (strcmp(option, "-v") == 0)
+ flag_verbose = 1;
+ else {
+ fprintf(stderr, "*** unrecognized option '%s'.\n", option);
+ bad_option = 1;
+ }
+ } else {
+ fprintf(stderr, "*** unrecognized option '%s'.\n", option);
+ bad_option = 1;
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ int i;
+
+ for (i = 1; i < argc; i++)
+ check_option(argv[i]);
+
+ if (bad_option)
+ return 1;
+
+ check(Q(sizeof(S0)), SIZE, "struct with 1 char, 1 double");
+
+ if (nbr_failures > 0)
+ return 1;
+ else
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.apple/align-test-5c.c b/gcc/testsuite/gcc.apple/align-test-5c.c
new file mode 100644
index 00000000000..fd9bd5cca4c
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/align-test-5c.c
@@ -0,0 +1,87 @@
+/* APPLE LOCAL file Macintosh alignment */
+/* align-test-5*.c are all the same code but with different options. */
+
+/* { dg-do run } */
+/* { dg-options "-malign-mac68k -DSIZE=10" } */
+
+/*
+ * GCC alignment test for command line options for setting alignment modes.
+ * Fred Forsman
+ * Apple Computer, Inc.
+ * (C) 2000-2002.
+ * Last modified 2002-2-18.
+ *
+ */
+
+ /* Check whether we are testing GCC 3 or later. */
+#ifdef __GNUC__
+#if __GNUC__ >= 3
+#define GCC3 1
+#else
+#define GCC3 0
+#endif
+#endif
+
+#include <stdio.h>
+#include <stddef.h>
+#include <string.h>
+
+#define Q(x) #x, x
+
+typedef unsigned char UINT8;
+typedef unsigned long UINT32;
+
+static int bad_option = 0;
+static int flag_verbose = 0;
+static int nbr_failures = 0;
+
+typedef struct S0 {
+ UINT8 f1;
+ double f2;
+} S0;
+
+static void check(char * rec_name, int actual, int expected, char * comment)
+{
+ if (flag_verbose || (actual != expected)) {
+ printf("%-20s = %2d (%2d) ", rec_name, actual, expected);
+ if (actual != expected) {
+ printf("*** FAIL");
+ nbr_failures++;
+ } else
+ printf(" PASS");
+ printf(": %s\n", comment);
+ }
+}
+
+static void check_option(char *option)
+{
+ if (*option == '-') {
+ if (strcmp(option, "-v") == 0)
+ flag_verbose = 1;
+ else {
+ fprintf(stderr, "*** unrecognized option '%s'.\n", option);
+ bad_option = 1;
+ }
+ } else {
+ fprintf(stderr, "*** unrecognized option '%s'.\n", option);
+ bad_option = 1;
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ int i;
+
+ for (i = 1; i < argc; i++)
+ check_option(argv[i]);
+
+ if (bad_option)
+ return 1;
+
+ check(Q(sizeof(S0)), SIZE, "struct with 1 char, 1 double");
+
+ if (nbr_failures > 0)
+ return 1;
+ else
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.apple/altivec-1.c b/gcc/testsuite/gcc.apple/altivec-1.c
new file mode 100644
index 00000000000..d2040d96bbc
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/altivec-1.c
@@ -0,0 +1,124 @@
+/* APPLE LOCAL file AltiVec */
+/* { dg-do run { target powerpc*-*-* } } */
+/* { dg-options "-faltivec -Wno-long-double" } */
+
+/* Test for correct handling of AltiVec constants passed
+ through '...' (va_arg). */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define CHECK_INVARIANT(expr) \
+ if (!(expr)) { \
+ printf ("ASSERT FAILED: %d: %s\n", __LINE__, #expr); \
+ abort (); \
+ }
+
+struct foo { int x; int y; };
+struct vfoo { int x; __vector signed int v; int y; };
+union u { __vector signed int v; signed int i[4]; };
+
+struct foo x_g = { 3, 4};
+struct vfoo vx_g = { 10, (vector signed int)(11, 12, 13, 14), 15 };
+__vector signed int v_g = (vector signed int) (22, 23, 24, 25);
+struct vfoo vx2_g = { 30, (vector signed int)(31, 32, 33, 34), 35 };
+__vector signed int v2_g = (vector signed int)(40, 41, 42, 43);
+int i_1 = 99, i_2 = 33;
+double d_2 = 1.5, d_3 = 1.75;
+long double ld_1 = 1.25;
+
+void bar (int i, ... )
+{
+ struct foo xi;
+ double d;
+ long double ld;
+ float f;
+ char c;
+ short s;
+ va_list ap;
+ va_start(ap, i);
+ xi = va_arg(ap, struct foo);
+ s = (short)va_arg(ap, int);
+ f = (float)va_arg(ap, double);
+ ld = va_arg(ap, long double);
+ c = (char)va_arg(ap, int);
+ d = va_arg(ap, double);
+ va_end(ap);
+
+ CHECK_INVARIANT (xi.x == x_g.x && xi.y == x_g.y);
+ CHECK_INVARIANT (s == (short)i_2);
+ CHECK_INVARIANT (f == (float)d_2);
+ CHECK_INVARIANT (ld == ld_1);
+ CHECK_INVARIANT (c == (char)i_1);
+ CHECK_INVARIANT (d == d_3);
+}
+
+void baz (int i, ... )
+{
+ struct vfoo vx, vx2;
+ __vector signed int v_i, v2_i;
+ int j, k, l;
+ va_list ap;
+ va_start(ap, i);
+ v_i = va_arg(ap, __vector signed int);
+ j = va_arg(ap, int);
+ vx = va_arg(ap, struct vfoo);
+ k = va_arg(ap, int);
+ v2_i = va_arg(ap, __vector signed int);
+ l = va_arg(ap, int);
+ vx2 = va_arg(ap, struct vfoo);
+ va_end(ap);
+
+ CHECK_INVARIANT (vec_all_eq (v_i, v_g));
+ CHECK_INVARIANT (j == i_1);
+ CHECK_INVARIANT (vx.x == vx_g.x && vec_all_eq(vx.v, vx_g.v) && vx.y == vx_g.y);
+ CHECK_INVARIANT (k == i_1);
+ CHECK_INVARIANT (vec_all_eq (v2_i, v2_g));
+ CHECK_INVARIANT (l == i_1);
+ CHECK_INVARIANT (vx2.x == vx2_g.x && vec_all_eq(vx2.v, vx2_g.v) && vx2.y == vx2_g.y);
+}
+
+void quux (int i, ... )
+{
+ __vector signed int v_i, v2_i;
+ union u vi, v2i;
+ va_list ap;
+ va_start(ap, i);
+ v_i = va_arg(ap, __vector signed int);
+ v2_i = va_arg(ap, __vector signed int);
+ va_end(ap);
+ vi.v = v_i;
+ v2i.v = v2_i;
+
+ CHECK_INVARIANT (vec_all_eq (v_i, v_g));
+ CHECK_INVARIANT (vec_all_eq (v2_i, v_g));
+ CHECK_INVARIANT (vec_all_eq (vi.v, v_g));
+ CHECK_INVARIANT (vec_all_eq (v2i.v, v_g));
+}
+
+void baz2 (int i, ... )
+{
+ struct vfoo vx;
+ union u vxi;
+ va_list ap;
+ va_start(ap, i);
+ vx = va_arg(ap, struct vfoo);
+ va_end(ap);
+ vxi.v = vx.v;
+
+ CHECK_INVARIANT (vx.x == vx_g.x && vec_all_eq(vx.v, vx_g.v) && vx.y == vx_g.y);
+ CHECK_INVARIANT (vec_all_eq (vxi.v, vx_g.v));
+}
+
+int main(void)
+{
+ CHECK_INVARIANT (sizeof(struct foo) == 8 && sizeof(struct vfoo) == 48);
+
+ bar(i_1, x_g, (short)i_2, (float)d_2, ld_1, (char)i_1, d_3);
+ baz(i_1, v_g, i_1, vx_g, i_1, v2_g, i_1, vx2_g);
+ quux(i_1, v_g, v_g);
+ baz2(i_1, vx_g);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.apple/applecc.c b/gcc/testsuite/gcc.apple/applecc.c
new file mode 100644
index 00000000000..757ad573272
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/applecc.c
@@ -0,0 +1,14 @@
+/* APPLE LOCAL file Apple version */
+/* { dg-do compile } */
+
+#if __APPLE_CC__ < 1000
+#error build number too small
+#endif
+#if __APPLE_CC__ > 32768
+#error build number too big
+#endif
+#if ! ( __APPLE_CC__ > 1000)
+#error build number not really a number
+#endif
+
+int x = __APPLE_CC__;
diff --git a/gcc/testsuite/gcc.apple/const-cfstring-1.c b/gcc/testsuite/gcc.apple/const-cfstring-1.c
new file mode 100644
index 00000000000..3e8c1194d20
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/const-cfstring-1.c
@@ -0,0 +1,29 @@
+/* APPLE LOCAL file constant CFStrings */
+/* Test whether the __builtin__CFStringMakeConstantString
+ "function" fails gracefully when handed a non-constant
+ argument. This will only work on MacOS X 10.1.2 and later. */
+/* Developed by Ziemowit Laski <zlaski@apple.com>. */
+
+/* { dg-do compile { target *-*-darwin* } } */
+/* { dg-options "-fconstant-cfstrings" } */
+
+typedef const struct __CFString *CFStringRef;
+
+#ifdef __CONSTANT_CFSTRINGS__
+#define CFSTR(STR) ((CFStringRef) __builtin___CFStringMakeConstantString (STR))
+#else
+#error __CONSTANT_CFSTRINGS__ not defined
+#endif
+
+extern int cond;
+extern const char *func(void);
+
+const CFStringRef s0 = CFSTR("Hello" "there");
+
+int main(void) {
+ CFStringRef s1 = CFSTR("Str1");
+ CFStringRef s2 = CFSTR(cond? "Str2": "Str3"); /* { dg-error "literal expression is not constant" } */
+ CFStringRef s3 = CFSTR(func()); /* { dg-error "literal expression is not constant" } */
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.apple/const-cfstring-2.c b/gcc/testsuite/gcc.apple/const-cfstring-2.c
new file mode 100644
index 00000000000..cbf09d3a977
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/const-cfstring-2.c
@@ -0,0 +1,13 @@
+/* APPLE LOCAL file constant CFStrings */
+/* Test whether the __builtin__CFStringMakeConstantString
+ "function" fails gracefully when used without the
+ -fconstant-cfstrings flag. */
+/* Developed by Ziemowit Laski <zlaski@apple.com>. */
+
+/* { dg-options "-fno-constant-cfstrings" } */
+/* { dg-do compile { target *-*-darwin* } } */
+
+typedef const struct __CFString *CFStringRef;
+
+const CFStringRef S = ((CFStringRef)__builtin___CFStringMakeConstantString("Testing"));
+/* { dg-error "built-in" "built-in function .* requires .* flag" { target *-*-* } 12 } */
diff --git a/gcc/testsuite/gcc.apple/const-cfstring-3.c b/gcc/testsuite/gcc.apple/const-cfstring-3.c
new file mode 100644
index 00000000000..aba558b1f8b
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/const-cfstring-3.c
@@ -0,0 +1,29 @@
+/* APPLE LOCAL file constant CFStrings */
+/* Test whether the __builtin__CFStringMakeConstantString
+ "function" generates compile-time objects with the correct layout. */
+/* Developed by Ziemowit Laski <zlaski@apple.com>. */
+
+/* { dg-do compile { target *-*-darwin* } } */
+/* { dg-options "-fconstant-cfstrings" } */
+
+typedef const struct __CFString *CFStringRef;
+
+#ifdef __CONSTANT_CFSTRINGS__
+#define CFSTR(STR) ((CFStringRef) __builtin___CFStringMakeConstantString (STR))
+#else
+#error __CONSTANT_CFSTRINGS__ not defined
+#endif
+
+extern int cond;
+extern const char *func(void);
+
+CFStringRef s0 = CFSTR("Hello" "there");
+
+void foo(void) {
+ const CFStringRef s1 = CFSTR("Str1");
+
+ s0 = s1;
+}
+
+/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+LC.*\n\[ \\t\]*\\.long\[ \\t\]+4\n" } } */
+/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+LC.*\n\[ \\t\]*\\.long\[ \\t\]+10\n" } } */
diff --git a/gcc/testsuite/gcc.apple/dg.exp b/gcc/testsuite/gcc.apple/dg.exp
new file mode 100644
index 00000000000..42fcefba10e
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/dg.exp
@@ -0,0 +1,40 @@
+# APPLE LOCAL file testsuite
+# Copyright (C) 1997 Free Software Foundation, Inc.
+
+# This program 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 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Apple-specific GCC testsuite driver.
+# Note that this is basically a clone of gcc.dg/dg.exp, updated
+# whenever the original file changes (which is not very often).
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CFLAGS
+if ![info exists DEFAULT_CFLAGS] then {
+ set DEFAULT_CFLAGS " -ansi -pedantic-errors -Wno-long-double"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+# APPLE LOCAL preprocess .s files
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cSs\]]] \
+ "" $DEFAULT_CFLAGS
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/gcc.apple/execute/bitfield-1.c b/gcc/testsuite/gcc.apple/execute/bitfield-1.c
new file mode 100644
index 00000000000..f013853f48e
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/execute/bitfield-1.c
@@ -0,0 +1,52 @@
+/* { dg-do run { target *-*-darwin* } } */
+/* { dg-options "-O2 -fss-const-prop" } */
+/* APPLE LOCAL */
+/* <rdar://problem/3366203>:Setup Assistant crashes in SetModificationDateToPasteboard */
+/* <rdar://problem/3379022>:GCC compiler error in bitfield handling */
+
+
+typedef struct
+{
+ unsigned int b01 : 1;
+ unsigned int b02 : 2;
+ unsigned int b03 : 1;
+ unsigned int b04 : 1;
+ unsigned int b05 : 1;
+ unsigned int b06 : 1;
+ unsigned int b07 : 3;
+ unsigned int b08 : 3;
+ unsigned int b09 : 3;
+ unsigned int b10 : 3;
+ unsigned int b11 : 8;
+ unsigned int b12 : 1;
+ unsigned int b13 : 4;
+} test_struct;
+
+void func( test_struct* s, int t )
+{
+ s->b12 = 0;
+ s->b02 = 0;
+}
+
+main()
+{
+ test_struct r = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
+
+ func (&r, 42);
+
+ if (r.b01 != 1
+ || r.b03 != 1
+ || r.b04 != 1
+ || r.b05 != 1
+ || r.b06 != 1
+ || r.b07 != 1
+ || r.b08 != 1
+ || r.b09 != 1
+ || r.b10 != 1
+ || r.b11 != 1
+ || r.b13 != 1)
+ {
+ abort();
+ }
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.apple/execute/execute.exp b/gcc/testsuite/gcc.apple/execute/execute.exp
new file mode 100644
index 00000000000..f7b1f5b5eeb
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/execute/execute.exp
@@ -0,0 +1,43 @@
+# Copyright (C) 1991, 1992, 1993, 1995, 1997 Free Software Foundation, Inc.
+
+# This program 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 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# This file was written by Rob Savoye. (rob@cygnus.com)
+# Modified and maintained by Jeffrey Wheat (cassidy@cygnus.com)
+
+#
+# These tests come from Torbjorn Granlund (tege@cygnus.com)
+# C torture test suite.
+#
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+# load support procs
+load_lib c-torture.exp
+
+#
+# main test loop
+#
+
+foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
+ # If we're only testing specific files and this isn't one of them, skip it.
+ if ![runtest_file_p $runtests $src] then {
+ continue
+ }
+
+ c-torture-execute $src
+}
diff --git a/gcc/testsuite/gcc.apple/framework1.c b/gcc/testsuite/gcc.apple/framework1.c
new file mode 100644
index 00000000000..bd0203669c2
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/framework1.c
@@ -0,0 +1,12 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc. */
+
+/* { dg-do preprocess } */
+/* { dg-options "-nostdinc -c -F${srcdir}/gcc.apple" } */
+
+/* Contributed by Devang Patel <dpatel@apple.com> */
+
+#include <one/one.h>
+int main()
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.apple/import.c b/gcc/testsuite/gcc.apple/import.c
new file mode 100644
index 00000000000..110a2d249ed
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/import.c
@@ -0,0 +1,9 @@
+/* APPLE LOCAL file #import not deprecated */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+#import "importee.h"
+
+#import "importee.h"
+
+void foo (bar x) {}
diff --git a/gcc/testsuite/gcc.apple/importee.h b/gcc/testsuite/gcc.apple/importee.h
new file mode 100644
index 00000000000..86fbd11da4d
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/importee.h
@@ -0,0 +1,3 @@
+/* APPLE LOCAL file #import not deprecated */
+
+typedef int bar;
diff --git a/gcc/testsuite/gcc.apple/inttypes-1.c b/gcc/testsuite/gcc.apple/inttypes-1.c
new file mode 100644
index 00000000000..40404e2995b
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/inttypes-1.c
@@ -0,0 +1,21 @@
+/* APPLE LOCAL file test of inttypes.h formatter macros */
+
+/* { dg-do compile } */
+/* { dg-options "-Wall -W" } */
+
+#include <stdio.h>
+#include <inttypes.h>
+#include <stdint.h>
+
+int main ()
+{
+ uint32_t x = 12;
+ int32_t y = 15;
+ printf("x = %" PRIo32 "\n", x);
+ printf("x = %" PRIu32 "\n", x);
+ printf("x = %" PRIx32 "\n", x);
+ printf("x = %" PRIX32 "\n", x);
+ printf("y = %" PRId32 "\n", y);
+ printf("y = %" PRIi32 "\n", y);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.apple/no-warning.c b/gcc/testsuite/gcc.apple/no-warning.c
new file mode 100644
index 00000000000..9b71d722239
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/no-warning.c
@@ -0,0 +1,8 @@
+/* APPLE LOCAL file -Wno-#warnings */
+
+/* { dg-do compile } */
+/* { dg-options "-Wno-#warnings" } */
+
+#warning "suppress this warning"
+
+int a;
diff --git a/gcc/testsuite/gcc.apple/one.framework/Headers/one.h b/gcc/testsuite/gcc.apple/one.framework/Headers/one.h
new file mode 100644
index 00000000000..50c24d3e6c5
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/one.framework/Headers/one.h
@@ -0,0 +1,3 @@
+/* Contributed by Devang Patel <dpatel@apple.com> */
+
+/* Empty header */
diff --git a/gcc/testsuite/gcc.apple/pascal-strings-1.c b/gcc/testsuite/gcc.apple/pascal-strings-1.c
new file mode 100644
index 00000000000..c4e2d86ddc9
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/pascal-strings-1.c
@@ -0,0 +1,46 @@
+/* APPLE LOCAL file pascal strings */
+/* Positive C test cases. */
+/* Origin: Ziemowit Laski <zlaski@apple.com> */
+/* { dg-do run } */
+/* { dg-options "-std=iso9899:1999 -fpascal-strings" } */
+
+typedef __WCHAR_TYPE__ wchar_t;
+typedef __SIZE_TYPE__ size_t;
+
+extern void abort (void);
+extern size_t strlen (const char *s);
+
+const unsigned char *pascalStr1 = "\pHello, World!";
+const unsigned char *concat1 = "\pConcatenated" "string" "\pliteral";
+
+const unsigned char msg1[] = "\pHello"; /* ok */
+const unsigned char *msg2 = "\pHello"; /* ok */
+const signed char msg3[] = "\pHello"; /* ok */
+const char msg4[] = "\pHello"; /* ok */
+unsigned char msg5[] = "\pHello"; /* ok */
+signed char msg7[] = "\pHello"; /* ok */
+char msg8[] = "\pHello"; /* ok */
+
+int
+main (void)
+{
+ const unsigned char *pascalStr2 = "\pGood-bye!";
+
+ if (strlen ((const char *)pascalStr1) != 14)
+ abort ();
+ if (*pascalStr1 != 13)
+ abort (); /* the length byte does not include trailing null */
+
+ if (strlen ((const char *)pascalStr2) != 10)
+ abort ();
+ if (*pascalStr2 != 9)
+ abort ();
+
+ if (strlen ((const char *)concat1) != 26)
+ abort ();
+ if (*concat1 != 25)
+ abort ();
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.apple/pascal-strings-2.c b/gcc/testsuite/gcc.apple/pascal-strings-2.c
new file mode 100644
index 00000000000..6b617fa32c5
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/pascal-strings-2.c
@@ -0,0 +1,45 @@
+/* APPLE LOCAL file pascal strings */
+/* Negative C test cases. */
+/* Origin: Ziemowit Laski <zlaski@apple.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -Wwrite-strings -fpascal-strings" } */
+
+typedef __WCHAR_TYPE__ wchar_t;
+
+const wchar_t *pascalStr1 = L"\pHi!"; /* { dg-warning "unknown escape sequence" } */
+const wchar_t *pascalStr2 = L"Bye\p!"; /* { dg-warning "unknown escape sequence" } */
+
+const wchar_t *initErr0 = "\pHi"; /* { dg-warning "incompatible pointer type" } */
+const wchar_t initErr0a[] = "\pHi"; /* { dg-error "initialized from non-wide string" } */
+const wchar_t *initErr1 = "Bye"; /* { dg-warning "incompatible pointer type" } */
+const wchar_t initErr1a[] = "Bye"; /* { dg-error "initialized from non-wide string" } */
+
+const char *initErr2 = L"Hi"; /* { dg-warning "incompatible pointer type" } */
+const char initErr2a[] = L"Hi"; /* { dg-error "initialized from wide string" } */
+const signed char *initErr3 = L"Hi"; /* { dg-warning "incompatible pointer type" } */
+const signed char initErr3a[] = L"Hi"; /* { dg-error "initialized from wide string" } */
+const unsigned char *initErr4 = L"Hi"; /* { dg-warning "incompatible pointer type" } */
+const unsigned char initErr4a[] = L"Hi"; /* { dg-error "initialized from wide string" } */
+
+const char *pascalStr3 = "Hello\p, World!"; /* { dg-warning "unknown escape sequence" } */
+
+const char *concat2 = "Hi" "\pthere"; /* { dg-warning "unknown escape sequence" } */
+const char *concat3 = "Hi" "there\p"; /* { dg-warning "unknown escape sequence" } */
+
+const char *s2 = "\pGoodbye!"; /* ok */
+unsigned char *s3 = "\pHi!"; /* { dg-warning "initialization discards qualifiers" } */
+char *s4 = "\pHi"; /* { dg-warning "initialization discards qualifiers" } */
+signed char *s5 = "\pHi"; /* { dg-warning "initialization discards qualifiers" } */
+const signed char *s6 = "\pHi"; /* ok */
+
+/* the maximum length of a Pascal literal is 255. */
+const unsigned char *almostTooLong =
+ "\p12345678901234567890123456789012345678901234567890123456789012345678901234567890"
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
+ "123456789012345"; /* ok */
+const unsigned char *definitelyTooLong =
+ "\p12345678901234567890123456789012345678901234567890123456789012345678901234567890"
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
+ "1234567890123456"; /* { dg-error "too long" } */
diff --git a/gcc/testsuite/gcc.apple/preprocess.s b/gcc/testsuite/gcc.apple/preprocess.s
new file mode 100644
index 00000000000..897f2a7d6b1
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/preprocess.s
@@ -0,0 +1,16 @@
+/* APPLE LOCAL file preprocess .s files */
+
+/* Regression test - in assembly language, # may have some significance
+ other than 'stringize macro argument' and therefore must be preserved
+ in the output, and should not be warned about. */
+
+/* { dg-do preprocess } */
+
+#define foo() mov r0, #5 /* { dg-bogus "not followed" "spurious warning" } */
+
+entry:
+ foo()
+
+/* Check we don't EOF on an unknown directive. */
+#unknown directive
+#error a later diagnostic /* { dg-error "diagnostic" } */
diff --git a/gcc/testsuite/gcc.apple/special/liblongcall.c b/gcc/testsuite/gcc.apple/special/liblongcall.c
new file mode 100644
index 00000000000..297e473927a
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/special/liblongcall.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-mlongcall" } */
+
+int
+dy_foo (char *str, int i)
+{
+ printf ("dy_foo (\"%s\", %d)\n", str, i);
+ return i + 1;
+}
diff --git a/gcc/testsuite/gcc.apple/special/longcall-prog.c b/gcc/testsuite/gcc.apple/special/longcall-prog.c
new file mode 100644
index 00000000000..59448507350
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/special/longcall-prog.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+
+/* declare all externally visible functions in libweak.c */
+int dy_foo (char *, int);
+
+main ()
+{
+ int answer, x=41;
+ char *str = "foostr";
+ printf ("%s begins:\n", __FILE__);
+ answer = dy_foo (str, x);
+ printf ("dy_foo (\"%s\", %d) = %d", str, x, answer);
+ if (answer != 42)
+ printf (" (error!)");
+ printf ("\n%s done.\n", __FILE__);
+ exit (answer != 42);
+}
diff --git a/gcc/testsuite/gcc.apple/special/longcall.exp b/gcc/testsuite/gcc.apple/special/longcall.exp
new file mode 100644
index 00000000000..d9ebd1270ea
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/special/longcall.exp
@@ -0,0 +1,69 @@
+# APPLE LOCAL file testsuite
+# Copyright (C) 2002 Free Software Foundation, Inc.
+
+# This program 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 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+# Initialize `dg'.
+dg-init
+
+set timeout 30
+
+set prms_id 0
+set bug_id 0
+
+set testfile "longcall-prog"
+set binfile ${objdir}/${subdir}/${testfile}
+set srcfile ${srcdir}/${subdir}/${testfile}.c
+
+set libfilestem "longcall"
+set libfile "lib${libfilestem}"
+set libbinfile ${objdir}/${subdir}/${libfile}.dylib
+set libsrcfile ${srcdir}/${subdir}/${libfile}.c
+
+file mkdir ${objdir}/${subdir}
+
+set test "longcall/dylib"
+
+proc note_result {success diagnostic} {
+ set verb [expr {($success) ? "pass" : "fail"}]
+ eval {$verb $diagnostic}
+}
+
+set whine "building $test library"
+set additional_flags "additional_flags=-dynamiclib -mlongcall"
+set result [expr {[gcc_target_compile "${libsrcfile}" "${libbinfile}" executable [list debug $additional_flags]] == ""}]
+note_result $result $whine
+
+set whine "building $test test program"
+set additional_flags "additional_flags=-L${objdir}/${subdir} -l${libfilestem}"
+set result [expr {[gcc_target_compile "${srcfile}" "${binfile}" executable [list debug $additional_flags]] == ""}]
+note_result $result $whine
+
+set result [gcc_load "$binfile" "" ""]
+set status [lindex $result 0]
+set output [lindex $result 1];
+if {$status == "pass" } {
+ pass $test
+ file delete $libbinfile $binfile
+} else {
+ fail $test
+}
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/gcc.apple/special/special.exp b/gcc/testsuite/gcc.apple/special/special.exp
new file mode 100644
index 00000000000..5344a4817b7
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/special/special.exp
@@ -0,0 +1,42 @@
+# APPLE LOCAL file testsuite
+# Copyright (C) 2002 Free Software Foundation, Inc.
+
+# This program 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 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+# Initialize `dg'.
+dg-init
+
+# Test the zerofill support by seeing if a file with a large array
+# compiled -fno-common has a small size on disk.
+
+gcc_target_compile "$srcdir/$subdir/zerofill.c" "zerofill.o" object \
+ "additional_flags=-fno-common"
+
+set size [ exec wc -c < zerofill.o ]
+
+if { $size < 100000 } {
+ pass "zerofill"
+} else {
+ fail "zerofill"
+}
+
+file delete zerofill.o
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/gcc.apple/special/zerofill.c b/gcc/testsuite/gcc.apple/special/zerofill.c
new file mode 100644
index 00000000000..e4bd84c816f
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/special/zerofill.c
@@ -0,0 +1,5 @@
+/* APPLE LOCAL file zerofill */
+
+int arr[40000];
+
+foo() {}
diff --git a/gcc/testsuite/gcc.apple/string-insns.c b/gcc/testsuite/gcc.apple/string-insns.c
new file mode 100644
index 00000000000..741ab60f5df
--- /dev/null
+++ b/gcc/testsuite/gcc.apple/string-insns.c
@@ -0,0 +1,9 @@
+/* APPLE LOCAL radar 3509006 */
+/* { dg-do compile { target powerpc*-apple-darwin* } } */
+/* { dg-options "-Os" } */
+/* On ppc at Apple, -Os should not use string instructions. 3509006. */
+struct s { int a; int b; int c; };
+int foo (struct s* p, struct s* q) {
+ *p = *q;
+}
+/* { dg-final { scan-assembler-not "lswi" } } */