aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorYao Qi <yao@codesourcery.com>2011-05-30 02:27:51 +0000
committerYao Qi <yao@codesourcery.com>2011-05-30 02:27:51 +0000
commit6680506ef023d4cf1046561ad3dbcf48d3d357b0 (patch)
tree9beb465f97a52d7b95af514f433a97e90d00b417 /gdb
parente43ec454f97ac55350df1086ddfa76bd08d7aead (diff)
downloadgdb-6680506ef023d4cf1046561ad3dbcf48d3d357b0.zip
gdb-6680506ef023d4cf1046561ad3dbcf48d3d357b0.tar.gz
gdb-6680506ef023d4cf1046561ad3dbcf48d3d357b0.tar.bz2
2011-05-30 Yao Qi <yao@codesourcery.com>
* gdb.base/varargs.c (find_max_float_real): New. (find_max_double_real, find_max_long_double_real): New. * gdb.base/varargs.exp: Call these new added functions. * lib/gdb.exp (setup_kfail_for_target): New.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/testsuite/ChangeLog7
-rw-r--r--gdb/testsuite/gdb.base/varargs.c80
-rw-r--r--gdb/testsuite/gdb.base/varargs.exp26
-rw-r--r--gdb/testsuite/lib/gdb.exp8
4 files changed, 121 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 4dd6a8b..66fea15 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,12 @@
2011-05-30 Yao Qi <yao@codesourcery.com>
+ * gdb.base/varargs.c (find_max_float_real): New.
+ (find_max_double_real, find_max_long_double_real): New.
+ * gdb.base/varargs.exp: Call these new added functions.
+ * lib/gdb.exp (setup_kfail_for_target): New.
+
+2011-05-30 Yao Qi <yao@codesourcery.com>
+
* gdb.base/funcargs.c (callca, callcb, callcc): New.
(callcd, callce, callcf, callc1a, callc1b): New.
(callc2a, callc2b): New.
diff --git a/gdb/testsuite/gdb.base/varargs.c b/gdb/testsuite/gdb.base/varargs.c
index 1122767..1ad2ffc 100644
--- a/gdb/testsuite/gdb.base/varargs.c
+++ b/gdb/testsuite/gdb.base/varargs.c
@@ -23,6 +23,28 @@ float fa,fb,fc,fd;
double da,db,dc,dd;
double dmax_val;
+#ifdef TEST_COMPLEX
+extern float crealf (float _Complex);
+extern double creal (double _Complex);
+extern long double creall (long double _Complex);
+
+float _Complex fc1 = 1.0F + 1.0iF;
+float _Complex fc2 = 2.0F + 2.0iF;
+float _Complex fc3 = 3.0F + 3.0iF;
+float _Complex fc4 = 4.0F + 4.0iF;
+
+double _Complex dc1 = 1.0 + 1.0i;
+double _Complex dc2 = 2.0 + 2.0i;
+double _Complex dc3 = 3.0 + 3.0i;
+double _Complex dc4 = 4.0 + 4.0i;
+
+long double _Complex ldc1 = 1.0L + 1.0Li;
+long double _Complex ldc2 = 2.0L + 2.0Li;
+long double _Complex ldc3 = 3.0L + 3.0Li;
+long double _Complex ldc4 = 4.0L + 4.0Li;
+
+#endif
+
int main() {
c = -1;
uc = 1;
@@ -109,3 +131,61 @@ double find_max_double(int num_vals, double first_val, ...) {
return max_val;
}
+
+#ifdef TEST_COMPLEX
+float _Complex
+find_max_float_real (int num_vals, ...)
+{
+ float _Complex max = 0.0F + 0.0iF;
+ float _Complex x;
+ va_list argp;
+ int i;
+
+ va_start(argp, num_vals);
+ for (i = 0; i < num_vals; i++)
+ {
+ x = va_arg (argp, float _Complex);
+ if (crealf (max) < crealf (x)) max = x;
+ }
+
+ return max;
+}
+
+double _Complex
+find_max_double_real (int num_vals, ...)
+{
+ double _Complex max = 0.0 + 0.0i;
+ double _Complex x;
+ va_list argp;
+ int i;
+
+ va_start(argp, num_vals);
+ for (i = 0; i < num_vals; i++)
+ {
+ x = va_arg (argp, double _Complex);
+ if (creal (max) < creal (x)) max = x;
+ }
+
+ return max;
+}
+
+long double _Complex
+find_max_long_double_real (int num_vals, ...)
+{
+ long double _Complex max = 0.0L + 0.0iL;
+ long double _Complex x;
+ va_list argp;
+ int i;
+
+ va_start(argp, num_vals);
+ for (i = 0; i < num_vals; i++)
+ {
+ x = va_arg (argp, long double _Complex);
+ if (creall (max) < creal (x)) max = x;
+ }
+
+ return max;
+}
+
+
+#endif /* TEST_COMPLEX */
diff --git a/gdb/testsuite/gdb.base/varargs.exp b/gdb/testsuite/gdb.base/varargs.exp
index 4627862..6ecfcbf 100644
--- a/gdb/testsuite/gdb.base/varargs.exp
+++ b/gdb/testsuite/gdb.base/varargs.exp
@@ -44,6 +44,9 @@ if [get_compiler_info ${binfile}] {
}
set additional_flags {debug}
+if [support_complex_tests] {
+ lappend additional_flags "additional_flags=-DTEST_COMPLEX"
+}
if {$hp_cc_compiler} {
lappend additional_flags "additional_flags=-Ae"
@@ -112,3 +115,26 @@ if {![target_info exists gdb,skip_float_tests]} {
"print find_max_double(5,1.0,17.0,2.0,3.0,4.0)"
}
+
+# Test _Complex type here if supported.
+if [support_complex_tests] {
+ global gdb_prompt
+
+ set test "print find_max_float_real(4, fc1, fc2, fc3, fc4)"
+ setup_kfail_for_target gdb/12790 "x86_64-*-*"
+ setup_kfail_for_target gdb/12791 "arm*-*-*"
+ gdb_test $test ".*= 4 \\+ 4 \\* I" $test
+
+ set test "print find_max_double_real(4, dc1, dc2, dc3, dc4)"
+ setup_kfail_for_target gdb/12776 "i?86-*-*"
+ setup_kfail_for_target gdb/12790 "x86_64-*-*"
+ setup_kfail_for_target gdb/12791 "arm*-*-*"
+ gdb_test $test ".*= 4 \\+ 4 \\* I" $test
+
+ set test "print find_max_long_double_real(4, ldc1, ldc2, ldc3, ldc4)"
+ setup_kfail_for_target gdb/12776 "i?86-*-*"
+ setup_kfail_for_target gdb/12790 "x86_64-*-*"
+ setup_kfail_for_target gdb/12791 "arm*-*-*"
+ gdb_test $test ".*= 4 \\+ 4 \\* I" $test
+
+}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 3f38453..0e07931 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2996,6 +2996,14 @@ proc setup_xfail_format { format } {
return $ret;
}
+# Like setup_kfail, but only call setup_kfail conditionally if
+# istarget[TARGET] returns true.
+proc setup_kfail_for_target { PR target } {
+ if { [istarget $target] } {
+ setup_kfail $PR $target
+ }
+}
+
proc gdb_step_for_stub { } {
global gdb_prompt;