double d = 5.0;
double *dp = &d;
+#ifdef TEST_COMPLEX
+float _Complex fc = 1.0F + 2.0iF;
+double _Complex dc = 3.0 + 4.0i;
+long double _Complex ldc = 5.0L + 6.0iL;
+#endif /* TEST_COMPLEX */
+
struct stag {
int s1;
int s2;
}
+
+#ifdef TEST_COMPLEX
+
+/* Test various _Complex type args. */
+
+#ifdef PROTOTYPES
+void callca (float _Complex f1, float _Complex f2, float _Complex f3)
+#else
+callca (f1, f2, f3)
+float _Complex f1; float _Complex f2; float _Complex f3;
+#endif
+{
+
+}
+
+#ifdef PROTOTYPES
+void callcb (double _Complex d1, double _Complex d2, double _Complex d3)
+#else
+callcb (d1, d2, d3)
+double _Complex d1; double _Complex d2; double _Complex d3;
+#endif
+{
+
+}
+
+#ifdef PROTOTYPES
+void callcc (long double _Complex ld1, long double _Complex ld2, long double _Complex ld3)
+#else
+callcc (ld1, ld2, ld3)
+long double _Complex ld1; long double _Complex ld2; long double _Complex ld3;
+#endif
+{
+
+}
+
+#ifdef PROTOTYPES
+void callcd (float _Complex fc1, double _Complex dc1, long double _Complex ldc1)
+#else
+callcd (fc1, dc1, ldc1)
+float _Complex fc1; double _Complex dc1; long double _Complex ldc1;
+#endif
+{
+}
+
+#ifdef PROTOTYPES
+void callce (double _Complex dc1, long double _Complex ldc1, float _Complex fc1)
+#else
+callce (dc1, ldc1, fc1)
+double _Complex dc1; long double _Complex ldc1; float _Complex fc1;
+#endif
+{
+}
+
+#ifdef PROTOTYPES
+void callcf (long double _Complex ldc1, float _Complex fc1, double _Complex dc1)
+#else
+callcf (ldc1, fc1, dc1)
+long double _Complex ldc1; float _Complex fc1; double _Complex dc1;
+#endif
+{
+}
+
+
+/* Test passing _Complex type and integral. */
+#ifdef PROTOTYPES
+void callc1a (char c, short s, int i, unsigned int ui, long l,
+ float _Complex fc1, double _Complex dc1,
+ long double _Complex ldc1)
+#else
+callc1a (c, s, i, ui, l, fc1, dc1, ldc1)
+char c; short s; int i; unsigned int ui; long l; float _Complex fc1; double _Complex dc1; long double _Complex ldc1;
+#endif
+{}
+
+#ifdef PROTOTYPES
+void callc1b (long double _Complex ldc1, char c, short s, int i,
+ float _Complex fc1, unsigned int ui, long l, double _Complex dc1)
+#else
+callc1b (ldc1, c, s, i, fc1, ui, l, dc1)
+char c; short s; int i; unsigned int ui; long l; float _Complex fc1; double _Complex dc1; long double _Complex ldc1;
+#endif
+{}
+
+
+#ifdef PROTOTYPES
+void callc2a (char c, short s, int i, unsigned int ui, long l, float f,
+ double d, float _Complex fc1, double _Complex dc1,
+ long double _Complex ldc1)
+#else
+callc2a (c, s, i, ui, l, f, d, fc1, dc1, ldc1)
+ char c; short s; int i; unsigned int ui; long l; float f; double d;
+ float _Complex fc1; double _Complex dc1;
+ long double _Complex ldc1;
+#endif
+{}
+
+#ifdef PROTOTYPES
+void callc2b (float _Complex fc1, char c, short s, int i, unsigned int ui,
+ long double _Complex ldc1, long l, float f, double d,
+ double _Complex dc1)
+#else
+callc2b (fc1, c, s, i, ui, ldc1, l, f, d, dc1)
+ char c; short s; int i; unsigned int ui; long l; float f; double d;
+ float _Complex fc1; double _Complex dc1;
+ long double _Complex ldc1;
+#endif
+{}
+
+
+#endif /* TEST_COMPLEX */
+
/* Test passing structures and unions by reference. */
call2h (d, c, f, s, d, i, f, l);
call2i (c, f, c, c, d, c, c, c, f, s, c, d);
+#ifdef TEST_COMPLEX
+ /* Test calling with _Complex types. */
+ callca (fc, fc, fc);
+ callcb (dc, dc, dc);
+ callcc (ldc, ldc, ldc);
+ callcd (fc, dc, ldc);
+ callce (dc, ldc, fc);
+ callcf (ldc, fc, dc);
+
+
+ callc1a (c, s, i, ui, l, fc, dc, ldc);
+ callc1b (ldc, c, s, i, fc, ui, l, dc);
+
+ callc2a (c, s, i, ui, l, f, d, fc, dc, ldc);
+ callc2b (fc, c, s, i, ui, ldc, l, f, d, dc);
+#endif /* TEST_COMPLEX */
+
/* Test dereferencing pointers to various integral and floating types */
call3a (cp, sp, ip, lp);
set testfile "funcargs"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+
+set compile_flags {debug nowarnings quiet}
+if [support_complex_tests] {
+ lappend compile_flags "additional_flags=-DTEST_COMPLEX"
+}
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $compile_flags] != "" } {
untested funcargs.exp
return -1
}
gdb_stop_suppressing_tests;
}
+
+#
+# Locate actual args; _Complex types.
+#
+
+proc complex_args {} {
+ global gdb_prompt
+
+ delete_breakpoints
+
+ gdb_breakpoint callca
+ gdb_breakpoint callcb
+ gdb_breakpoint callcc
+ gdb_breakpoint callcd
+ gdb_breakpoint callce
+ gdb_breakpoint callcf
+
+ # Run; should stop at call1a and print actual arguments.
+ gdb_run_cmd
+ gdb_expect {
+ -re ".* callca \\(f1=1 \\+ 2 \\* I, f2=1 \\+ 2 \\* I, f3=1 \\+ 2 \\* I\\) .*$gdb_prompt $" { pass "run to call2a" }
+ timeout { fail "(timeout) run to callca" ; gdb_suppress_tests; }
+ }
+ gdb_test "cont" ".* callcb \\(d1=3 \\+ 4 \\* I, d2=3 \\+ 4 \\* I, d3=3 \\+ 4 \\* I\\) .*" "continue to callcb"
+ gdb_test "cont" ".* callcc \\(ld1=5 \\+ 6 \\* I, ld2=5 \\+ 6 \\* I, ld3=5 \\+ 6 \\* I\\) .*" "continue to callcb"
+ gdb_test "cont" ".* callcd \\(fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*" "continue to callcd"
+ gdb_test "cont" ".* callce \\(dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I, fc1=1 \\+ 2 \\* I\\) .*" "continue to callce"
+ gdb_test "cont" ".* callcf \\(ldc1=5 \\+ 6 \\* I, fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I\\) .*" "continue to callcf"
+}
+
+
+#
+# Locate actual args; _Complex types and integral.
+#
+proc complex_integral_args {} {
+ global gdb_prompt
+
+ delete_breakpoints
+
+ gdb_breakpoint callc1a
+ gdb_breakpoint callc1b
+
+ # Run; should stop at call1a and print actual arguments.
+ gdb_run_cmd
+ gdb_expect {
+ -re ".* callc1a \\(c=97 'a', s=1, i=2, ui=7, l=3, fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*$gdb_prompt $" { pass "run to callc1a" }
+ timeout { fail "(timeout) run to callc1a" ; gdb_suppress_tests; }
+ }
+ gdb_test "cont" ".* callc1b \\(ldc1=5 \\+ 6 \\* I\\, c=97 'a', s=1, i=2, fc1=1 \\+ 2 \\* I, ui=7, l=3, dc1=3 \\+ 4 \\* I\\) .*" "continue to callc1b"
+}
+
+#
+# Locate actual args; _Complex types and integral/float.
+#
+proc complex_float_integral_args {} {
+ global gdb_prompt
+
+ delete_breakpoints
+
+ gdb_breakpoint callc2a
+ gdb_breakpoint callc2b
+
+ # Run; should stop at call1a and print actual arguments.
+ gdb_run_cmd
+ gdb_expect {
+ -re ".* callc2a \\(c=97 'a', s=1, i=2, ui=7, l=3, f=4, d=5, fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*$gdb_prompt $" { pass "run to callc2a" }
+ timeout { fail "(timeout) run to callc1a" ; gdb_suppress_tests; }
+ }
+ gdb_test "cont" ".* callc2b \\(fc1=1 \\+ 2 \\* I, c=97 'a', s=1, i=2, ui=7, ldc1=5 \\+ 6 \\* I\\, l=3, f=4, d=5, dc1=3 \\+ 4 \\* I\\) .*" "continue to callc2b"
+}
+
#
# Locate actual args; dereference pointers to ints and floats.
#
if {![target_info exists gdb,skip_float_tests]} {
float_and_integral_args
}
+
+# Test _Complex type here if supported.
+if [support_complex_tests] {
+ funcargs_reload
+ complex_args
+
+ funcargs_reload
+ complex_integral_args
+
+ if {![target_info exists gdb,skip_float_tests]} {
+ funcargs_reload
+ complex_float_integral_args
+ }
+}
+
funcargs_reload
pointer_args
funcargs_reload
return 1
}
+# Return 1 if _Complex types are supported, otherwise, return 0.
+
+proc support_complex_tests {} {
+ global support_complex_tests_saved
+
+ # Use the cached value, if it exists.
+ if [info exists support_complex_tests_saved] {
+ verbose "returning saved $support_complex_tests_saved" 2
+ return $support_complex_tests_saved
+ }
+
+ # Set up, compile, and execute a test program containing _Complex types.
+ # Include the current process ID in the file names to prevent conflicts
+ # with invocations for multiple testsuites.
+ set src complex[pid].c
+ set exe complex[pid].x
+
+ set f [open $src "w"]
+ puts $f "int main() {"
+ puts $f "_Complex float cf;"
+ puts $f "_Complex double cd;"
+ puts $f "_Complex long double cld;"
+ puts $f " return 0; }"
+ close $f
+
+ verbose "compiling testfile $src" 2
+ set compile_flags {debug nowarnings quiet}
+ set lines [gdb_compile $src $exe executable $compile_flags]
+ file delete $src
+ file delete $exe
+
+ if ![string match "" $lines] then {
+ verbose "testfile compilation failed, returning 0" 2
+ set support_complex_tests_saved 0
+ } else {
+ set support_complex_tests_saved 1
+ }
+
+ return $support_complex_tests_saved
+}
+
# Return 1 if target is ILP32.
# This cannot be decided simply from looking at the target string,
# as it might depend on externally passed compiler options like -m64.