[gcc(refs/vendors/ARM/heads/morello)] cp: Base __intcap support: parsing, mangling, and diagnostics
Matthew Malcomson
matmal01@gcc.gnu.org
Mon Mar 14 10:34:52 GMT 2022
https://gcc.gnu.org/g:7fb73dcc84fc3a9fffa03620a4ecc6382d4c6efb
commit 7fb73dcc84fc3a9fffa03620a4ecc6382d4c6efb
Author: Alex Coplan <alex.coplan@arm.com>
Date: Mon Jan 31 16:50:56 2022 +0000
cp: Base __intcap support: parsing, mangling, and diagnostics
This adds the base support to the C++ frontend for parsing and mangling
__intcap types. The changes to the dump_* functions are neded for
diagnostics involving intcaps.
The mangling follows that used by CHERI LLVM.
gcc/cp/ChangeLog:
* decl.c (grokdeclarator): Handle __intcap.
* error.c (dump_type): Handle INTCAP_TYPE.
(dump_type_prefix): Likewise.
(dump_type_suffix): Likewise.
* mangle.c (write_type): Likewise.
(write_builtin_type): Likewise.
* parser.c (cp_keyword_starts_decl_specifier_p): Likewise.
(cp_parser_simple_type_specifier): Likewise.
Diff:
---
gcc/cp/decl.c | 11 +++++++----
gcc/cp/error.c | 3 +++
gcc/cp/mangle.c | 10 ++++++++++
gcc/cp/parser.c | 6 ++++++
4 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index d1af63e7300..fc88567a3cf 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -11552,15 +11552,16 @@ grokdeclarator (const cp_declarator *declarator,
richloc.add_range (declspecs->locations[ds_short]);
error_at (&richloc, "%<long%> and %<short%> specified together");
}
- else if (TREE_CODE (type) != INTEGER_TYPE
+ else if ((TREE_CODE (type) != INTEGER_TYPE && !INTCAP_TYPE_P (type))
|| type == char8_type_node
|| type == char16_type_node
|| type == char32_type_node
|| ((long_p || short_p)
- && (explicit_char || explicit_intN)))
+ && (explicit_char || explicit_intN || INTCAP_TYPE_P (type))))
error_at (loc, "%qs specified with %qT", key, type);
else if (!explicit_int && !defaulted_int
- && !explicit_char && !explicit_intN)
+ && !explicit_char && !explicit_intN
+ && !INTCAP_TYPE_P (type))
{
if (typedef_decl)
{
@@ -11608,7 +11609,9 @@ grokdeclarator (const cp_declarator *declarator,
&& TREE_CODE (type) == INTEGER_TYPE
&& !same_type_p (TYPE_MAIN_VARIANT (type), wchar_type_node)))
{
- if (explicit_intN)
+ if (type == intcap_type_node)
+ type = uintcap_type_node;
+ else if (explicit_intN)
type = int_n_trees[declspecs->int_n_idx].unsigned_type;
else if (longlong)
type = long_long_unsigned_type_node;
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index ecb41e82d8c..6c137b30d94 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -527,6 +527,7 @@ dump_type (cxx_pretty_printer *pp, tree t, int flags)
break;
case INTEGER_TYPE:
+ case INTCAP_TYPE:
case REAL_TYPE:
case VOID_TYPE:
case BOOLEAN_TYPE:
@@ -862,6 +863,7 @@ dump_type_prefix (cxx_pretty_printer *pp, tree t, int flags)
case ENUMERAL_TYPE:
case IDENTIFIER_NODE:
case INTEGER_TYPE:
+ case INTCAP_TYPE:
case BOOLEAN_TYPE:
case REAL_TYPE:
case RECORD_TYPE:
@@ -982,6 +984,7 @@ dump_type_suffix (cxx_pretty_printer *pp, tree t, int flags)
case ENUMERAL_TYPE:
case IDENTIFIER_NODE:
case INTEGER_TYPE:
+ case INTCAP_TYPE:
case BOOLEAN_TYPE:
case REAL_TYPE:
case RECORD_TYPE:
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index 9fd30011288..c5fab5057dd 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -2122,6 +2122,7 @@ write_type (tree type)
case VOID_TYPE:
case BOOLEAN_TYPE:
case INTEGER_TYPE: /* Includes wchar_t. */
+ case INTCAP_TYPE:
case REAL_TYPE:
case FIXED_POINT_TYPE:
{
@@ -2541,6 +2542,15 @@ write_builtin_type (tree type)
}
break;
+ case INTCAP_TYPE:
+ {
+ write_char ('u');
+ const char *s = TYPE_UNSIGNED (type) ? "__uintcap_t" : "__intcap_t";
+ write_unsigned_number (strlen (s));
+ write_string (s);
+ }
+ break;
+
case REAL_TYPE:
if (type == float_type_node)
write_char ('f');
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 7cc2dbed5fe..525a0a27c19 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -1016,6 +1016,7 @@ cp_keyword_starts_decl_specifier_p (enum rid keyword)
case RID_FLOAT:
case RID_DOUBLE:
case RID_VOID:
+ case RID_INTCAP:
/* GNU extensions. */
case RID_ATTRIBUTE:
case RID_TYPEOF:
@@ -18009,6 +18010,11 @@ cp_parser_simple_type_specifier (cp_parser* parser,
}
type = int_n_trees [idx].signed_type;
break;
+ case RID_INTCAP:
+ if (!intcap_type_node)
+ break;
+ type = intcap_type_node;
+ break;
case RID_LONG:
if (decl_specs)
set_and_check_decl_spec_loc (decl_specs, ds_long, token);
More information about the Gcc-cvs
mailing list