Add pg_attribute_counted_by()
The counted_by attribute allows specifying that a flexible array
member of a struct is "counted by" another member of the same struct.
The attribute makes arrays a little more self-documenting, but it is
also a hint to the compiler such that it can improve detection of
object size information and provide better results in compile-time
diagnostics and run-time features, such as the array bounds sanitizer.
Both GCC and clang warn when the attribute is used in C++, where it is
ignored, so define it away there.
In its current form, it is best used for flexible array members only.
Pointer array support may come later on.
This commit only contains a single use of the attribute for testing.
More will be added afterwards.
Author: Tristan Partin <tristan@partin.io>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Japin Li <japinli@hotmail.com>
Reviewed-by: Greg Burd <greg@burd.me>
Discussion: https://www.postgresql.org/message-id/flat/DKBEBF32QLUA.3L2DJRPUYNKHZ%40partin.io
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/a936ebd9f9f64b0efb853195d8dcdb8a0453537d
Modified Files
--------------
src/backend/utils/adt/jsonfuncs.c | 2 +-
src/include/c.h | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)