From: Qing Zhao <qing.zhao@oracle.com>
To: josmyers@redhat.com, richard.guenther@gmail.com, uecker@tugraz.at
Cc: siddhesh@gotplt.org, keescook@chromium.org,
gcc-patches@gcc.gnu.org, Qing Zhao <qing.zhao@oracle.com>
Subject: [RFC][PATCH v1 4/4] Adjust testcases for flexible array member in union and alone in structure extension.
Date: Fri, 19 Apr 2024 18:43:17 +0000 [thread overview]
Message-ID: <20240419184317.2138890-5-qing.zhao@oracle.com> (raw)
In-Reply-To: <20240419184317.2138890-1-qing.zhao@oracle.com>
gcc/testsuite/ChangeLog:
* c-c++-common/builtin-clear-padding-3.c: Adjust testcase.
* g++.dg/ext/flexary12.C: Likewise.
* g++.dg/ext/flexary19.C: Likewise.
* g++.dg/ext/flexary2.C: Likewise.
* g++.dg/ext/flexary3.C: Likewise.
* g++.dg/ext/flexary36.C: Likewise.
* g++.dg/ext/flexary4.C: Likewise.
* g++.dg/ext/flexary5.C: Likewise.
* g++.dg/ext/flexary8.C: Likewise.
* g++.dg/torture/pr64280.C: Likewise.
* gcc.dg/20050620-1.c: Likewise.
* gcc.dg/940510-1.c: Likewise.
---
.../c-c++-common/builtin-clear-padding-3.c | 10 ++--
gcc/testsuite/g++.dg/ext/flexary12.C | 6 +--
gcc/testsuite/g++.dg/ext/flexary19.C | 42 +++++++--------
gcc/testsuite/g++.dg/ext/flexary2.C | 2 +-
gcc/testsuite/g++.dg/ext/flexary3.C | 2 +-
gcc/testsuite/g++.dg/ext/flexary36.C | 2 +-
gcc/testsuite/g++.dg/ext/flexary4.C | 54 +++++++++----------
gcc/testsuite/g++.dg/ext/flexary5.C | 4 +-
gcc/testsuite/g++.dg/ext/flexary8.C | 8 +--
gcc/testsuite/g++.dg/torture/pr64280.C | 2 +-
gcc/testsuite/gcc.dg/20050620-1.c | 2 +-
gcc/testsuite/gcc.dg/940510-1.c | 4 +-
12 files changed, 68 insertions(+), 70 deletions(-)
diff --git a/gcc/testsuite/c-c++-common/builtin-clear-padding-3.c b/gcc/testsuite/c-c++-common/builtin-clear-padding-3.c
index d16cc6aad05f..a4f49f26db14 100644
--- a/gcc/testsuite/c-c++-common/builtin-clear-padding-3.c
+++ b/gcc/testsuite/c-c++-common/builtin-clear-padding-3.c
@@ -2,14 +2,12 @@
/* { dg-do compile } */
/* { dg-options "" } */
-union U { int a; char b[] __attribute__((aligned (2 * sizeof (int)))); }; /* { dg-error "flexible array member in union" } */
+union U { int a; char b[] __attribute__((aligned (2 * sizeof (int)))); };
struct V { int a; union U b; };
-struct W { int a; union U b; int c; };
void
-foo (union U *u, struct V *v, struct W *w)
+foo (union U *u, struct V *v)
{
- __builtin_clear_padding (u);
- __builtin_clear_padding (v);
- __builtin_clear_padding (w);
+ __builtin_clear_padding (u); /* { dg-error "flexible array member" "does not have well defined padding bits" } */
+ __builtin_clear_padding (v); /* { dg-error "flexible array member" "does not have well defined padding bits" } */
}
diff --git a/gcc/testsuite/g++.dg/ext/flexary12.C b/gcc/testsuite/g++.dg/ext/flexary12.C
index b0964948731d..6ba4b6417135 100644
--- a/gcc/testsuite/g++.dg/ext/flexary12.C
+++ b/gcc/testsuite/g++.dg/ext/flexary12.C
@@ -6,7 +6,7 @@
// { dg-options "-Wno-pedantic" }
struct A {
- int a []; // { dg-error "flexible array member .A::a. in an otherwise empty .struct A." }
+ int a [];
};
void f1 ()
@@ -40,7 +40,7 @@ void f2 ()
}
struct D {
- int a []; // { dg-error "flexible array member .D::a. in an otherwise empty .struct D." }
+ int a [];
D ();
};
@@ -52,7 +52,7 @@ D::D (): // { dg-error "initializer for flexible array member" }
template <class T>
struct C {
- T a []; // { dg-error "flexible array member" }
+ T a [];
};
void f3 ()
diff --git a/gcc/testsuite/g++.dg/ext/flexary19.C b/gcc/testsuite/g++.dg/ext/flexary19.C
index abfbc43028af..9a06f9ca758f 100644
--- a/gcc/testsuite/g++.dg/ext/flexary19.C
+++ b/gcc/testsuite/g++.dg/ext/flexary19.C
@@ -12,7 +12,7 @@ struct S1
// The following declares a named data member of an unnamed struct
// (i.e., it is not an anonymous struct).
struct {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[]; // { dg-warning "in an otherwise empty" }
} s;
};
@@ -21,7 +21,7 @@ struct S2
int i;
struct {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[]; // { dg-warning "in an otherwise empty" }
} s[1];
};
@@ -30,7 +30,7 @@ struct S3
int i;
struct {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[]; // { dg-warning "in an otherwise empty" }
} s[];
};
@@ -39,7 +39,7 @@ struct S4
int i;
struct {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[]; // { dg-warning "in an otherwise empty" }
} s[2];
};
@@ -48,7 +48,7 @@ struct S5
int i;
struct {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[]; // { dg-warning "in an otherwise empty" }
} s[1][2];
};
@@ -57,7 +57,7 @@ struct S6
int i;
struct {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[]; // { dg-warning "in an otherwise empty" }
} s[][2];
};
@@ -66,7 +66,7 @@ struct S7
int i;
struct {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[]; // { dg-warning "in an otherwise empty" }
} *s;
};
@@ -75,7 +75,7 @@ struct S8
int i;
struct {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[]; // { dg-warning "in an otherwise empty" }
} **s;
};
@@ -84,7 +84,7 @@ struct S9
int i;
struct {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[]; // { dg-warning "in an otherwise empty" }
} *s[1];
};
@@ -93,7 +93,7 @@ struct S10
int i;
struct {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[]; // { dg-warning "in an otherwise empty" }
} *s[];
};
@@ -102,7 +102,7 @@ struct S11
int i;
struct {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[]; // { dg-warning "in an otherwise empty" }
} **s[1];
};
@@ -111,7 +111,7 @@ struct S12
int i;
struct {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[]; // { dg-warning "in an otherwise empty" }
} **s[];
};
@@ -120,7 +120,7 @@ struct S13
int i;
struct {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[]; // { dg-warning "in an otherwise empty" }
} **s[2];
};
@@ -129,7 +129,7 @@ struct S14
int i;
struct {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[]; // { dg-warning "in an otherwise empty" }
} &s;
};
@@ -138,7 +138,7 @@ struct S15
int i;
typedef struct {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[]; // { dg-warning "in an otherwise empty" }
} T15;
};
@@ -159,8 +159,8 @@ struct S17
{
int i;
- union { // anonymous union
- int a[]; // { dg-error "flexible array member in union" }
+ union { // { dg-warning "invalid use" }
+ int a[]; // { dg-warning "flexible array member in union" }
};
};
@@ -209,7 +209,7 @@ struct S22
struct S22S {
static int i;
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[]; // { dg-warning "in an otherwise empty" }
} s;
};
@@ -218,7 +218,7 @@ struct S23
struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct" }
static int i; // { dg-error "static data member" }
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[]; // { dg-warning "in an otherwise empty" }
};
};
@@ -227,7 +227,7 @@ struct S24
static int i;
struct {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[]; // { dg-warning "in an otherwise empty" }
} s;
};
@@ -252,7 +252,7 @@ struct S26
};
struct {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[]; // { dg-warning "in an otherwise empty" }
} s;
};
diff --git a/gcc/testsuite/g++.dg/ext/flexary2.C b/gcc/testsuite/g++.dg/ext/flexary2.C
index c0253777a1e9..7095a3b0fb2d 100644
--- a/gcc/testsuite/g++.dg/ext/flexary2.C
+++ b/gcc/testsuite/g++.dg/ext/flexary2.C
@@ -13,7 +13,7 @@ struct A {
struct B {
B() {}
- A a[]; // { dg-error "extension|flexible array .* in an otherwise empty" }
+ A a[];
};
struct C {
diff --git a/gcc/testsuite/g++.dg/ext/flexary3.C b/gcc/testsuite/g++.dg/ext/flexary3.C
index 8344b42dd163..7785c9b190a4 100644
--- a/gcc/testsuite/g++.dg/ext/flexary3.C
+++ b/gcc/testsuite/g++.dg/ext/flexary3.C
@@ -11,7 +11,7 @@
// { dg-options "" }
struct s {
- char c[]; // { dg-error "flexible array member .* in an otherwise empty" }
+ char c[];
};
int main()
diff --git a/gcc/testsuite/g++.dg/ext/flexary36.C b/gcc/testsuite/g++.dg/ext/flexary36.C
index 5bb827cfd0e0..87d6fb092100 100644
--- a/gcc/testsuite/g++.dg/ext/flexary36.C
+++ b/gcc/testsuite/g++.dg/ext/flexary36.C
@@ -25,7 +25,7 @@ struct {
union {
- int a[]; // { dg-error "flexible array member in union" }
+ int a[];
int b;
} du = { 1 };
diff --git a/gcc/testsuite/g++.dg/ext/flexary4.C b/gcc/testsuite/g++.dg/ext/flexary4.C
index bd28cf55de2b..a87b7e71edb6 100644
--- a/gcc/testsuite/g++.dg/ext/flexary4.C
+++ b/gcc/testsuite/g++.dg/ext/flexary4.C
@@ -11,79 +11,79 @@
#include "flexary.h"
struct Sx {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[];
};
// Verify that non-data members or static data members either before
// or after a flexible array member in an otherwise empty struct don't
// suppress the diagnostic.
struct Sx2 {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[];
typedef int I;
};
struct Sx3 {
typedef int I;
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[];
};
struct Sx4 {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[];
enum E { e };
};
struct Sx5 {
enum E { e };
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[];
};
struct Sx6 {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[];
static int i;
};
struct Sx7 {
static int i;
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[];
};
struct Sx8 {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[];
Sx8 () { }
};
struct Sx9 {
Sx9 () { }
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[];
};
struct Sx10 {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[];
virtual ~Sx10 () { }
};
struct Sx11 {
virtual ~Sx11 () { }
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[];
};
struct Sx12 {
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[];
virtual void foo () = 0;
};
struct Sx13 {
virtual void foo () = 0;
- int a[]; // { dg-error "in an otherwise empty" }
+ int a[];
};
struct Sx14 {
- int a[][1]; // { dg-error "in an otherwise empty" }
+ int a[][1];
};
struct Sx15 {
typedef int A[];
- A a; // { dg-error "in an otherwise empty" }
+ A a;
};
// Verify also that a zero-size array doesn't suppress the diagnostic.
@@ -91,7 +91,7 @@ struct Sx16 {
// a_0 below is diagnosed with -Wpedantic only and emits
// warning: ISO C++ forbids zero-size arrays
int a_0 [0];
- int a_x []; // { dg-error "in an otherwise empty" }
+ int a_x [];
};
struct Sx17 {
@@ -123,7 +123,7 @@ struct Sx19 {
// so doesn't contribute its member to that of the enclosing struct.
struct Sx20 {
struct S { int i; };
- int a_x []; // { dg-error "in an otherwise empty" }
+ int a_x [];
};
struct Sx21 {
@@ -148,12 +148,12 @@ struct Sx24 {
struct Sx25 {
struct S { };
- S a_x []; // { dg-error "flexible array member" }
+ S a_x [];
};
struct Sx26 {
struct { }
- a_x []; // { dg-error "flexible array member" }
+ a_x [];
};
struct Sx27 {
@@ -193,13 +193,13 @@ struct Sx32 {
ASSERT_AT_END (Sx32, a);
struct Sx33 {
- int a []; // { dg-error "otherwise empty" }
+ int a [];
friend int foo ();
};
struct Sx34 {
friend int foo ();
- int a []; // { dg-error "otherwise empty" }
+ int a [];
};
// Verify that intervening non-field declarations of members other
@@ -277,7 +277,7 @@ ASSERT_AT_END (Sx44, a);
struct S_S_S_x {
struct A {
struct B {
- int a[]; // { dg-error "flexible array member" }
+ int a[];
} b;
} a;
};
@@ -300,7 +300,7 @@ struct NotAnon1 {
// The following is not an anonymous struct -- the type is unnamed
// but the object has a name.
struct {
- int bad[]; // { dg-error "otherwise empty" }
+ int bad[];
} name;
};
@@ -328,7 +328,7 @@ ASSERT_AT_END (Anon3, good);
struct Anon4 {
struct {
- int in_empty_struct[]; // { dg-error "in an otherwise empty" }
+ int in_empty_struct[];
};
};
@@ -366,7 +366,7 @@ struct Six {
ASSERT_AT_END (Six, a);
class Cx {
- int a[]; // { dg-error "flexible array member" }
+ int a[];
};
class Cix {
@@ -390,7 +390,7 @@ struct S0i {
struct S_a0_ax {
int a0[0];
- int ax[]; // { dg-error "flexible array member" }
+ int ax[];
};
struct S_a0_i_ax {
@@ -417,7 +417,7 @@ struct Si_ax_a0 {
struct S_u0_ax {
union { } u[0];
- int ax[]; // { dg-error "flexible array member" }
+ int ax[];
};
struct S_a1_s2 {
diff --git a/gcc/testsuite/g++.dg/ext/flexary5.C b/gcc/testsuite/g++.dg/ext/flexary5.C
index d5ec13204966..3fb88c0e8a2c 100644
--- a/gcc/testsuite/g++.dg/ext/flexary5.C
+++ b/gcc/testsuite/g++.dg/ext/flexary5.C
@@ -13,7 +13,7 @@ struct S_no_diag: T {
template <class T>
struct STx_1: T {
- char a[]; // { dg-error "flexible array member" }
+ char a[];
};
template <class T, int I>
@@ -37,7 +37,7 @@ struct E1: E<0>, E<1> { };
struct E2: E<2>, E<3> { };
struct D1: E1, E2
{
- char a[]; // { dg-error "flexible array member" }
+ char a[];
};
struct NE { size_t i; };
diff --git a/gcc/testsuite/g++.dg/ext/flexary8.C b/gcc/testsuite/g++.dg/ext/flexary8.C
index 7a1811deaff2..a0477f0fa410 100644
--- a/gcc/testsuite/g++.dg/ext/flexary8.C
+++ b/gcc/testsuite/g++.dg/ext/flexary8.C
@@ -4,26 +4,26 @@
union U_i_ax {
int i;
- int a[]; // { dg-error "flexible array member in union" }
+ int a[];
};
struct SU1 {
union {
- int a[]; // { dg-error "flexible array member in union" }
+ int a[];
};
};
struct SU2 {
int n;
union {
- int a[]; // { dg-error "flexible array member in union" }
+ int a[];
};
};
struct SU3 {
union {
int n;
- int a[]; // { dg-error "flexible array member in union" }
+ int a[];
};
};
diff --git a/gcc/testsuite/g++.dg/torture/pr64280.C b/gcc/testsuite/g++.dg/torture/pr64280.C
index 5c569e864b4c..1ea70c4e766e 100644
--- a/gcc/testsuite/g++.dg/torture/pr64280.C
+++ b/gcc/testsuite/g++.dg/torture/pr64280.C
@@ -15,7 +15,7 @@ public:
typedef int jmp_buf[];
struct C
{
- jmp_buf cond_; // { dg-error "flexible array member" }
+ jmp_buf cond_;
};
class F
{
diff --git a/gcc/testsuite/gcc.dg/20050620-1.c b/gcc/testsuite/gcc.dg/20050620-1.c
index befdd9636500..0a9e1d478454 100644
--- a/gcc/testsuite/gcc.dg/20050620-1.c
+++ b/gcc/testsuite/gcc.dg/20050620-1.c
@@ -5,7 +5,7 @@
void
foo (void)
{
- struct { int i[]; } u; /* { dg-error "flexible array member" } */
+ struct { int i[]; } u;
}
void
diff --git a/gcc/testsuite/gcc.dg/940510-1.c b/gcc/testsuite/gcc.dg/940510-1.c
index 46183831d096..9bcd7881f715 100644
--- a/gcc/testsuite/gcc.dg/940510-1.c
+++ b/gcc/testsuite/gcc.dg/940510-1.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
/* { dg-options "-std=c89 -pedantic" } */
struct { int a[]; } x = { 0 }; /* { dg-warning "ISO C90 does not support flexible array members" } */
-/* { dg-error "flexible array member in a struct with no named members" "" { target *-*-* } .-1 } */
-
+/* { dg-warning "flexible array member in a struct with no named members is a GCC extension" "" { target *-*-* } .-1 } */
+/* { dg-warning "initialization of a flexible array member" "" { target *-*-* } .-2 } */
--
2.31.1
next prev parent reply other threads:[~2024-04-19 18:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-19 18:43 [RFC][PATCH v1 0/4] Allow flexible array members in unions and alone in structures [PR53548] Qing Zhao
2024-04-19 18:43 ` [RFC][PATCH v1 1/4] Documentation change Qing Zhao
2024-04-19 20:54 ` Tom Tromey
2024-04-22 13:28 ` Qing Zhao
2024-04-23 18:04 ` Joseph Myers
2024-04-23 18:21 ` Qing Zhao
2024-04-23 19:03 ` Joseph Myers
2024-04-23 19:21 ` Qing Zhao
2024-04-19 18:43 ` [RFC][PATCH v1 2/4] C and C++ FE changes to support flexible array members in unions and alone in structures Qing Zhao
2024-04-23 19:51 ` Joseph Myers
2024-04-23 19:58 ` Qing Zhao
2024-04-19 18:43 ` [RFC][PATCH v1 3/4] Add testing cases for " Qing Zhao
2024-04-23 18:53 ` Joseph Myers
2024-04-23 19:30 ` Qing Zhao
2024-04-19 18:43 ` Qing Zhao [this message]
2024-04-19 21:55 ` [RFC][PATCH v1 0/4] Allow flexible array members in unions and alone in structures [PR53548] Kees Cook
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=20240419184317.2138890-5-qing.zhao@oracle.com \
--to=qing.zhao@oracle.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=josmyers@redhat.com \
--cc=keescook@chromium.org \
--cc=richard.guenther@gmail.com \
--cc=siddhesh@gotplt.org \
--cc=uecker@tugraz.at \
/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).