Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-06-07 Thread Qing Zhao
Hi, Richard, > On Jun 5, 2024, at 13:58, Qing Zhao wrote: >> >>>>>>>>> Like this? >>>>>>>>> >>>>>>>>> diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h >>>>>>>>

Re: "counted_by" and -fanalyzer

2024-06-05 Thread Qing Zhao
> On Jun 5, 2024, at 09:49, David Malcolm wrote: > > On Tue, 2024-06-04 at 22:09 +0000, Qing Zhao wrote: >> >> >>> On Jun 4, 2024, at 17:55, David Malcolm >>> wrote: >>> >>> On Fri, 2024-05-31 at 13:11 +, Qing Zhao wrote

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-06-05 Thread Qing Zhao
> On Jun 5, 2024, at 13:07, Richard Biener wrote: > > > >> Am 05.06.2024 um 18:39 schrieb Qing Zhao : >> >>  >> >>> On Jun 5, 2024, at 03:26, Richard Biener wrote: >>> >>>> On Tue, Jun 4, 2024 at 10:31 PM Qing Zhao wrote

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-06-05 Thread Qing Zhao
> On Jun 5, 2024, at 03:26, Richard Biener wrote: > > On Tue, Jun 4, 2024 at 10:31 PM Qing Zhao wrote: >> >> >> >>> On Jun 4, 2024, at 03:43, Richard Biener wrote: >>> >>> On Mon, Jun 3, 2024 at 4:48 PM David Malcolm wrote: >&g

