[GCC13,V4,0/2] Add a new option -fstrict-flex-array[=n] and attribute strict_flex_array(n) and use it in PR101836

Message ID 20220907002817.236178-1-qing.zhao@oracle.com
Headers
Series Add a new option -fstrict-flex-array[=n] and attribute strict_flex_array(n) and use it in PR101836 |

Message

Qing Zhao Sept. 7, 2022, 12:28 a.m. UTC
  This is the 4th version of the patch set.
Compare to the 3rd version, the following are the major change:

1. delete all the warnings for the confliction between -std and
-fstrict-flex-arrays per our discussion.
2. delete all the related testing cases for these warnings.
3. update all the wording changes, and documentation format changes
recommanded by Joseph.
I have bootstrapped and regression tested on both aarch64 and x86, no issues.

Let me know if you have any comments on the patches.

thanks.

Qing Zhao (2):
  Add a new option -fstrict-flex-arrays[=n] and new attribute
    strict_flex_arrays
  Use array_at_struct_end_p in __builtin_object_size [PR101836]

 gcc/c-family/c-attribs.cc                  |  47 ++++++++
 gcc/c-family/c.opt                         |   7 ++
 gcc/c/c-decl.cc                            | 130 +++++++++++++++++++--
 gcc/cp/module.cc                           |   2 +
 gcc/doc/extend.texi                        |  25 ++++
 gcc/doc/invoke.texi                        |  27 ++++-
 gcc/print-tree.cc                          |   8 +-
 gcc/testsuite/g++.dg/strict-flex-array-1.C |  31 +++++
 gcc/testsuite/gcc.dg/pr101836.c            |  60 ++++++++++
 gcc/testsuite/gcc.dg/pr101836_1.c          |  60 ++++++++++
 gcc/testsuite/gcc.dg/pr101836_2.c          |  60 ++++++++++
 gcc/testsuite/gcc.dg/pr101836_3.c          |  60 ++++++++++
 gcc/testsuite/gcc.dg/pr101836_4.c          |  60 ++++++++++
 gcc/testsuite/gcc.dg/pr101836_5.c          |  60 ++++++++++
 gcc/testsuite/gcc.dg/strict-flex-array-1.c |  31 +++++
 gcc/testsuite/gcc.dg/strict-flex-array-2.c |  60 ++++++++++
 gcc/testsuite/gcc.dg/strict-flex-array-3.c |  60 ++++++++++
 gcc/tree-core.h                            |   5 +-
 gcc/tree-object-size.cc                    |  16 ++-
 gcc/tree-streamer-in.cc                    |   1 +
 gcc/tree-streamer-out.cc                   |   1 +
 gcc/tree.cc                                |  45 +++++--
 gcc/tree.h                                 |  14 ++-
 23 files changed, 833 insertions(+), 37 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/strict-flex-array-1.C
 create mode 100644 gcc/testsuite/gcc.dg/pr101836.c
 create mode 100644 gcc/testsuite/gcc.dg/pr101836_1.c
 create mode 100644 gcc/testsuite/gcc.dg/pr101836_2.c
 create mode 100644 gcc/testsuite/gcc.dg/pr101836_3.c
 create mode 100644 gcc/testsuite/gcc.dg/pr101836_4.c
 create mode 100644 gcc/testsuite/gcc.dg/pr101836_5.c
 create mode 100644 gcc/testsuite/gcc.dg/strict-flex-array-1.c
 create mode 100644 gcc/testsuite/gcc.dg/strict-flex-array-2.c
 create mode 100644 gcc/testsuite/gcc.dg/strict-flex-array-3.c