From: Uros Bizjak <ubizjak@gmail.com>
To: Joseph Myers <joseph@codesourcery.com>
Cc: GCC Development <gcc@gcc.gnu.org>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
Jakub Jelinek <jakub@redhat.com>,
Mike Stump <mikestump@comcast.net>,
Richard Henderson <rth@twiddle.net>
Subject: [PATCH, testsuite]: Test compat _Complex varargs passing
Date: Thu, 08 Sep 2016 09:09:00 -0000 [thread overview]
Message-ID: <CAFULd4awMpupam7zgaP6Y9zX9KPgfY5mHvZftf0W9JpVzA+2+w@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1539 bytes --]
On Mon, Sep 5, 2016 at 1:45 PM, Joseph Myers <joseph@codesourcery.com> wrote:
> On Sun, 4 Sep 2016, Uros Bizjak wrote:
>
>> It looks that different handling of _Complex char, _Complex short and
>> _Complex float is there on purpose. Is (was?) there a limitation in a
>> c language standard that prevents passing of these arguments as
>> varargs?
>
> Well, ISO C doesn't define complex integers at all. But it's deliberate
> (see DR#206) that _Complex float doesn't promote to _Complex double in
> variable arguments. And there is nothing in ISO C to stop _Complex float
> being passed in variable arguments.
>
> For all these types including the complex integer ones: given that the
> front end doesn't promote them, they should be usable in variable
> arguments.
Attached patch adds various _Complex variable arguments tests to
scalar-by-value-4 and scalar-return-4 tests. These tests previously
erroneously claimed that these argument types are unsupported as
variable arguments.
2016-09-08 Uros Bizjak <ubizjak@gmail.com>
* gcc.dg/compat/scalar-by-value-4_x.c: Also test passing of
variable arguments.
* gcc.dg/compat/scalar-by-value-4_y.c (testva##NAME): New.
* gcc.dg/compat/scalar-by-value-4_main.c: Update description comment.
* gcc.dg/compat/scalar-return-4_x.c: Also test returning of
variable argument.
* gcc.dg/compat/scalar-return-4_y.c (testva##NAME): New.
* gcc.dg/compat/scalar-return-4_main.c: Update description comment.
Tested on x86_64-linux-gnu {,-m32}.
OK for mainline?
Uros.
[-- Attachment #2: t.diff.txt --]
[-- Type: text/plain, Size: 10459 bytes --]
diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_main.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_main.c
index 8164b44..bd024c0 100644
--- a/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_main.c
+++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_main.c
@@ -1,5 +1,5 @@
/* Test passing scalars by value. This test includes _Complex types
- whose real and imaginary parts cannot be used in variable-length
+ whose real and imaginary parts can be used in variable-length
argument lists. */
extern void scalar_by_value_4_x (void);
diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_x.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_x.c
index a4e73c9..a36a060 100644
--- a/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_x.c
+++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_x.c
@@ -13,6 +13,7 @@ test##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \
TYPE x05, TYPE x06, TYPE x07, TYPE x08, \
TYPE x09, TYPE x10, TYPE x11, TYPE x12, \
TYPE x13, TYPE x14, TYPE x15, TYPE x16); \
+extern void testva##NAME (int n, ...); \
\
void \
check##NAME (TYPE x, TYPE v) \
@@ -62,6 +63,81 @@ testit##NAME (void) \
g13##NAME, g14##NAME, g15##NAME, g16##NAME); \
DEBUG_NL; \
DEBUG_FPUTS (#NAME); \
+ DEBUG_FPUTS (" testva:"); \
+ DEBUG_NL; \
+ testva##NAME (1, \
+ g01##NAME); \
+ DEBUG_NL; \
+ testva##NAME (2, \
+ g01##NAME, g02##NAME); \
+ DEBUG_NL; \
+ testva##NAME (3, \
+ g01##NAME, g02##NAME, g03##NAME); \
+ DEBUG_NL; \
+ testva##NAME (4, \
+ g01##NAME, g02##NAME, g03##NAME, g04##NAME); \
+ DEBUG_NL; \
+ testva##NAME (5, \
+ g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
+ g05##NAME); \
+ DEBUG_NL; \
+ testva##NAME (6, \
+ g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
+ g05##NAME, g06##NAME); \
+ DEBUG_NL; \
+ testva##NAME (7, \
+ g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
+ g05##NAME, g06##NAME, g07##NAME); \
+ DEBUG_NL; \
+ testva##NAME (8, \
+ g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
+ g05##NAME, g06##NAME, g07##NAME, g08##NAME); \
+ DEBUG_NL; \
+ testva##NAME (9, \
+ g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
+ g05##NAME, g06##NAME, g07##NAME, g08##NAME, \
+ g09##NAME); \
+ DEBUG_NL; \
+ testva##NAME (10, \
+ g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
+ g05##NAME, g06##NAME, g07##NAME, g08##NAME, \
+ g09##NAME, g10##NAME); \
+ DEBUG_NL; \
+ testva##NAME (11, \
+ g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
+ g05##NAME, g06##NAME, g07##NAME, g08##NAME, \
+ g09##NAME, g10##NAME, g11##NAME); \
+ DEBUG_NL; \
+ testva##NAME (12, \
+ g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
+ g05##NAME, g06##NAME, g07##NAME, g08##NAME, \
+ g09##NAME, g10##NAME, g11##NAME, g12##NAME); \
+ DEBUG_NL; \
+ testva##NAME (13, \
+ g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
+ g05##NAME, g06##NAME, g07##NAME, g08##NAME, \
+ g09##NAME, g10##NAME, g11##NAME, g12##NAME, \
+ g13##NAME); \
+ DEBUG_NL; \
+ testva##NAME (14, \
+ g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
+ g05##NAME, g06##NAME, g07##NAME, g08##NAME, \
+ g09##NAME, g10##NAME, g11##NAME, g12##NAME, \
+ g13##NAME, g14##NAME); \
+ DEBUG_NL; \
+ testva##NAME (15, \
+ g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
+ g05##NAME, g06##NAME, g07##NAME, g08##NAME, \
+ g09##NAME, g10##NAME, g11##NAME, g12##NAME, \
+ g13##NAME, g14##NAME, g15##NAME); \
+ DEBUG_NL; \
+ testva##NAME (16, \
+ g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
+ g05##NAME, g06##NAME, g07##NAME, g08##NAME, \
+ g09##NAME, g10##NAME, g11##NAME, g12##NAME, \
+ g13##NAME, g14##NAME, g15##NAME, g16##NAME); \
+ DEBUG_NL; \
+ DEBUG_FPUTS (#NAME); \
DEBUG_FPUTS (" test2: "); \
test2_##NAME (g01##NAME, g03##NAME, g05##NAME, g07##NAME, \
g09##NAME, g11##NAME, g13##NAME, g15##NAME); \
diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_y.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_y.c
index e0fa705..38b17d50 100644
--- a/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_y.c
+++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_y.c
@@ -65,6 +65,23 @@ test##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \
check##NAME (x14, 14); \
check##NAME (x15, 15); \
check##NAME (x16, 16); \
+} \
+ \
+void \
+testva##NAME (int n, ...) \
+{ \
+ int i; \
+ va_list ap; \
+ if (test_va) \
+ { \
+ va_start (ap, n); \
+ for (i = 0; i < n; i++) \
+ { \
+ TYPE t = va_arg (ap, TYPE); \
+ check##NAME (t, i+1); \
+ } \
+ va_end (ap); \
+ } \
}
#ifndef SKIP_COMPLEX
diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-4_main.c b/gcc/testsuite/gcc.dg/compat/scalar-return-4_main.c
index 2bcfa04..866121e 100644
--- a/gcc/testsuite/gcc.dg/compat/scalar-return-4_main.c
+++ b/gcc/testsuite/gcc.dg/compat/scalar-return-4_main.c
@@ -1,5 +1,5 @@
/* Test function return values. This test includes _Complex types
- whose real and imaginary parts cannot be used in variable-length
+ whose real and imaginary parts can be used in variable-length
argument lists. */
extern void scalar_return_4_x (void);
diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-4_x.c b/gcc/testsuite/gcc.dg/compat/scalar-return-4_x.c
index 50305be..11f4688 100644
--- a/gcc/testsuite/gcc.dg/compat/scalar-return-4_x.c
+++ b/gcc/testsuite/gcc.dg/compat/scalar-return-4_x.c
@@ -1,12 +1,22 @@
#include "compat-common.h"
+#ifdef SKIP_VA
+const int test_va = 0;
+#else
+const int test_va = 1;
+#endif
+
#define T(NAME, TYPE, INITVAL) \
-TYPE g01##NAME; \
+TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \
+TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \
+TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \
+TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \
\
extern void init##NAME (TYPE *p, TYPE v); \
extern void checkg##NAME (void); \
extern TYPE test0##NAME (void); \
extern TYPE test1##NAME (TYPE); \
+extern TYPE testva##NAME (int n, ...); \
\
void \
check##NAME (TYPE x, TYPE v) \
@@ -22,6 +32,21 @@ testit##NAME (void) \
DEBUG_FPUTS (#NAME); \
DEBUG_FPUTS (" init: "); \
init##NAME (&g01##NAME, 1); \
+ init##NAME (&g02##NAME, 2); \
+ init##NAME (&g03##NAME, 3); \
+ init##NAME (&g04##NAME, 4); \
+ init##NAME (&g05##NAME, 5); \
+ init##NAME (&g06##NAME, 6); \
+ init##NAME (&g07##NAME, 7); \
+ init##NAME (&g08##NAME, 8); \
+ init##NAME (&g09##NAME, 9); \
+ init##NAME (&g10##NAME, 10); \
+ init##NAME (&g11##NAME, 11); \
+ init##NAME (&g12##NAME, 12); \
+ init##NAME (&g13##NAME, 13); \
+ init##NAME (&g14##NAME, 14); \
+ init##NAME (&g15##NAME, 15); \
+ init##NAME (&g16##NAME, 16); \
checkg##NAME (); \
DEBUG_NL; \
DEBUG_FPUTS (#NAME); \
@@ -33,13 +58,35 @@ testit##NAME (void) \
DEBUG_FPUTS (" test1: "); \
rslt = test1##NAME (g01##NAME); \
check##NAME (rslt, g01##NAME); \
+ if (test_va) \
+ { \
+ DEBUG_NL; \
+ DEBUG_FPUTS (#NAME); \
+ DEBUG_FPUTS (" testva: "); \
+ rslt = testva##NAME (1, g01##NAME); \
+ check##NAME (rslt, g01##NAME); \
+ rslt = testva##NAME (5, g01##NAME, g02##NAME, g03##NAME, \
+ g04##NAME, g05##NAME); \
+ check##NAME (rslt, g05##NAME); \
+ rslt = testva##NAME (9, g01##NAME, g02##NAME, g03##NAME, \
+ g04##NAME, g05##NAME, g06##NAME, \
+ g07##NAME, g08##NAME, g09##NAME); \
+ check##NAME (rslt, g09##NAME); \
+ rslt = testva##NAME (16, g01##NAME, g02##NAME, g03##NAME, \
+ g04##NAME, g05##NAME, g06##NAME, \
+ g07##NAME, g08##NAME, g09##NAME, \
+ g10##NAME, g11##NAME, g12##NAME, \
+ g13##NAME, g14##NAME, g15##NAME, \
+ g16##NAME); \
+ check##NAME (rslt, g16##NAME); \
+ } \
DEBUG_NL; \
}
#ifndef SKIP_COMPLEX
#ifndef SKIP_COMPLEX_INT
T(cc, _Complex char, CINT (0, 1))
-T(cs, _Complex short, CINT (1 + 2))
+T(cs, _Complex short, CINT (1, 2))
#endif
T(cf, _Complex float, CDBL (1.0, 2.0))
#endif
diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-4_y.c b/gcc/testsuite/gcc.dg/compat/scalar-return-4_y.c
index 3c96856..3ae0749 100644
--- a/gcc/testsuite/gcc.dg/compat/scalar-return-4_y.c
+++ b/gcc/testsuite/gcc.dg/compat/scalar-return-4_y.c
@@ -2,14 +2,11 @@
#include "compat-common.h"
-#ifdef SKIP_VA
-const int test_va = 0;
-#else
-const int test_va = 1;
-#endif
-
#define T(NAME, TYPE, INITVAL) \
-extern TYPE g01##NAME; \
+extern TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \
+extern TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \
+extern TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \
+extern TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \
\
extern void check##NAME (TYPE x, TYPE v); \
\
@@ -23,6 +20,21 @@ void \
checkg##NAME (void) \
{ \
check##NAME (g01##NAME, 1+INITVAL); \
+ check##NAME (g02##NAME, 2+INITVAL); \
+ check##NAME (g03##NAME, 3+INITVAL); \
+ check##NAME (g04##NAME, 4+INITVAL); \
+ check##NAME (g05##NAME, 5+INITVAL); \
+ check##NAME (g06##NAME, 6+INITVAL); \
+ check##NAME (g07##NAME, 7+INITVAL); \
+ check##NAME (g08##NAME, 8+INITVAL); \
+ check##NAME (g09##NAME, 9+INITVAL); \
+ check##NAME (g10##NAME, 10+INITVAL); \
+ check##NAME (g11##NAME, 11+INITVAL); \
+ check##NAME (g12##NAME, 12+INITVAL); \
+ check##NAME (g13##NAME, 13+INITVAL); \
+ check##NAME (g14##NAME, 14+INITVAL); \
+ check##NAME (g15##NAME, 15+INITVAL); \
+ check##NAME (g16##NAME, 16+INITVAL); \
} \
\
TYPE \
@@ -35,6 +47,19 @@ TYPE \
test1##NAME (TYPE x01) \
{ \
return x01; \
+} \
+ \
+TYPE \
+testva##NAME (int n, ...) \
+{ \
+ int i; \
+ TYPE rslt; \
+ va_list ap; \
+ va_start (ap, n); \
+ for (i = 0; i < n; i++) \
+ rslt = va_arg (ap, TYPE); \
+ va_end (ap); \
+ return rslt; \
}
#ifndef SKIP_COMPLEX
next reply other threads:[~2016-09-08 8:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-08 9:09 Uros Bizjak [this message]
2016-09-12 20:20 ` Mike Stump
2016-09-12 20:58 ` Jeff Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAFULd4awMpupam7zgaP6Y9zX9KPgfY5mHvZftf0W9JpVzA+2+w@mail.gmail.com \
--to=ubizjak@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=gcc@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=joseph@codesourcery.com \
--cc=mikestump@comcast.net \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).