Re: "counted_by" and -fanalyzer (was Re: [PATCH v10 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.)

2024-06-04 Thread Qing Zhao
> On Jun 4, 2024, at 17:55, David Malcolm wrote: > > On Fri, 2024-05-31 at 13:11 +0000, Qing Zhao wrote: >> >> >>> On May 31, 2024, at 08:58, Richard Biener >>> wrote: >>> >>> On Thu, 30 May 2024, Qing Zhao wrote: >>> >

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-06-04 Thread Qing Zhao
> On Jun 4, 2024, at 03:43, Richard Biener wrote: > > On Mon, Jun 3, 2024 at 4:48 PM David Malcolm wrote: >> >> On Mon, 2024-06-03 at 08:29 +0200, Richard Biener wrote: >>> On Fri, May 31, 2024 at 11:23 PM Qing Zhao >>> wrote: >>>> &

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-06-03 Thread Qing Zhao
> On Jun 3, 2024, at 02:29, Richard Biener wrote: > > On Fri, May 31, 2024 at 11:23 PM Qing Zhao wrote: >> >> >> >>> On May 23, 2024, at 07:46, Richard Biener >>> wrote: >>> >>> On Wed, May 22, 2024 at 8:53 PM Qing Zhao wr

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-31 Thread Qing Zhao
> On May 23, 2024, at 07:46, Richard Biener wrote: > > On Wed, May 22, 2024 at 8:53 PM Qing Zhao wrote: >> >> >> >>> On May 22, 2024, at 03:38, Richard Biener >>> wrote: >>> >>> On Tue, May 21, 2024 at 11:36 PM David Mal

[gcc r15-947] Use the .ACCESS_WITH_SIZE in bound sanitizer.

2024-05-31 Thread Qing Zhao via Gcc-cvs
https://gcc.gnu.org/g:3d94fee616d6132075f3292a6eafdcb7b1d3f5a5 commit r15-947-g3d94fee616d6132075f3292a6eafdcb7b1d3f5a5 Author: Qing Zhao Date: Tue May 28 18:37:14 2024 + Use the .ACCESS_WITH_SIZE in bound sanitizer. gcc/c-family/ChangeLog: * c-ubsan.cc

[gcc r15-948] Add the 6th argument to .ACCESS_WITH_SIZE

2024-05-31 Thread Qing Zhao via Gcc-cvs
https://gcc.gnu.org/g:4c5bea7def13613fba166edb23289bab446b0b48 commit r15-948-g4c5bea7def13613fba166edb23289bab446b0b48 Author: Qing Zhao Date: Tue May 28 18:39:31 2024 + Add the 6th argument to .ACCESS_WITH_SIZE to carry the TYPE of the flexible array

[gcc r15-946] Use the .ACCESS_WITH_SIZE in builtin object size.

2024-05-31 Thread Qing Zhao via Gcc-cvs
https://gcc.gnu.org/g:6f17933548fc34ee269e90546a590df8269cee60 commit r15-946-g6f17933548fc34ee269e90546a590df8269cee60 Author: Qing Zhao Date: Tue May 28 18:36:00 2024 + Use the .ACCESS_WITH_SIZE in builtin object size. gcc/ChangeLog: * tree-object-size.cc

[gcc r15-945] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.

2024-05-31 Thread Qing Zhao via Gcc-cvs
https://gcc.gnu.org/g:bb49b6e4f55891d0d8b596845118f40df6ae72a5 commit r15-945-gbb49b6e4f55891d0d8b596845118f40df6ae72a5 Author: Qing Zhao Date: Tue May 28 18:34:09 2024 + Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE. Including the

[gcc r15-944] Provide counted_by attribute to flexible array member field

2024-05-31 Thread Qing Zhao via Gcc-cvs
https://gcc.gnu.org/g:f824acd0e807546a733c122ab6340f18cef88766 commit r15-944-gf824acd0e807546a733c122ab6340f18cef88766 Author: Qing Zhao Date: Tue May 28 18:30:05 2024 + Provide counted_by attribute to flexible array member field 'counted_by (COUNT)' The 'counted_by

Re: [PATCH v10 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.

2024-05-31 Thread Qing Zhao
> On May 31, 2024, at 08:58, Richard Biener wrote: > > On Thu, 30 May 2024, Qing Zhao wrote: > >> Including the following changes: >> * The definition of the new internal function .ACCESS_WITH_SIZE >> in internal-fn.def. >> * C FE converts every r

Re: [PATCH v10 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.

2024-05-30 Thread Qing Zhao
> On May 30, 2024, at 15:43, Joseph Myers wrote: > > On Thu, 30 May 2024, Qing Zhao wrote: > >> In order to make this working, the routine digest_init in c-typeck.cc >> is updated to fold calls to .ACCESS_WITH_SIZE to its first argument >> when require_

[PATCH v10 3/5] Use the .ACCESS_WITH_SIZE in builtin object size.

2024-05-30 Thread Qing Zhao
gcc/ChangeLog: * tree-object-size.cc (access_with_size_object_size): New function. (call_object_size): Call the new function. gcc/testsuite/ChangeLog: * gcc.dg/builtin-object-size-common.h: Add a new macro EXPECT. * gcc.dg/flex-array-counted-by-3.c: New test.

[PATCH v10 5/5] Add the 6th argument to .ACCESS_WITH_SIZE

2024-05-30 Thread Qing Zhao
to carry the TYPE of the flexible array. Such information is needed during tree-object-size.cc. We cannot use the result type or the type of the 1st argument of the routine .ACCESS_WITH_SIZE to decide the element type of the original array due to possible type casting in the source code.

[PATCH v10 4/5] Use the .ACCESS_WITH_SIZE in bound sanitizer.

2024-05-30 Thread Qing Zhao
gcc/c-family/ChangeLog: * c-ubsan.cc (get_bound_from_access_with_size): New function. (ubsan_instrument_bounds): Handle call to .ACCESS_WITH_SIZE. gcc/testsuite/ChangeLog: * gcc.dg/ubsan/flex-array-counted-by-bounds-2.c: New test. *

[PATCH v10 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.

2024-05-30 Thread Qing Zhao
Including the following changes: * The definition of the new internal function .ACCESS_WITH_SIZE in internal-fn.def. * C FE converts every reference to a FAM with a "counted_by" attribute to a call to the internal function .ACCESS_WITH_SIZE. (build_component_ref in c_typeck.cc) This

[PATCH v10 1/5] Provide counted_by attribute to flexible array member field (PR108896)

2024-05-30 Thread Qing Zhao
'counted_by (COUNT)' The 'counted_by' attribute may be attached to the C99 flexible array member of a structure. It indicates that the number of the elements of the array is given by the field "COUNT" in the same structure as the flexible array member. GCC may use this

[PATCH v10 0/5] New attribute "counted_by" to annotate bounds for C99 FAM(PR108896)

2024-05-30 Thread Qing Zhao
Hi, This is the 10th version of the patch. Which is rebased on the latest trunk. Compare with the 9th version, all the difference are in patch #2, including a small C FE change in the routine "digest_init". all others are middle-end changes. please review the changes for the patch #2: updates

Re: [PATCH v9 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.

2024-05-29 Thread Qing Zhao
Richard and Joseph: > On May 28, 2024, at 17:09, Qing Zhao wrote: > >>> >>> diff --git a/gcc/varasm.cc b/gcc/varasm.cc >>> index fa17eff551e8..d75b23668925 100644 >>> --- a/gcc/varasm.cc >>> +++ b/gcc/varasm.cc >>> @@ -5082,6

Re: [PATCH v9 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.

2024-05-29 Thread Qing Zhao
> On May 29, 2024, at 02:57, Richard Biener wrote: > > On Tue, May 28, 2024 at 11:09 PM Qing Zhao wrote: >> >> Thank you for the comments. See my answers below: >> >> Joseph, please see the last question, I need your help on it. Thanks a lot >> for

Re: [PATCH v9 5/5] Add the 6th argument to .ACCESS_WITH_SIZE

2024-05-28 Thread Qing Zhao
> On May 28, 2024, at 03:43, Richard Biener wrote: > > On Fri, Apr 12, 2024 at 3:55 PM Qing Zhao wrote: >> >> to carry the TYPE of the flexible array. >> >> Such information is needed during tree-object-size.cc. >> >> We cannot use th

Re: [PATCH v9 3/5] Use the .ACCESS_WITH_SIZE in builtin object size.

2024-05-28 Thread Qing Zhao
> On May 28, 2024, at 03:39, Richard Biener wrote: > > On Fri, Apr 12, 2024 at 3:54 PM Qing Zhao wrote: >> > > I have no comments here, if Siddesh is OK with this I approve. thanks. Qing > >> gcc/ChangeLog: >> >>* tree-object-size.cc (a

Re: [PATCH v9 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.

2024-05-28 Thread Qing Zhao
Thank you for the comments. See my answers below: Joseph, please see the last question, I need your help on it. Thanks a lot for the help. Qing > On May 28, 2024, at 03:38, Richard Biener wrote: > > On Fri, Apr 12, 2024 at 3:54 PM Qing Zhao wrote: >> >> Including

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-23 Thread Qing Zhao
> On May 23, 2024, at 10:13, David Malcolm wrote: > > On Thu, 2024-05-23 at 14:03 +0000, Qing Zhao wrote: > > [...snip...] > >> Is “location_adhoc_data” an available data structure in current GCC? >> I just searched GCC source tree, cannot find it. > >

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-23 Thread Qing Zhao
> On May 23, 2024, at 07:46, Richard Biener wrote: > > On Wed, May 22, 2024 at 8:53 PM Qing Zhao wrote: >> >> >> >>> On May 22, 2024, at 03:38, Richard Biener >>> wrote: >>> >>> On Tue, May 21, 2024 at 11:36 PM David Mal

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-22 Thread Qing Zhao
> On May 22, 2024, at 03:38, Richard Biener wrote: > > On Tue, May 21, 2024 at 11:36 PM David Malcolm wrote: >> >> On Tue, 2024-05-21 at 15:13 +, Qing Zhao wrote: >>> Thanks for the comments and suggestions. >>> >>>> O

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-21 Thread Qing Zhao
Thanks for the comments and suggestions. > On May 15, 2024, at 10:00, David Malcolm wrote: > > On Tue, 2024-05-14 at 15:08 +0200, Richard Biener wrote: >> On Mon, 13 May 2024, Qing Zhao wrote: >> >>> -Warray-bounds is an important option to enable linux kernal

3rd Ping [PATCH v9 0/5] New attribute "counted_by" to annotate bounds for C99 FAM(PR108896)

2024-05-20 Thread Qing Zhao
024, at 10:14, Qing Zhao wrote: > > > >> On May 7, 2024, at 10:02, Qing Zhao wrote: >> >> 2nd Ping for the middle-end change approval. -:) >> >> **Approval status: >> >> All C FE changes have been approved. >> >> **Revi

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-15 Thread Qing Zhao
> On May 15, 2024, at 02:09, Richard Biener wrote: > > On Tue, 14 May 2024, Qing Zhao wrote: > >> >> >>> On May 14, 2024, at 13:14, Richard Biener wrote: >>> >>> On Tue, 14 May 2024, Qing Zhao wrote: >>> >&g

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-14 Thread Qing Zhao
> On May 14, 2024, at 13:14, Richard Biener wrote: > > On Tue, 14 May 2024, Qing Zhao wrote: > >> >> >>> On May 14, 2024, at 10:29, Richard Biener wrote: >>> > [...] >>> It would of course >>> need experimenting since we c

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-14 Thread Qing Zhao
> On May 14, 2024, at 11:08, Jeff Law wrote: > > > > On 5/14/24 8:57 AM, Qing Zhao wrote: >>> On May 13, 2024, at 20:14, Kees Cook wrote: >>> >>> On Tue, May 14, 2024 at 01:38:49AM +0200, Andrew Pinski wrote: >>>> On Mon, May 13, 2024,

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-14 Thread Qing Zhao
> On May 14, 2024, at 10:29, Richard Biener wrote: > > On Tue, 14 May 2024, Qing Zhao wrote: > >> >> >>> On May 14, 2024, at 09:08, Richard Biener wrote: >>> >>> On Mon, 13 May 2024, Qing Zhao wrote: >>> >>>&

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-14 Thread Qing Zhao
> On May 13, 2024, at 20:14, Kees Cook wrote: > > On Tue, May 14, 2024 at 01:38:49AM +0200, Andrew Pinski wrote: >> On Mon, May 13, 2024, 11:41 PM Kees Cook wrote: >>> But it makes no sense to warn about: >>> >>> void sparx5_set (int * ptr, struct nums * sg, int index) >>> { >>> if (index

Re: [RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-14 Thread Qing Zhao
> On May 14, 2024, at 09:08, Richard Biener wrote: > > On Mon, 13 May 2024, Qing Zhao wrote: > >> -Warray-bounds is an important option to enable linux kernal to keep >> the array out-of-bound errors out of the source tree. >> >> However, due to

[RFC][PATCH] PR tree-optimization/109071 - -Warray-bounds false positive warnings due to code duplication from jump threading

2024-05-13 Thread Qing Zhao
-Warray-bounds is an important option to enable linux kernal to keep the array out-of-bound errors out of the source tree. However, due to the false positive warnings reported in PR109071 (-Warray-bounds false positive warnings due to code duplication from jump threading), -Warray-bounds=1 cannot

Re: [V2][PATCH] gcc-14/changes.html: Deprecate a GCC C extension on flexible array members.

2024-05-08 Thread Qing Zhao
> On May 7, 2024, at 17:52, Kees Cook wrote: > > On Tue, May 07, 2024 at 06:34:19PM +0000, Qing Zhao wrote: >> On May 7, 2024, at 13:57, Sebastian Huber >> wrote: >>> On 07.05.24 16:26, Qing Zhao wrote: >>>> Hi, Sebastian, >>>> Than

Re: [V2][PATCH] gcc-14/changes.html: Deprecate a GCC C extension on flexible array members.

2024-05-07 Thread Qing Zhao
(Resend since my previous email in HTML and inline quoting wasn’t work, I changed the mail setting, hopefully this time it’s good). Sorry for the inconvenience. > On May 7, 2024, at 13:57, Sebastian Huber > wrote: > > On 07.05.24 16:26, Qing Zhao wrote: >> Hi, Sebastian,

Re: [V2][PATCH] gcc-14/changes.html: Deprecate a GCC C extension on flexible array members.

2024-05-07 Thread Qing Zhao
On May 7, 2024, at 13:57, Sebastian Huber wrote: On 07.05.24 16:26, Qing Zhao wrote: Hi, Sebastian, Thanks for your explanation. Our goal is to deprecate the GCC extension on structure containing a flexible array member not at the end of another structure. In order to achieve this goal, we

Re: [V2][PATCH] gcc-14/changes.html: Deprecate a GCC C extension on flexible array members.

2024-05-07 Thread Qing Zhao
wrote: > > On 06.05.24 16:20, Qing Zhao wrote: >> Hi, Sebastian, >> Looks like that the behavior you described is correct. >> What’s your major concern? ( a little confused). > > I am concerned that the static initialization of structures with flexible > array members no

Re: Ping * 2 [PATCH v9 0/5] New attribute "counted_by" to annotate bounds for C99 FAM(PR108896)

2024-05-07 Thread Qing Zhao
On May 7, 2024, at 10:02, Qing Zhao wrote: 2nd Ping for the middle-end change approval. -:) **Approval status: All C FE changes have been approved. **Review status: All Middle-end changes have been reviewed by Sid, no remaining issue. Okay for GCC15? For convenience

Ping * 2 [PATCH v9 0/5] New attribute "counted_by" to annotate bounds for C99 FAM(PR108896)

2024-05-07 Thread Qing Zhao
2nd Ping for the middle-end change approval. -:) **Approval status: All C FE changes have been approved. **Review status: All Middle-end changes have been reviewed by Sid, no remaining issue. Okay for GCC15? thanks. Qing Begin forwarded message: From: Qing Zhao Subject: Re

[gcc r15-211] Update the C FE routine "add_flexible_array_elts_to_size" C++ FE routine "layout_var_decl" to handle

2024-05-06 Thread Qing Zhao via Gcc-cvs
https://gcc.gnu.org/g:6634a409124a884ff66b3756568a7daae7d3c295 commit r15-211-g6634a409124a884ff66b3756568a7daae7d3c295 Author: Qing Zhao Date: Mon May 6 16:28:01 2024 + Update the C FE routine "add_flexible_array_elts_to_size" C++ FE routine "layout_var_decl"

[gcc r15-210] Add testing cases for flexible array members in unions and alone in structures.

2024-05-06 Thread Qing Zhao via Gcc-cvs
https://gcc.gnu.org/g:93f6a47583f3fa8a1b66856ecb19ec28f26b2ba4 commit r15-210-g93f6a47583f3fa8a1b66856ecb19ec28f26b2ba4 Author: Qing Zhao Date: Mon May 6 16:27:09 2024 + Add testing cases for flexible array members in unions and alone in structures. PR c/53548 gcc

[gcc r15-209] C and C++ FE changes to support flexible array members in unions and alone in structures. Adjust tes

2024-05-06 Thread Qing Zhao via Gcc-cvs
https://gcc.gnu.org/g:f27fc59d9f7c735d200fda647a487850144b10eb commit r15-209-gf27fc59d9f7c735d200fda647a487850144b10eb Author: Qing Zhao Date: Mon May 6 16:26:19 2024 + C and C++ FE changes to support flexible array members in unions and alone in structures. Adjust testcases

[gcc r15-208] Allow flexible array members in unions and alone in structures [PR53548]

2024-05-06 Thread Qing Zhao via Gcc-cvs
https://gcc.gnu.org/g:adb1c8a0f167c3a1f7593d75f5a10eb07a5d741a commit r15-208-gadb1c8a0f167c3a1f7593d75f5a10eb07a5d741a Author: Qing Zhao Date: Mon May 6 16:25:04 2024 + Allow flexible array members in unions and alone in structures [PR53548] The request for GCC to accept

Re: [V2][PATCH] gcc-14/changes.html: Deprecate a GCC C extension on flexible array members.

2024-05-06 Thread Qing Zhao
Hi, Sebastian, Looks like that the behavior you described is correct. What’s your major concern? ( a little confused). Qing On May 6, 2024, at 09:29, Sebastian Huber wrote: On 06.05.24 09:08, Richard Biener wrote: On Sat, 4 May 2024, Sebastian Huber wrote: On 07.08.23 16:22, Qing Zhao via

[PATCH v5 4/4] Update the C/C++ FEs routine

2024-05-01 Thread Qing Zhao
"add_flexible_array_elts_to_size" C++ FE routine "layout_var_decl" to handle the cases when the DECL is union. Add testing cases to test the _bos for flexible array members in unions or alone in structures. gcc/c/ChangeLog: * c-decl.cc (add_flexible_array_elts_to_size): Handle the

[PATCH v5 3/4] Add testing cases for flexible array members in unions and alone in structures.

2024-05-01 Thread Qing Zhao
gcc/testsuite/ChangeLog: * c-c++-common/fam-in-union-alone-in-struct-1.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-2.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-3.c: New testcase. --- .../fam-in-union-alone-in-struct-1.c | 52

[PATCH v5 2/4] C and C++ FE changes

2024-05-01 Thread Qing Zhao
to support flexible array members in unions and alone in structures. Adjust testcases for flexible array member in union and alone in structure extension. gcc/c/ChangeLog: * c-decl.cc (finish_struct): Change errors to pedwarns for the cases flexible array members in union or

[PATCH v5 1/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-05-01 Thread Qing Zhao
The request for GCC to accept that the C99 flexible array member can be in a union or alone in a structure has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC PR has been opened for such request at that time:

[PATCH v5 0/4]Allow flexible array members in unions and alone in structures [PR53548]

2024-05-01 Thread Qing Zhao
Hi, This is the 5th version for Allow flexible array members in unions and alone in structures [PR53548] (for your reference, the 1st version is at: https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649737.html The 2nd version is at:

Re: [PATCH v4 4/4] Update the C/C++ FE routines

2024-05-01 Thread Qing Zhao
On May 1, 2024, at 09:35, Jason Merrill wrote: On 5/1/24 08:19, Qing Zhao wrote: "add_flexible_array_elts_to_size" and "layout_var_decl" to handle the cases when the DECL is union. Add testing cases to test the _bos for flexible array members in unions or alone

[PATCH v4 2/4] C and C++ FE changes

2024-05-01 Thread Qing Zhao
to support flexible array members in unions and alone in structures. Adjust testcases for flexible array member in union and alone in structure extension. gcc/c/ChangeLog: * c-decl.cc (finish_struct): Change errors to pedwarns for the cases flexible array members in union or

[PATCH v4 4/4] Update the C/C++ FE routines

2024-05-01 Thread Qing Zhao
"add_flexible_array_elts_to_size" and "layout_var_decl" to handle the cases when the DECL is union. Add testing cases to test the _bos for flexible array members in unions or alone in structures. gcc/c/ChangeLog: * c-decl.cc (add_flexible_array_elts_to_size): Handle the cases

[PATCH v4 3/4] Add testing cases for flexible array members in unions and alone in structures.

2024-05-01 Thread Qing Zhao
gcc/testsuite/ChangeLog: * c-c++-common/fam-in-union-alone-in-struct-1.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-2.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-3.c: New testcase. --- .../fam-in-union-alone-in-struct-1.c | 52

[PATCH v4 1/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-05-01 Thread Qing Zhao
The request for GCC to accept that the C99 flexible array member can be in a union or alone in a structure has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC PR has been opened for such request at that time:

[PATCH v4 0/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-05-01 Thread Qing Zhao
Hi, This is the 4th version for Allow flexible array members in unions and alone in structures [PR53548] (for your reference, the 1st version is at: https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649737.html The 2nd version is at:

Re: [PATCH v3 1/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-05-01 Thread Qing Zhao
On Apr 30, 2024, at 17:55, Kees Cook wrote: On Tue, Apr 30, 2024 at 05:51:20PM -0400, Jason Merrill wrote: On 4/30/24 14:45, Qing Zhao wrote: On Apr 30, 2024, at 15:27, Jason Merrill wrote: On 4/30/24 07:58, Qing Zhao wrote: The request for GCC to accept that the C99 flexible array member

Re: [PATCH v3 1/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-04-30 Thread Qing Zhao
> On Apr 30, 2024, at 15:52, Jason Merrill wrote: > > On 4/30/24 14:49, Qing Zhao wrote: >>> On Apr 30, 2024, at 15:45, Qing Zhao wrote: >>> >>> >>> >>>>> gcc/doc/extend.texi | 34 ++ >&g

Re: [PATCH v3 1/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-04-30 Thread Qing Zhao
On Apr 30, 2024, at 15:45, Qing Zhao wrote: gcc/doc/extend.texi | 34 ++ 1 file changed, 34 insertions(+) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 7b54a241a7bf..cba98c8aadd7 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi

Re: [PATCH v3 1/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-04-30 Thread Qing Zhao
On Apr 30, 2024, at 15:27, Jason Merrill wrote: On 4/30/24 07:58, Qing Zhao wrote: The request for GCC to accept that the C99 flexible array member can be in a union or alone in a structure has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC

Re: [PATCH v3 4/4] Update the C FE routine "add_flexible_array_elts_to_size" C++ FE routine "layout_var_decl" to handle the cases when the DECL is union.

2024-04-30 Thread Qing Zhao
On Apr 30, 2024, at 15:29, Jason Merrill wrote: On 4/30/24 07:58, Qing Zhao wrote: Add testing cases to test the _bos for flexible array members in unions or alone in structures. gcc/c/ChangeLog: * c-decl.cc (add_flexible_array_elts_to_size): Handle the cases when the DECL is union. gcc/cp

[PATCH v3 4/4] Update the C FE routine "add_flexible_array_elts_to_size" C++ FE routine "layout_var_decl" to handle the cases when the DECL is union.

2024-04-30 Thread Qing Zhao
Add testing cases to test the _bos for flexible array members in unions or alone in structures. gcc/c/ChangeLog: * c-decl.cc (add_flexible_array_elts_to_size): Handle the cases when the DECL is union. gcc/cp/ChangeLog: * decl.cc (layout_var_decl): Handle the cases when

[PATCH v3 3/4] Add testing cases for flexible array members in unions and alone in structures.

2024-04-30 Thread Qing Zhao
gcc/testsuite/ChangeLog: * c-c++-common/fam-in-union-alone-in-struct-1.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-2.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-3.c: New testcase. --- .../fam-in-union-alone-in-struct-1.c | 52

[PATCH v3 2/4] C and C++ FE changes

2024-04-30 Thread Qing Zhao
to support flexible array members in unions and alone in structures. Adjust testcases for flexible array member in union and alone in structure extension. gcc/c/ChangeLog: * c-decl.cc (finish_struct): Change errors to pedwarns for the cases flexible array members in union or

[PATCH v3 0/4]Allow flexible array members in unions and alone in structures [PR53548]

2024-04-30 Thread Qing Zhao
Hi, This is the 3rd version for Allow flexible array members in unions and alone in structures [PR53548] (for your reference, the 1st version is at: https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649737.html The 2nd version is at:

[PATCH v3 1/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-04-30 Thread Qing Zhao
The request for GCC to accept that the C99 flexible array member can be in a union or alone in a structure has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC PR has been opened for such request at that time:

Re: [PATCH v2 3/3] Add testing cases for flexible array members in unions and alone in structures.

2024-04-25 Thread Qing Zhao
> On Apr 25, 2024, at 10:13, Siddhesh Poyarekar wrote: > > On 2024-04-25 10:06, Qing Zhao wrote: >> gcc/testsuite/ChangeLog: >> * c-c++-common/fam-in-union-alone-in-struct-1.c: New testcase. >> * c-c++-common/fam-in-union-alone-in-struct-2.c: New testcase.

[PATCH v2 3/3] Add testing cases for flexible array members in unions and alone in structures.

2024-04-25 Thread Qing Zhao
gcc/testsuite/ChangeLog: * c-c++-common/fam-in-union-alone-in-struct-1.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-2.c: New testcase. * c-c++-common/fam-in-union-alone-in-struct-3.c: New testcase. --- .../fam-in-union-alone-in-struct-1.c | 52

[PATCH v2 0/3] Allow flexible array members in unions and alone in structures [PR53548]

2024-04-25 Thread Qing Zhao
Hi, This is the 2nd version for Allow flexible array members in unions and alone in structures [PR53548] (for your reference, the 1st version is at: https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649737.html) compared to the 1st version, the major difference are: A. C FE updates based

[PATCH v2 2/3] C and C++ FE changes

2024-04-25 Thread Qing Zhao
to support flexible array members in unions and alone in structures. Adjust testcases for flexible array member in union and alone in structure extension. gcc/c/ChangeLog: * c-decl.cc (finish_struct): Change errors to pedwarns for the cases flexible array members in union or

[PATCH v2 1/3] Allow flexible array members in unions and alone in structures [PR53548]

2024-04-25 Thread Qing Zhao
The request for GCC to accept that the C99 flexible array member can be in a union or alone in a structure has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC PR has been opened for such request at that time:

Re: [RFC][PATCH v1 2/4] C and C++ FE changes to support flexible array members in unions and alone in structures.

2024-04-23 Thread Qing Zhao
> On Apr 23, 2024, at 15:51, Joseph Myers wrote: > > On Fri, 19 Apr 2024, Qing Zhao wrote: > >> gcc/c/ChangeLog: >> >> * c-decl.cc (finish_struct): Change errors to pedwarns for the cases >> flexible array members in union or alone in stru

Re: [PATCH v9 0/5] New attribute "counted_by" to annotate bounds for C99 FAM(PR108896)

2024-04-23 Thread Qing Zhao
024, at 09:54, Qing Zhao wrote: > > Hi, > > This is the 9th version of the patch. > > Compare with the 8th version, the difference are: > > updates per Joseph's comments: > > 1. in C FE, add checking for counted_by attribute for the new multiple > definitions of

Re: [RFC][PATCH v1 3/4] Add testing cases for flexible array members in unions and alone in structures.

2024-04-23 Thread Qing Zhao
> On Apr 23, 2024, at 14:53, Joseph Myers wrote: > > On Fri, 19 Apr 2024, Qing Zhao wrote: > >> gcc/testsuite/ChangeLog: >> >> * gcc.dg/flex-array-in-union-1.c: New test. >> * gcc.dg/flex-array-in-union-2.c: New test. > > Th

Re: [RFC][PATCH v1 1/4] Documentation change

2024-04-23 Thread Qing Zhao
> On Apr 23, 2024, at 15:03, Joseph Myers wrote: > > On Tue, 23 Apr 2024, Qing Zhao wrote: > >> However, I am not very confident on the wording of the doc, is the >> current wording good enough for this? Or do you have any suggestion on >> how to make it

Re: [RFC][PATCH v1 1/4] Documentation change

2024-04-23 Thread Qing Zhao
> On Apr 23, 2024, at 14:04, Joseph Myers wrote: > > On Fri, 19 Apr 2024, Qing Zhao wrote: > >> +The size of the union is as if the flexiable array member were omitted >> +except that it may have more trailing padding than the omission would imply. > > "

Re: [PATCH v9 1/5] Provide counted_by attribute to flexible array member field (PR108896)

2024-04-22 Thread Qing Zhao
Thanks a lot. Qing > On Apr 22, 2024, at 16:38, Joseph Myers wrote: > > This version of patch 1/5 is OK for GCC 15. > > -- > Joseph S. Myers > josmy...@redhat.com >

Re: [RFC][PATCH v1 1/4] Documentation change

2024-04-22 Thread Qing Zhao
> On Apr 19, 2024, at 16:54, Tom Tromey wrote: > >>>>>> Qing Zhao writes: > >> +The size of the union is as if the flexiable array member were omitted >> +except that it may have more trailing padding than the omission would imply. >> + >>

[RFC][PATCH v1 4/4] Adjust testcases for flexible array member in union and alone in structure extension.

2024-04-19 Thread Qing Zhao
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. *

[RFC][PATCH v1 3/4] Add testing cases for flexible array members in unions and alone in structures.

2024-04-19 Thread Qing Zhao
gcc/testsuite/ChangeLog: * gcc.dg/flex-array-in-union-1.c: New test. * gcc.dg/flex-array-in-union-2.c: New test. --- gcc/testsuite/gcc.dg/flex-array-in-union-1.c | 37 + gcc/testsuite/gcc.dg/flex-array-in-union-2.c | 42 2 files changed, 79

[RFC][PATCH v1 1/4] Documentation change

2024-04-19 Thread Qing Zhao
for allow flexible array members in unions and alone in structures [PR53548] The request for GCC to accept that the C99 flexible array member can be in a union or alone in a structure has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC PR has

[RFC][PATCH v1 2/4] C and C++ FE changes to support flexible array members in unions and alone in structures.

2024-04-19 Thread Qing Zhao
gcc/c/ChangeLog: * c-decl.cc (finish_struct): Change errors to pedwarns for the cases flexible array members in union or alone in structures. gcc/cp/ChangeLog: * class.cc (diagnose_flexarrays): Change error to pdewarn for the case flexible array members alone in

[RFC][PATCH v1 0/4] Allow flexible array members in unions and alone in structures [PR53548]

2024-04-19 Thread Qing Zhao
Hi, The request for GCC to accept that the C99 flexible array member can be in a union or alone in a struct has been made a long time ago around 2012 for supporting several practical cases including glibc. A GCC PR has been opened for such request at that time:

[PATCH v9 4/5] Use the .ACCESS_WITH_SIZE in bound sanitizer.

2024-04-12 Thread Qing Zhao
gcc/c-family/ChangeLog: * c-ubsan.cc (get_bound_from_access_with_size): New function. (ubsan_instrument_bounds): Handle call to .ACCESS_WITH_SIZE. gcc/testsuite/ChangeLog: * gcc.dg/ubsan/flex-array-counted-by-bounds-2.c: New test. *

[PATCH v9 3/5] Use the .ACCESS_WITH_SIZE in builtin object size.

2024-04-12 Thread Qing Zhao
gcc/ChangeLog: * tree-object-size.cc (access_with_size_object_size): New function. (call_object_size): Call the new function. gcc/testsuite/ChangeLog: * gcc.dg/builtin-object-size-common.h: Add a new macro EXPECT. * gcc.dg/flex-array-counted-by-3.c: New test.

[PATCH v9 5/5] Add the 6th argument to .ACCESS_WITH_SIZE

2024-04-12 Thread Qing Zhao
to carry the TYPE of the flexible array. Such information is needed during tree-object-size.cc. We cannot use the result type or the type of the 1st argument of the routine .ACCESS_WITH_SIZE to decide the element type of the original array due to possible type casting in the source code.

[PATCH v9 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.

2024-04-12 Thread Qing Zhao
Including the following changes: * The definition of the new internal function .ACCESS_WITH_SIZE in internal-fn.def. * C FE converts every reference to a FAM with a "counted_by" attribute to a call to the internal function .ACCESS_WITH_SIZE. (build_component_ref in c_typeck.cc) This

[PATCH v9 1/5] Provide counted_by attribute to flexible array member field (PR108896)

2024-04-12 Thread Qing Zhao
'counted_by (COUNT)' The 'counted_by' attribute may be attached to the C99 flexible array member of a structure. It indicates that the number of the elements of the array is given by the field "COUNT" in the same structure as the flexible array member. GCC may use this

[PATCH v9 0/5] New attribute "counted_by" to annotate bounds for C99 FAM(PR108896)

2024-04-12 Thread Qing Zhao
Hi, This is the 9th version of the patch. Compare with the 8th version, the difference are: updates per Joseph's comments: 1. in C FE, add checking for counted_by attribute for the new multiple definitions of the same tag for C23 in the routine "tagged_types_tu_compatible_p". Add a new

Re: [PATCH v8 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.

2024-04-11 Thread Qing Zhao
Sid and Richard, The C FE changes in this patch has been approved by Joseph. Could you please review the Middle-end change? thanks. Qing > On Apr 10, 2024, at 14:36, Joseph Myers wrote: > > On Fri, 29 Mar 2024, Qing Zhao wrote: > >> +/* For a SUBDATUM field of a struct

Re: [PATCH v8 5/5] Add the 6th argument to .ACCESS_WITH_SIZE

2024-04-11 Thread Qing Zhao
Sid, Thanks a lot for your review. Richard, Could you please comment on this patch? Is the middle-end part Okay for stage 1? Thanks. Qing On Apr 10, 2024, at 17:48, Siddhesh Poyarekar wrote: On 2024-03-29 12:07, Qing Zhao wrote: to carry the TYPE of the flexible array. Such information

Re: [PATCH v8 4/5] Use the .ACCESS_WITH_SIZE in bound sanitizer.

2024-04-11 Thread Qing Zhao
Sid, Thanks a lot for the review. > On Apr 10, 2024, at 17:46, Siddhesh Poyarekar wrote: > > On 2024-03-29 12:07, Qing Zhao wrote: >> gcc/c-family/ChangeLog: >> * c-ubsan.cc (get_bound_from_access_with_size): New function. >> (ubsan_inst

Re: [PATCH v8 3/5] Use the .ACCESS_WITH_SIZE in builtin object size.

2024-04-11 Thread Qing Zhao
Sid, Thanks a lot for your review! > On Apr 10, 2024, at 17:45, Siddhesh Poyarekar wrote: > > On 2024-03-29 12:07, Qing Zhao wrote: >> gcc/ChangeLog: >> * tree-object-size.cc (access_with_size_object_size): New function. >> (call_object_size): Call the new

Re: [PATCH v8 1/5] Provide counted_by attribute to flexible array member field (PR108896)

2024-04-11 Thread Qing Zhao
> On Apr 10, 2024, at 17:56, Joseph Myers wrote: > > On Wed, 10 Apr 2024, Qing Zhao wrote: > >> Okay, the above is very clear, thanks a lot for the explanation. >> So, basically, for “counted-by” attribute: >> **The following is good: >> struc

Re: [PATCH v8 1/5] Provide counted_by attribute to flexible array member field (PR108896)

2024-04-11 Thread Qing Zhao
> On Apr 11, 2024, at 02:02, Martin Uecker wrote: > > Am Mittwoch, dem 10.04.2024 um 19:35 + schrieb Qing Zhao: >> >>> On Apr 10, 2024, at 15:05, Martin Uecker wrote: >>> >>> Am Mittwoch, dem 10.04.2024 um 20:25 +0200 schrieb Martin Uecker:

Re: [PATCH v8 2/5] Convert references with "counted_by" attributes to/from .ACCESS_WITH_SIZE.

2024-04-10 Thread Qing Zhao
Thanks a lot for your review. Will fix these typos before committing to GCC15. Qing > On Apr 10, 2024, at 14:36, Joseph Myers wrote: > > On Fri, 29 Mar 2024, Qing Zhao wrote: > >> +/* For a SUBDATUM field of a structure or union DATUM, generate a REF to >> + the ob

  1   2   3   4   5   6   7   8   9   10   >