aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/doc/gty.texi11
-rw-r--r--libcpp/include/symtab.h4
2 files changed, 12 insertions, 3 deletions
diff --git a/gcc/doc/gty.texi b/gcc/doc/gty.texi
index 7bd064b..15f9fa0 100644
--- a/gcc/doc/gty.texi
+++ b/gcc/doc/gty.texi
@@ -217,6 +217,17 @@ struct GTY(()) non_terminated_string @{
@};
@end smallexample
+Similarly, this is useful for (regular NUL-terminated) strings with
+NUL characters embedded (that the default @code{strlen} use would run
+afoul of):
+
+@smallexample
+struct GTY(()) multi_string @{
+ const char * GTY((string_length ("%h.len + 1"))) str;
+ size_t len;
+@};
+@end smallexample
+
The @code{string_length} option currently is not supported for (fields
in) global variables.
@c <https://inbox.sourceware.org/87bkgqvlst.fsf@euler.schwinge.homeip.net>
diff --git a/libcpp/include/symtab.h b/libcpp/include/symtab.h
index c7ccc6d..0c713f2 100644
--- a/libcpp/include/symtab.h
+++ b/libcpp/include/symtab.h
@@ -29,9 +29,7 @@ along with this program; see the file COPYING3. If not see
typedef struct ht_identifier ht_identifier;
typedef struct ht_identifier *ht_identifier_ptr;
struct GTY(()) ht_identifier {
- /* This GTY markup arranges that the null-terminated identifier would still
- stream to PCH correctly, if a null byte were to make its way into an
- identifier somehow. */
+ /* We know the 'len'gth of the 'str'ing; use it in the GTY markup. */
const unsigned char * GTY((string_length ("1 + %h.len"))) str;
unsigned int len;
unsigned int hash_value;