public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] c: Implement newer __intcap builtin type
@ 2021-09-21 9:14 Matthew Malcomson
0 siblings, 0 replies; only message in thread
From: Matthew Malcomson @ 2021-09-21 9:14 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:c295b3fe0becede39d22df877ad828a6e743477f
commit c295b3fe0becede39d22df877ad828a6e743477f
Author: Alex Coplan <alex.coplan@arm.com>
Date: Mon Sep 20 16:39:35 2021 +0100
c: Implement newer __intcap builtin type
Previously we implemented __intcap_t and __uintcap_t as builtin types.
These days the preferred names for these are signed __intcap and
unsigned __intcap, with __intcap being the only reserved word and the _t
versions being typedefs. This patch makes that change to the C
frontend.
gcc/c-family/ChangeLog:
* c-common.c (c_common_reswords): Remove RID_UINTCAP, adjust
RID_INTCAP to reserve __intcap instead of __intcap_t.
(c_common_nodes_and_builtins): Remove RID_UINTCAP as a built-in
type, register __intcap_t and __uintcap_t as typedefs.
* c-common.h (enum rid): Delete RID_UINTCAP.
gcc/c/ChangeLog:
* c-decl.c (declspecs_add_type): Remove RID_UINTCAP handling,
tweak RID_INTCAP handling: adjust error messages and permit
signed/unsigned keywords in combination with __intcap.
(finish_declspecs): Remove cts_uintcap handling, adjust
cts_intcap handling to dispatch on unsigned_p to choose the
correct type node.
* c-parser.c (c_keyword_starts_typename): Remove RID_UINTCAP
handling.
(c_token_starts_declspecs): Likewise.
(c_parser_declspecs): Likewise.
(c_parser_gnu_attribute_any_word): Likewise.
(c_parser_objc_selector): Likewise.
* c-tree.h (enum c_typespec_keyword): Remove cts_uintcap.
gcc/testsuite/ChangeLog:
* gcc.dg/pr26865.c: __intcap_t -> __intcap
* gcc.dg/spec-barrier-3.c: Likewise.
* gcc.dg/intcap-not-supported.c: Likewise.
Diff:
---
gcc/c-family/c-common.c | 7 +--
gcc/c-family/c-common.h | 2 +-
gcc/c/c-decl.c | 73 ++++-------------------------
gcc/c/c-parser.c | 5 --
gcc/c/c-tree.h | 4 +-
gcc/testsuite/gcc.dg/intcap-not-supported.c | 12 ++---
gcc/testsuite/gcc.dg/pr26865.c | 4 +-
gcc/testsuite/gcc.dg/spec-barrier-3.c | 2 +-
8 files changed, 25 insertions(+), 84 deletions(-)
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index d02d944b879..7f8e01aa57d 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -409,7 +409,7 @@ const struct c_common_resword c_common_reswords[] =
{ "__imag__", RID_IMAGPART, 0 },
{ "__inline", RID_INLINE, 0 },
{ "__inline__", RID_INLINE, 0 },
- { "__intcap_t", RID_INTCAP, 0 },
+ { "__intcap", RID_INTCAP, 0 },
{ "__is_abstract", RID_IS_ABSTRACT, D_CXXONLY },
{ "__is_aggregate", RID_IS_AGGREGATE, D_CXXONLY },
{ "__is_base_of", RID_IS_BASE_OF, D_CXXONLY },
@@ -442,7 +442,6 @@ const struct c_common_resword c_common_reswords[] =
{ "__transaction_cancel", RID_TRANSACTION_CANCEL, 0 },
{ "__typeof", RID_TYPEOF, 0 },
{ "__typeof__", RID_TYPEOF, 0 },
- { "__uintcap_t", RID_UINTCAP, 0 },
{ "__underlying_type", RID_UNDERLYING_TYPE, D_CXXONLY },
{ "__volatile", RID_VOLATILE, 0 },
{ "__volatile__", RID_VOLATILE, 0 },
@@ -4117,10 +4116,12 @@ c_common_nodes_and_builtins (void)
record_builtin_type (RID_MAX, "long unsigned int",
long_unsigned_type_node);
+ gcc_assert (!intcap_type_node == !uintcap_type_node);
if (intcap_type_node)
{
record_builtin_type (RID_INTCAP, NULL, intcap_type_node);
- record_builtin_type (RID_UINTCAP, NULL, uintcap_type_node);
+ lang_hooks.types.register_builtin_type (intcap_type_node, "__intcap_t");
+ lang_hooks.types.register_builtin_type (uintcap_type_node, "__uintcap_t");
}
for (i = 0; i < NUM_INT_N_ENTS; i ++)
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index fedaede361d..363f8d5bc77 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -96,7 +96,7 @@ enum rid
RID_ENUM, RID_STRUCT, RID_UNION, RID_IF, RID_ELSE,
RID_WHILE, RID_DO, RID_FOR, RID_SWITCH, RID_CASE,
RID_DEFAULT, RID_BREAK, RID_CONTINUE, RID_RETURN, RID_GOTO,
- RID_SIZEOF, RID_INTCAP, RID_UINTCAP,
+ RID_SIZEOF, RID_INTCAP,
/* C extensions */
RID_ASM, RID_TYPEOF, RID_ALIGNOF, RID_ATTRIBUTE, RID_VA_ARG,
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index e8827c3fea9..e45f7c054f2 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -11151,32 +11151,24 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs,
case RID_INTCAP:
if (specs->long_p)
error_at (loc,
- ("both %<long%> and %<__intcap_t%> in "
+ ("both %<long%> and %<__intcap%> in "
"declaration specifiers"));
else if (specs->short_p)
error_at (loc,
- ("both %<short%> and %<__intcap_t%> in "
- "declaration specifiers"));
- else if (specs->signed_p)
- error_at (loc,
- ("both %<signed%> and %<__intcap_t%> in "
- "declaration specifiers"));
- else if (specs->unsigned_p)
- error_at (loc,
- ("both %<unsigned%> and %<__intcap_t%> in "
+ ("both %<short%> and %<__intcap%> in "
"declaration specifiers"));
else if (specs->complex_p)
error_at (loc,
- ("both %<complex%> and %<__intcap_t%> in "
+ ("both %<complex%> and %<__intcap%> in "
"declaration specifiers"));
else if (specs->saturating_p)
error_at (loc,
- ("both %<_Sat%> and %<__intcap_t%> in "
+ ("both %<_Sat%> and %<__intcap%> in "
"declaration specifiers"));
else if (intcap_type_node == NULL_TREE)
{
error_at (loc,
- "%<__intcap_t%> is not supported on this target");
+ "%<__intcap%> is not supported on this target");
specs->typespec_word = cts_intcap;
}
else
@@ -11185,43 +11177,6 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs,
specs->locations[cdw_typespec] = loc;
}
return specs;
- case RID_UINTCAP:
- if (specs->long_p)
- error_at (loc,
- ("both %<long%> and %<__uintcap_t%> in "
- "declaration specifiers"));
- else if (specs->short_p)
- error_at (loc,
- ("both %<short%> and %<__uintcap_t%> in "
- "declaration specifiers"));
- else if (specs->signed_p)
- error_at (loc,
- ("both %<signed%> and %<__uintcap_t%> in "
- "declaration specifiers"));
- else if (specs->unsigned_p)
- error_at (loc,
- ("both %<unsigned%> and %<__uintcap_t%> in "
- "declaration specifiers"));
- else if (specs->complex_p)
- error_at (loc,
- ("both %<complex%> and %<__uintcap_t%> in "
- "declaration specifiers"));
- else if (specs->saturating_p)
- error_at (loc,
- ("both %<_Sat%> and %<__uintcap_t%> in "
- "declaration specifiers"));
- else if (uintcap_type_node == NULL_TREE)
- {
- error_at (loc,
- "%<__uintcap_t%> is not supported on this target");
- specs->typespec_word = cts_uintcap;
- }
- else
- {
- specs->typespec_word = cts_uintcap;
- specs->locations[cdw_typespec] = loc;
- }
- return specs;
case RID_FLOAT:
if (specs->long_p)
error_at (loc,
@@ -11810,22 +11765,14 @@ finish_declspecs (struct c_declspecs *specs)
}
break;
case cts_intcap:
- gcc_assert (!specs->long_p && !specs->short_p
- && !specs->signed_p && !specs->unsigned_p
- && !specs->complex_p);
+ gcc_assert (!specs->long_p && !specs->short_p && !specs->complex_p);
+ gcc_assert (!(specs->signed_p && specs->unsigned_p));
+ gcc_assert (!intcap_type_node == !uintcap_type_node);
if (intcap_type_node == NULL_TREE)
specs->type = integer_type_node;
else
- specs->type = intcap_type_node;
- break;
- case cts_uintcap:
- gcc_assert (!specs->long_p && !specs->short_p
- && !specs->signed_p && !specs->unsigned_p
- && !specs->complex_p);
- if (uintcap_type_node == NULL_TREE)
- specs->type = integer_type_node;
- else
- specs->type = uintcap_type_node;
+ specs->type = (specs->unsigned_p
+ ? uintcap_type_node : intcap_type_node);
break;
case cts_float:
gcc_assert (!specs->long_p && !specs->short_p
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index bba964dfd96..8523c1b3b0c 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -556,7 +556,6 @@ c_keyword_starts_typename (enum rid keyword)
case RID_COMPLEX:
case RID_INT:
case RID_INTCAP:
- case RID_UINTCAP:
case RID_CHAR:
case RID_FLOAT:
case RID_DOUBLE:
@@ -735,7 +734,6 @@ c_token_starts_declspecs (c_token *token)
case RID_COMPLEX:
case RID_INT:
case RID_INTCAP:
- case RID_UINTCAP:
case RID_CHAR:
case RID_FLOAT:
case RID_DOUBLE:
@@ -2957,7 +2955,6 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
case RID_COMPLEX:
case RID_INT:
case RID_INTCAP:
- case RID_UINTCAP:
case RID_CHAR:
case RID_FLOAT:
case RID_DOUBLE:
@@ -4544,7 +4541,6 @@ c_parser_gnu_attribute_any_word (c_parser *parser)
case RID_THREAD:
case RID_INT:
case RID_INTCAP:
- case RID_UINTCAP:
case RID_CHERI_CAPABILITY:
case RID_CHAR:
case RID_FLOAT:
@@ -11818,7 +11814,6 @@ c_parser_objc_selector (c_parser *parser)
case RID_ONEWAY:
case RID_INT:
case RID_INTCAP:
- case RID_UINTCAP:
case RID_CHAR:
case RID_FLOAT:
case RID_DOUBLE:
diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h
index 60105e69ac7..cf428ba0be0 100644
--- a/gcc/c/c-tree.h
+++ b/gcc/c/c-tree.h
@@ -237,8 +237,7 @@ enum c_storage_class {
/* A type specifier keyword "void", "_Bool", "char", "int", "float",
"double", "_Decimal32", "_Decimal64", "_Decimal128", "_Fract", "_Accum",
- "__intcap_t", "__uintcap_t",
- or none of these. */
+ "__intcap", or none of these. */
enum c_typespec_keyword {
cts_none,
cts_void,
@@ -246,7 +245,6 @@ enum c_typespec_keyword {
cts_char,
cts_int,
cts_intcap,
- cts_uintcap,
cts_float,
cts_int_n,
cts_double,
diff --git a/gcc/testsuite/gcc.dg/intcap-not-supported.c b/gcc/testsuite/gcc.dg/intcap-not-supported.c
index fb87a9c8249..133eb436160 100644
--- a/gcc/testsuite/gcc.dg/intcap-not-supported.c
+++ b/gcc/testsuite/gcc.dg/intcap-not-supported.c
@@ -1,8 +1,8 @@
/* { dg-do compile } */
/* { dg-skip-if "skip if capabilities are enabled" { aarch64_capability_any } } */
-__intcap_t c1; /* { dg-error {not supported on this target} } */
-__uintcap_t c2; /* { dg-error {not supported on this target} } */
-__intcap_t f1(void) {} /* { dg-error {not supported on this target} } */
-void f2(__intcap_t x) {} /* { dg-error {not supported on this target} } */
-__uintcap_t f3(void) {} /* { dg-error {not supported on this target} } */
-void f4(__uintcap_t y) {} /* { dg-error {not supported on this target} } */
+__intcap c1; /* { dg-error {not supported on this target} } */
+unsigned __intcap c2; /* { dg-error {not supported on this target} } */
+__intcap f1(void) {} /* { dg-error {not supported on this target} } */
+void f2(__intcap x) {} /* { dg-error {not supported on this target} } */
+unsigned __intcap f3(void) {} /* { dg-error {not supported on this target} } */
+void f4(unsigned __intcap y) {} /* { dg-error {not supported on this target} } */
diff --git a/gcc/testsuite/gcc.dg/pr26865.c b/gcc/testsuite/gcc.dg/pr26865.c
index 23056bbb890..a69748bbb95 100644
--- a/gcc/testsuite/gcc.dg/pr26865.c
+++ b/gcc/testsuite/gcc.dg/pr26865.c
@@ -5,8 +5,8 @@ void
foo (void)
{
#ifdef __GCC_ARM_CAPABILITY_ANY
- char *e = (__intcap_t) alloca (100); /* { dg-warning "implicit declaration" "" { target { aarch64_capability_any } } } */
- /* { dg-warning "initialization of '.*' from '__intcap_t' makes pointer from integer without a cast" "" { target { aarch64_capability_any } } .-1 } */
+ char *e = (__intcap) alloca (100); /* { dg-warning "implicit declaration" "" { target { aarch64_capability_any } } } */
+ /* { dg-warning "initialization of '.*' from '__intcap' makes pointer from integer without a cast" "" { target { aarch64_capability_any } } .-1 } */
#else
char *e = alloca (100); /* { dg-warning "implicit declaration|initialization of 'char \\*' from 'int' makes" "" { target { ! aarch64_capability_any } } } */
#endif
diff --git a/gcc/testsuite/gcc.dg/spec-barrier-3.c b/gcc/testsuite/gcc.dg/spec-barrier-3.c
index 6226d7f1dda..d082eb53ccf 100644
--- a/gcc/testsuite/gcc.dg/spec-barrier-3.c
+++ b/gcc/testsuite/gcc.dg/spec-barrier-3.c
@@ -8,7 +8,7 @@ int *
f (int x)
{
#ifdef __GCC_ARM_CAPABILITY_ANY
- return (__intcap_t) __builtin_speculation_safe_value (x); /* { dg-warning "returning '__intcap_t' from a function with return type 'int \\*' makes pointer from integer without a cast" "" { target { aarch64_capability_any } } } */
+ return (__intcap) __builtin_speculation_safe_value (x); /* { dg-warning "returning '__intcap' from a function with return type 'int \\*' makes pointer from integer without a cast" "" { target { aarch64_capability_any } } } */
#else
return __builtin_speculation_safe_value (x); /* { dg-warning "returning 'int' from a function with return type 'int \\*' makes pointer from integer without a cast" "" { target { ! aarch64_capability_any } } } */
#endif
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-09-21 9:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-21 9:14 [gcc(refs/vendors/ARM/heads/morello)] c: Implement newer __intcap builtin type Matthew Malcomson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).