diff options
author | Qing Zhao <qing.zhao@oracle.com> | 2024-05-06 16:26:19 +0000 |
---|---|---|
committer | Qing Zhao <qing.zhao@oracle.com> | 2024-05-06 18:32:58 +0000 |
commit | f27fc59d9f7c735d200fda647a487850144b10eb (patch) | |
tree | e789eab17c762caab752fd74961f696f7b660948 /gcc/c | |
parent | adb1c8a0f167c3a1f7593d75f5a10eb07a5d741a (diff) | |
download | gcc-f27fc59d9f7c735d200fda647a487850144b10eb.zip gcc-f27fc59d9f7c735d200fda647a487850144b10eb.tar.gz gcc-f27fc59d9f7c735d200fda647a487850144b10eb.tar.bz2 |
C and C++ FE changes to support flexible array members in unions and alone in structures. Adjust testcases for flexible array member in union and alone in structure extension.
PR c/53548
gcc/c/ChangeLog:
PR c/53548
* c-decl.cc (finish_struct): Change errors to pedwarns for the cases
flexible array members in union or alone in structures.
gcc/cp/ChangeLog:
PR c/53548
* class.cc (diagnose_flexarrays): Change error to pdewarn for the case
flexible array members alone in structures.
* decl.cc (grokdeclarator): Change error to pdewarn for the case
flexible array members in unions.
gcc/ChangeLog:
PR c/53548
* stor-layout.cc (place_union_field): Use zero sizes for flexible array
member fields.
gcc/testsuite/ChangeLog:
PR c/53548
* 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.
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/c-decl.cc | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index 52af8f3..9ef2ab2 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -9516,11 +9516,8 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, if (flexible_array_member_type_p (TREE_TYPE (x))) { if (TREE_CODE (t) == UNION_TYPE) - { - error_at (DECL_SOURCE_LOCATION (x), - "flexible array member in union"); - TREE_TYPE (x) = error_mark_node; - } + pedwarn (DECL_SOURCE_LOCATION (x), OPT_Wpedantic, + "flexible array member in union is a GCC extension"); else if (!is_last_field) { error_at (DECL_SOURCE_LOCATION (x), @@ -9528,12 +9525,9 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, TREE_TYPE (x) = error_mark_node; } else if (!saw_named_field) - { - error_at (DECL_SOURCE_LOCATION (x), - "flexible array member in a struct with no named " - "members"); - TREE_TYPE (x) = error_mark_node; - } + pedwarn (DECL_SOURCE_LOCATION (x), OPT_Wpedantic, + "flexible array member in a struct with no named " + "members is a GCC extension"); } if (pedantic && TREE_CODE (t) == RECORD_TYPE |