aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base
diff options
context:
space:
mode:
authorYao Qi <yao@codesourcery.com>2011-05-30 02:51:58 +0000
committerYao Qi <yao@codesourcery.com>2011-05-30 02:51:58 +0000
commit0578b8d157cfe24f77424f9920e1c57497fd3635 (patch)
tree6ca1e20311807c0d6a44886fddc2d5e90a526e2f /gdb/testsuite/gdb.base
parentff4d2c6018b2de77d43ed3badb19e87de54d1a04 (diff)
downloadgdb-0578b8d157cfe24f77424f9920e1c57497fd3635.zip
gdb-0578b8d157cfe24f77424f9920e1c57497fd3635.tar.gz
gdb-0578b8d157cfe24f77424f9920e1c57497fd3635.tar.bz2
2011-05-30 Yao Qi <yao@codesourcery.com>
* gdb.base/callfuncs.c (t_structs_fc): New. (t_structs_dc, t_structs_ldc): New. (t_double_many_args): (DEF_FUNC_MANY_ARGS_1, DEF_FUNC_MANY_ARGS_2): Define. (DEF_FUNC_MANY_ARGS_3, DEF_FUNC_VALUES_1): Define. (DEF_FUNC_VALUES_2, DEF_FUNC_VALUES_3): Define. * gdb.base/callfuncs.exp: Call new functions.
Diffstat (limited to 'gdb/testsuite/gdb.base')
-rw-r--r--gdb/testsuite/gdb.base/callfuncs.c147
-rw-r--r--gdb/testsuite/gdb.base/callfuncs.exp50
2 files changed, 195 insertions, 2 deletions
diff --git a/gdb/testsuite/gdb.base/callfuncs.c b/gdb/testsuite/gdb.base/callfuncs.c
index 406d22a..f764b82 100644
--- a/gdb/testsuite/gdb.base/callfuncs.c
+++ b/gdb/testsuite/gdb.base/callfuncs.c
@@ -73,6 +73,30 @@ double double_val13 = 10.25;
double double_val14 = 11.25;
double double_val15 = 12.25;
+#ifdef TEST_COMPLEX
+extern float crealf (float _Complex);
+extern float cimagf (float _Complex);
+extern double creal (double _Complex);
+extern double cimag (double _Complex);
+extern long double creall (long double _Complex);
+extern long double cimagl (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 /* TEST_COMPLEX */
+
#define DELTA (0.001)
char *string_val1 = (char *)"string 1";
@@ -89,8 +113,15 @@ struct struct1 {
float f;
double d;
char a[4];
+#ifdef TEST_COMPLEX
+ float _Complex fc;
+ double _Complex dc;
+ long double _Complex ldc;
+} struct_val1 ={ 'x', 87, 76, 51, 2.1234, 9.876, "foo", 3.0F + 3.0Fi,
+ 4.0L + 4.0Li, 5.0L + 5.0Li};
+#else
} struct_val1 = { 'x', 87, 76, 51, 2.1234, 9.876, "foo" };
-
+#endif /* TEST_COMPLEX */
/* Some functions that can be passed as arguments to other test
functions, or called directly. */
#ifdef PROTOTYPES
@@ -183,6 +214,11 @@ char *t_structs_a (struct struct1 tstruct)
strcpy (buf, tstruct.a);
return buf;
}
+#ifdef TEST_COMPLEX
+float _Complex t_structs_fc (struct struct1 tstruct) { return tstruct.fc;}
+double _Complex t_structs_dc (struct struct1 tstruct) { return tstruct.dc;}
+long double _Complex t_structs_fc (struct struct1 tstruct) { return tstruct.ldc;}
+#endif
#else
char t_structs_c (tstruct) struct struct1 tstruct; { return (tstruct.c); }
short t_structs_s (tstruct) struct struct1 tstruct; { return (tstruct.s); }
@@ -196,6 +232,11 @@ char *t_structs_a (tstruct) struct struct1 tstruct;
strcpy (buf, tstruct.a);
return buf;
}
+#ifdef TEST_COMPLEX
+float _Complex t_structs_fc (tstruct) struct struct1 tstruct; { return tstruct.fc;}
+double _Complex t_structs_dc (tstruct) struct struct1 tstruct; { return tstruct.dc;}
+long double _Complex t_structs_ldc (tstruct) struct struct1 tstruct; { return tstruct.ldc;}
+#endif
#endif
/* Test that calling functions works if there are a lot of arguments. */
@@ -400,6 +441,110 @@ t_double_many_args (double f1, double f2, double f3, double f4, double f5,
&& (sum_args - sum_values) > -DELTA);
}
+/* Various functions for _Complex types. */
+
+#ifdef TEST_COMPLEX
+
+#define COMPARE_WITHIN_RANGE(ARG1, ARG2, DEL, FUNC) \
+ ((FUNC(ARG1) - FUNC(ARG2)) < DEL) && ((FUNC(ARG1) - FUNC(ARG2) > -DEL))
+
+#define DEF_FUNC_MANY_ARGS_1(TYPE, NAME) \
+t_##NAME##_complex_many_args (f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, \
+ f12, f13, f14, f15, f16) \
+ TYPE _Complex f1, TYPE _Complex f2, TYPE _Complex f3, \
+ TYPE _Complex f4, TYPE _Complex f5, TYPE _Complex f6, \
+ TYPE _Complex f7, TYPE _Complex f8, TYPE _Complex f9, \
+ TYPE _Complex f10, TYPE _Complex f11, TYPE _Complex f12, \
+ TYPE _Complex f13, TYPE _Complex f14, TYPE _Complex f15, \
+ TYPE _Complex f16;
+
+#define DEF_FUNC_MANY_ARGS_2(TYPE, NAME) \
+t_##NAME##_complex_many_args (TYPE _Complex f1, TYPE _Complex f2, \
+ TYPE _Complex f3, TYPE _Complex f4, \
+ TYPE _Complex f5, TYPE _Complex f6, \
+ TYPE _Complex f7, TYPE _Complex f8, \
+ TYPE _Complex f9, TYPE _Complex f10, \
+ TYPE _Complex f11, TYPE _Complex f12, \
+ TYPE _Complex f13, TYPE _Complex f14, \
+ TYPE _Complex f15, TYPE _Complex f16)
+
+#define DEF_FUNC_MANY_ARGS_3(TYPE, CREAL, CIMAG) \
+{ \
+ TYPE _Complex expected = fc1 + fc2 + fc3 + fc4 + fc1 + fc2 + fc3 + fc4 \
+ + fc1 + fc2 + fc3 + fc4 + fc1 + fc2 + fc3 + fc4; \
+ TYPE _Complex actual = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 \
+ + f11 + f12 + f13 + f14 + f15 + f16; \
+ return (COMPARE_WITHIN_RANGE(expected, actual, DELTA, creal) \
+ && COMPARE_WITHIN_RANGE(expected, actual, DELTA, creal) \
+ && COMPARE_WITHIN_RANGE(expected, actual, DELTA, cimag) \
+ && COMPARE_WITHIN_RANGE(expected, actual, DELTA, cimag)); \
+}
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_MANY_ARGS_1(float, float)
+#else
+DEF_FUNC_MANY_ARGS_2(float, float)
+#endif
+DEF_FUNC_MANY_ARGS_3(float, crealf, cimagf)
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_MANY_ARGS_1(double, double)
+#else
+DEF_FUNC_MANY_ARGS_2(double, double)
+#endif
+DEF_FUNC_MANY_ARGS_3(double, creal, cimag)
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_MANY_ARGS_1(long double, long_double)
+#else
+DEF_FUNC_MANY_ARGS_2(long double, long_double)
+#endif
+DEF_FUNC_MANY_ARGS_3(long double, creall, cimagl)
+
+#define DEF_FUNC_VALUES_1(TYPE, NAME) \
+ t_##NAME##_complex_values (f1, f2) TYPE _Complex f1, TYPE _Complex f2;
+
+#define DEF_FUNC_VALUES_2(TYPE, NAME) \
+ t_##NAME##_complex_values (TYPE _Complex f1, TYPE _Complex f2)
+
+#define DEF_FUNC_VALUES_3(FORMAL_PARM, TYPE, CREAL, CIMAG) \
+{ \
+ return (COMPARE_WITHIN_RANGE(f1, FORMAL_PARM##1, DELTA, CREAL) \
+ && COMPARE_WITHIN_RANGE(f2, FORMAL_PARM##2, DELTA, CREAL) \
+ && COMPARE_WITHIN_RANGE(f1, FORMAL_PARM##1, DELTA, CIMAG) \
+ && COMPARE_WITHIN_RANGE(f2, FORMAL_PARM##2, DELTA, CIMAG)); \
+}
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_VALUES_1(float, float)
+#else
+DEF_FUNC_VALUES_2(float, float)
+#endif
+DEF_FUNC_VALUES_3(fc, float, crealf, cimagf)
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_VALUES_1(double, double)
+#else
+DEF_FUNC_VALUES_2(double, double)
+#endif
+DEF_FUNC_VALUES_3(fc, double, creal, cimag)
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_VALUES_1(long double, long_double)
+#else
+DEF_FUNC_VALUES_2(long double, long_double)
+#endif
+DEF_FUNC_VALUES_3(fc, long double, creall, cimagl)
+
+#endif /* TEST_COMPLEX */
+
+
#ifdef PROTOTYPES
int t_string_values (char *string_arg1, char *string_arg2)
#else
diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp
index 5294a2d..78e6dd2 100644
--- a/gdb/testsuite/gdb.base/callfuncs.exp
+++ b/gdb/testsuite/gdb.base/callfuncs.exp
@@ -25,7 +25,12 @@ set testfile "callfuncs"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+set compile_flags {debug}
+if [support_complex_tests] {
+ lappend compile_flags "additional_flags=-DTEST_COMPLEX"
+}
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $compile_flags] != "" } {
untested callfuncs.exp
return -1
}
@@ -144,6 +149,29 @@ proc do_function_calls {} {
gdb_test "p t_int_double(99, 99.0)" " = 1"
}
+ if [support_complex_tests] {
+ setup_kfail_for_target gdb/12798 "x86_64-*-*"
+ gdb_test "p t_float_complex_values(fc1, fc2)" " = 1"
+ gdb_test "p t_float_complex_values(fc3, fc4)" " = 0"
+
+ setup_kfail_for_target gdb/12800 "x86_64-*-*"
+ gdb_test "p t_float_complex_many_args(fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4)" " = 1"
+ gdb_test "p t_float_complex_many_args(fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1)" " = 0"
+
+ setup_kfail_for_target gdb/12798 "x86_64-*-*"
+ gdb_test "p t_double_complex_values(dc1, dc2)" " = 1"
+ gdb_test "p t_double_complex_values(dc3, dc4)" " = 0"
+
+ setup_kfail_for_target gdb/12800 "x86_64-*-*"
+ gdb_test "p t_double_complex_many_args(dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4)" " = 1"
+ gdb_test "p t_double_complex_many_args(dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1)" " = 0"
+
+ gdb_test "p t_long_double_complex_values(ldc1, ldc2)" " = 1"
+ gdb_test "p t_long_double_complex_values(ldc3, ldc4)" " = 0"
+ gdb_test "p t_long_double_complex_many_args(ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4)" " = 1"
+ gdb_test "p t_long_double_complex_many_args(ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1,ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1)" " = 0"
+ }
+
gdb_test "p t_string_values(string_val2,string_val1)" " = 0"
gdb_test "p t_string_values(string_val1,string_val2)" " = 1"
gdb_test "p t_string_values(\"string 1\",\"string 2\")" " = 1"
@@ -217,6 +245,26 @@ proc do_function_calls {} {
"call inferior func with struct - returns double"
}
+ if [support_complex_tests] {
+
+ setup_kfail_for_target gdb/12796 "x86_64-*-*"
+ setup_kfail_for_target gdb/12797 "arm*-*-*"
+ gdb_test "p t_structs_fc(struct_val1)" ".*= 3 \\+ 3 \\* I" \
+ "call inferior func with struct - returns float _Complex"
+
+ setup_kfail_for_target gdb/12783 "i?86-*-*"
+ setup_kfail_for_target gdb/12796 "x86_64-*-*"
+ setup_kfail_for_target gdb/12797 "arm*-*-*"
+ gdb_test "p t_structs_dc(struct_val1)" ".*= 4 \\+ 4 \\* I" \
+ "call inferior func with struct - returns double _Complex"
+
+ setup_kfail_for_target gdb/12783 "i?86-*-*"
+ setup_kfail_for_target gdb/12796 "x86_64-*-*"
+ setup_kfail_for_target gdb/12797 "arm*-*-*"
+ gdb_test "p t_structs_ldc(struct_val1)" "= 5 \\+ 5 \\* I" \
+ "call inferior func with struct - returns long double _Complex"
+ }
+
gdb_test "p t_structs_a(struct_val1)" "= (.unsigned char .. )?\"foo\"" \
"call inferior func with struct - returns char *"
}