summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/special
diff options
context:
space:
mode:
authorwilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4>1999-02-10 16:00:06 +0000
committerwilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4>1999-02-10 16:00:06 +0000
commit0fccd442171e05f4ac28bdab373ccbaefe43031c (patch)
tree5d29afda084c03e56ec97ba6e7be2a56a96e1b9d /gcc/testsuite/gcc.dg/special
parent9059bc322498251936fc1b2c681d888fb5930fd0 (diff)
downloadgcc-0fccd442171e05f4ac28bdab373ccbaefe43031c.tar.gz
Test gcc features used by ECOS.
* gcc.dg/special/ecos.exp: New test driver for new tests with special requirements. * gcc.dg/special/alias-1.c: New test. * gcc.dg/special/gcsec-1.c: New test. * gcc.dg/special/weak-1.c: New test. * gcc.dg/special/weak-1a.c: Accompanying file to weak-1.c. * gcc.dg/special/weak-2.c: New test. * gcc.dg/special/weak-2a.c: Accompanying file to weak-2.c. * gcc.dg/special/weak-2b.c: Accompanying file to weak-2.c. * gcc.dg/special/wkali-1.c: New test. * gcc.dg/special/wkali-2.c: New test. * gcc.dg/special/wkali-2a.c: Accompanying file to wkali-2.c. * gcc.dg/special/wkali-2b.c: Accompanying file to wkali-2.c. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@25139 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/special')
-rw-r--r--gcc/testsuite/gcc.dg/special/alias-1.c15
-rw-r--r--gcc/testsuite/gcc.dg/special/ecos.exp214
-rw-r--r--gcc/testsuite/gcc.dg/special/gcsec-1.c21
-rw-r--r--gcc/testsuite/gcc.dg/special/weak-1.c15
-rw-r--r--gcc/testsuite/gcc.dg/special/weak-1a.c3
-rw-r--r--gcc/testsuite/gcc.dg/special/weak-2.c11
-rw-r--r--gcc/testsuite/gcc.dg/special/weak-2a.c5
-rw-r--r--gcc/testsuite/gcc.dg/special/weak-2b.c3
-rw-r--r--gcc/testsuite/gcc.dg/special/wkali-1.c15
-rw-r--r--gcc/testsuite/gcc.dg/special/wkali-2.c11
-rw-r--r--gcc/testsuite/gcc.dg/special/wkali-2a.c7
-rw-r--r--gcc/testsuite/gcc.dg/special/wkali-2b.c7
12 files changed, 327 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/special/alias-1.c b/gcc/testsuite/gcc.dg/special/alias-1.c
new file mode 100644
index 00000000000..347e1745630
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/special/alias-1.c
@@ -0,0 +1,15 @@
+/* { dg-do link } */
+
+extern int foo(void) __attribute__((alias("bar")));
+
+int bar(void) {
+ return 1;
+}
+
+int main(void) {
+
+ if (foo())
+ exit(0);
+ else
+ abort();
+}
diff --git a/gcc/testsuite/gcc.dg/special/ecos.exp b/gcc/testsuite/gcc.dg/special/ecos.exp
new file mode 100644
index 00000000000..dc54df6eea1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/special/ecos.exp
@@ -0,0 +1,214 @@
+# Copyright (C) 1999 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.
+
+# Please email any bugs, comments, and/or additions to this file to:
+# jlarmour@cygnus.co.uk
+
+# This file was written by Jonathan Larmour (jlarmour@cygnus.co.uk).
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+###################################
+# proc gcc_target_object_format { }
+###################################
+
+proc gcc_target_object_format { } {
+ global gcc_target_object_format_saved
+
+ if [info exists gcc_target_object_format_saved] {
+ verbose "gcc_target_object_format returning saved $gcc_target_object_format_saved" 2
+ return $gcc_target_object_format_saved
+ } else {
+
+ set objdump_name [find_binutils_prog objdump]
+ set open_file [open objfmtst.c w]
+ puts $open_file "void foo(void) { }"
+ close $open_file
+
+ gcc_target_compile objfmtst.c objfmtst.o object ""
+
+ set output [exec $objdump_name --file-headers objfmtst.o ]
+
+ file delete objfmtst.o
+
+ if ![ regexp "file format (.*)arch" $output dummy objformat ] {
+ verbose "Could not parse objdump output" 2
+ set gcc_target_object_format_saved unknown
+ } else {
+ switch -regexp $objformat {
+ elf {
+ verbose "gcc_target_object_format returning elf" 2
+ set gcc_target_object_format_saved elf
+ }
+ ecoff {
+ verbose "gcc_target_object_format returning ecoff" 2
+ set gcc_target_object_format_saved ecoff
+ }
+ coff {
+ verbose "gcc_target_object_format returning coff" 2
+ set gcc_target_object_format_saved coff
+ }
+ a\.out {
+ verbose "gcc_target_object_format returning a.out" 2
+ set gcc_target_object_format_saved a.out
+ }
+ default {
+ verbose "gcc_target_object_format returning unknown" 2
+ set gcc_target_object_format_saved unknown
+ }
+ }
+ }
+ return $gcc_target_object_format_saved
+ }
+}
+
+###############################
+# proc check_weak_available { }
+###############################
+
+# weak symbols are only supported in some configs/object formats
+# this proc returns 1 if they're support, 0 if they're not, or -1 if unsure
+
+proc check_weak_available { } {
+ global target_cpu
+
+ # All mips targets should support it
+
+ if { [ string first "mips" $target_cpu ] >= 0 } {
+ return 1
+ }
+
+ # ELF and ECOFF support it. a.out does with gas/gld but may also with
+ # other linkers, so we should try it
+
+ set objformat [gcc_target_object_format]
+
+ switch $objformat {
+ elf { return 1 }
+ ecoff { return 1 }
+ a.out { return 1 }
+ unknown { return -1 }
+ default { return 0 }
+ }
+}
+
+##########
+# weak-1.c
+##########
+
+if { [ check_weak_available ] == 1 } {
+ dg-init
+
+ set lines [gcc_target_compile "$srcdir/$subdir/weak-1a.c" "weak-1a.o" object ""]
+ if ![string match "" $lines] then {
+ fail "weak-1a.o"
+ } else {
+ dg-runtest "$srcdir/$subdir/weak-1.c" "weak-1a.o" ""
+ file delete weak-1a.o
+ }
+ dg-finish
+} elseif { [ check_weak_available ] == 0 } {
+ unsupported "weak-1.c"
+} else {
+ unresolved "weak-1.c"
+}
+
+##########
+# weak-2.c
+##########
+
+if { [ check_weak_available ] == 1 } {
+ dg-init
+
+ set lines [gcc_target_compile "$srcdir/$subdir/weak-2a.c" "weak-2a.o" object ""]
+ if ![string match "" $lines] then {
+ fail "weak-2a.o"
+ } else {
+ set lines [gcc_target_compile "$srcdir/$subdir/weak-2b.c" "weak-2b.o" object ""]
+ if ![string match "" $lines] then {
+ fail "weak-2b.o"
+ } else {
+ dg-runtest "$srcdir/$subdir/weak-2.c" "weak-2a.o weak-2b.o" ""
+ file delete weak-2a.o weak-2b.o
+ }
+ }
+ dg-finish
+} elseif { [ check_weak_available ] == 0 } {
+ unsupported "weak-2.c"
+} else {
+ unresolved "weak-2.c"
+}
+
+###########
+# alias-1.c
+###########
+
+dg-init
+dg-runtest "$srcdir/$subdir/alias-1.c" "" ""
+dg-finish
+
+###########
+# wkali-1.c
+###########
+
+dg-init
+dg-runtest "$srcdir/$subdir/wkali-1.c" "" ""
+dg-finish
+
+###########
+# wkali-2.c
+###########
+
+if { [ check_weak_available ] == 1 } {
+ dg-init
+ set lines [gcc_target_compile "$srcdir/$subdir/wkali-2a.c" "wkali-2a.o" object ""]
+ if ![string match "" $lines] then {
+ fail "wkali-2a.o"
+ } else {
+ set lines [gcc_target_compile "$srcdir/$subdir/wkali-2b.c" "wkali-2b.o" object ""]
+ if ![string match "" $lines] then {
+ fail "wkali-2b.o"
+ } else {
+ dg-runtest "$srcdir/$subdir/wkali-2.c" "wkali-2a.o wkali-2b.o" ""
+ file delete wkali-2a.o wkali-2b.o
+ }
+ }
+ dg-finish
+} elseif { [ check_weak_available ] == 0 } {
+ unsupported "wkali-2.c"
+} else {
+ unresolved "wkali-2.c"
+}
+
+###########
+# gcsec-1.c
+###########
+
+set ld_output [ exec [ find_ld ] --help ]
+
+if { [ string first "--gc-sections" $ld_output ] >= 0 } {
+
+ dg-init
+ dg-runtest "$srcdir/$subdir/gcsec-1.c" "-ffunction-sections -fdata-sections -Wl,--gc-sections" ""
+ dg-finish
+} else {
+ unsupported "gcsec-1.c"
+}
+
+### EOF ecos.exp
diff --git a/gcc/testsuite/gcc.dg/special/gcsec-1.c b/gcc/testsuite/gcc.dg/special/gcsec-1.c
new file mode 100644
index 00000000000..fa3f884fcbf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/special/gcsec-1.c
@@ -0,0 +1,21 @@
+/* { dg-do run } */
+
+static int unusedint=5;
+
+static int usedint=1;
+
+int unused(void) {
+ return 1;
+}
+
+int foo(void) {
+ return usedint;
+}
+
+int main(void) {
+
+ if (foo())
+ exit(0);
+ else
+ abort();
+}
diff --git a/gcc/testsuite/gcc.dg/special/weak-1.c b/gcc/testsuite/gcc.dg/special/weak-1.c
new file mode 100644
index 00000000000..ccf2b087a94
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/special/weak-1.c
@@ -0,0 +1,15 @@
+/* { dg-do run } */
+
+int foo(void) __attribute__((weak));
+
+int foo(void) {
+ return 0;
+}
+
+int main(void) {
+
+ if (foo())
+ exit(0);
+ else
+ abort();
+}
diff --git a/gcc/testsuite/gcc.dg/special/weak-1a.c b/gcc/testsuite/gcc.dg/special/weak-1a.c
new file mode 100644
index 00000000000..2a7dbba3d89
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/special/weak-1a.c
@@ -0,0 +1,3 @@
+int foo(void) {
+ return 1;
+}
diff --git a/gcc/testsuite/gcc.dg/special/weak-2.c b/gcc/testsuite/gcc.dg/special/weak-2.c
new file mode 100644
index 00000000000..74259cf9bca
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/special/weak-2.c
@@ -0,0 +1,11 @@
+/* { dg-do run } */
+
+extern int foo(void);
+
+int main(void) {
+
+ if (foo())
+ exit(0);
+ else
+ abort();
+}
diff --git a/gcc/testsuite/gcc.dg/special/weak-2a.c b/gcc/testsuite/gcc.dg/special/weak-2a.c
new file mode 100644
index 00000000000..52d3e08a2d7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/special/weak-2a.c
@@ -0,0 +1,5 @@
+int foo(void) __attribute__((weak));
+
+int foo(void) {
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/special/weak-2b.c b/gcc/testsuite/gcc.dg/special/weak-2b.c
new file mode 100644
index 00000000000..2a7dbba3d89
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/special/weak-2b.c
@@ -0,0 +1,3 @@
+int foo(void) {
+ return 1;
+}
diff --git a/gcc/testsuite/gcc.dg/special/wkali-1.c b/gcc/testsuite/gcc.dg/special/wkali-1.c
new file mode 100644
index 00000000000..d33c8d1d601
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/special/wkali-1.c
@@ -0,0 +1,15 @@
+/* { dg-do link } */
+
+extern int foo(void) __attribute__((weak, alias("bar")));
+
+int bar(void) {
+ return 1;
+}
+
+int main(void) {
+
+ if (foo())
+ exit(0);
+ else
+ abort();
+}
diff --git a/gcc/testsuite/gcc.dg/special/wkali-2.c b/gcc/testsuite/gcc.dg/special/wkali-2.c
new file mode 100644
index 00000000000..74259cf9bca
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/special/wkali-2.c
@@ -0,0 +1,11 @@
+/* { dg-do run } */
+
+extern int foo(void);
+
+int main(void) {
+
+ if (foo())
+ exit(0);
+ else
+ abort();
+}
diff --git a/gcc/testsuite/gcc.dg/special/wkali-2a.c b/gcc/testsuite/gcc.dg/special/wkali-2a.c
new file mode 100644
index 00000000000..79dde145540
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/special/wkali-2a.c
@@ -0,0 +1,7 @@
+/* { dg-do run } */
+
+extern int foo(void) __attribute__((weak, alias("bar_a")));
+
+int bar_a(void) {
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/special/wkali-2b.c b/gcc/testsuite/gcc.dg/special/wkali-2b.c
new file mode 100644
index 00000000000..84f389e846d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/special/wkali-2b.c
@@ -0,0 +1,7 @@
+/* { dg-do run } */
+
+extern int foo(void) __attribute__((alias("bar_b")));
+
+int bar_b(void) {
+ return 1;
+}