aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog15
-rw-r--r--gcc/c/c-decl.c69
-rw-r--r--gcc/c/c-parser.c37
-rw-r--r--gcc/c/c-tree.h4
4 files changed, 90 insertions, 35 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index b4cc40a..690c315 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,18 @@
+2014-10-14 DJ Delorie <dj@redhat.com>
+
+ * c-parser.c (c_parse_init): Add RID entries for each __intN.
+ (c_token_starts_typename): Check all __intN, not just __int128.
+ (c_token_starts_declspecs): Likewise.
+ (c_parser_declspecs): Likewise.
+ (c_parser_attribute_any_word): Likewise.
+ (c_parser_objc_selector): Likewise.
+ * c-tree.h (c_typespec_keyword): cts_int128 -> cts_int_n.
+ (struct c_declspecs): Add int_n_idx field to record *which* __intN
+ is specified.
+ * c-decl.c (declspecs_add_type): Check for all __intN, not just
+ __int128.
+ (finish_declspecs): Likewise.
+
2014-10-13 Anthony Brandon <anthony.brandon@gmail.com>
* c-parser.c (c_parser_all_labels): New function to replace
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index e23284a..2900c71 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -9369,10 +9369,11 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs,
error_at (loc,
("both %<long%> and %<void%> in "
"declaration specifiers"));
- else if (specs->typespec_word == cts_int128)
+ else if (specs->typespec_word == cts_int_n)
error_at (loc,
- ("both %<long%> and %<__int128%> in "
- "declaration specifiers"));
+ ("both %<long%> and %<__int%d%> in "
+ "declaration specifiers"),
+ int_n_data[specs->int_n_idx].bitsize);
else if (specs->typespec_word == cts_bool)
error_at (loc,
("both %<long%> and %<_Bool%> in "
@@ -9417,10 +9418,11 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs,
error_at (loc,
("both %<short%> and %<void%> in "
"declaration specifiers"));
- else if (specs->typespec_word == cts_int128)
+ else if (specs->typespec_word == cts_int_n)
error_at (loc,
- ("both %<short%> and %<__int128%> in "
- "declaration specifiers"));
+ ("both %<short%> and %<__int%d%> in "
+ "declaration specifiers"),
+ int_n_data[specs->int_n_idx].bitsize);
else if (specs->typespec_word == cts_bool)
error_at (loc,
("both %<short%> and %<_Bool%> in "
@@ -9594,11 +9596,12 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs,
dupe = specs->saturating_p;
pedwarn (loc, OPT_Wpedantic,
"ISO C does not support saturating types");
- if (specs->typespec_word == cts_int128)
+ if (specs->typespec_word == cts_int_n)
{
error_at (loc,
- ("both %<_Sat%> and %<__int128%> in "
- "declaration specifiers"));
+ ("both %<_Sat%> and %<__int%d%> in "
+ "declaration specifiers"),
+ int_n_data[specs->int_n_idx].bitsize);
}
else if (specs->typespec_word == cts_auto_type)
error_at (loc,
@@ -9662,7 +9665,7 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs,
else
{
/* "void", "_Bool", "char", "int", "float", "double", "_Decimal32",
- "__int128", "_Decimal64", "_Decimal128", "_Fract", "_Accum" or
+ "__intN", "_Decimal64", "_Decimal128", "_Fract", "_Accum" or
"__auto_type". */
if (specs->typespec_word != cts_none)
{
@@ -9703,31 +9706,41 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs,
specs->locations[cdw_typespec] = loc;
}
return specs;
- case RID_INT128:
- if (int128_integer_type_node == NULL_TREE)
- {
- error_at (loc, "%<__int128%> is not supported for this target");
- return specs;
- }
- if (!in_system_header_at (input_location))
+ case RID_INT_N_0:
+ case RID_INT_N_1:
+ case RID_INT_N_2:
+ case RID_INT_N_3:
+ specs->int_n_idx = i - RID_INT_N_0;
+ if (!in_system_header_at (input_location)
+ /* As a special exception, allow a type that's used
+ for __SIZE_TYPE__. */
+ && int_n_data[specs->int_n_idx].bitsize != POINTER_SIZE)
pedwarn (loc, OPT_Wpedantic,
- "ISO C does not support %<__int128%> type");
+ "ISO C does not support %<__int%d%> types",
+ int_n_data[specs->int_n_idx].bitsize);
if (specs->long_p)
error_at (loc,
- ("both %<__int128%> and %<long%> in "
- "declaration specifiers"));
+ ("both %<__int%d%> and %<long%> in "
+ "declaration specifiers"),
+ int_n_data[specs->int_n_idx].bitsize);
else if (specs->saturating_p)
error_at (loc,
- ("both %<_Sat%> and %<__int128%> in "
- "declaration specifiers"));
+ ("both %<_Sat%> and %<__int%d%> in "
+ "declaration specifiers"),
+ int_n_data[specs->int_n_idx].bitsize);
else if (specs->short_p)
error_at (loc,
- ("both %<__int128%> and %<short%> in "
- "declaration specifiers"));
+ ("both %<__int%d%> and %<short%> in "
+ "declaration specifiers"),
+ int_n_data[specs->int_n_idx].bitsize);
+ else if (! int_n_enabled_p [specs->int_n_idx])
+ error_at (loc,
+ "%<__int%d%> is not supported on this target",
+ int_n_data[specs->int_n_idx].bitsize);
else
{
- specs->typespec_word = cts_int128;
+ specs->typespec_word = cts_int_n;
specs->locations[cdw_typespec] = loc;
}
return specs;
@@ -10295,12 +10308,12 @@ finish_declspecs (struct c_declspecs *specs)
specs->type = build_complex_type (specs->type);
}
break;
- case cts_int128:
+ case cts_int_n:
gcc_assert (!specs->long_p && !specs->short_p && !specs->long_long_p);
gcc_assert (!(specs->signed_p && specs->unsigned_p));
specs->type = (specs->unsigned_p
- ? int128_unsigned_type_node
- : int128_integer_type_node);
+ ? int_n_trees[specs->int_n_idx].unsigned_type
+ : int_n_trees[specs->int_n_idx].signed_type);
if (specs->complex_p)
{
pedwarn (specs->locations[cdw_complex], OPT_Wpedantic,
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 346448a..fa146de 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -113,6 +113,16 @@ c_parse_init (void)
C_IS_RESERVED_WORD (id) = 1;
ridpointers [(int) c_common_reswords[i].rid] = id;
}
+
+ for (i = 0; i < NUM_INT_N_ENTS; i++)
+ {
+ /* We always create the symbols but they aren't always supported. */
+ char name[50];
+ sprintf (name, "__int%d", int_n_data[i].bitsize);
+ id = get_identifier (xstrdup (name));
+ C_SET_RID_CODE (id, RID_FIRST_INT_N + i);
+ C_IS_RESERVED_WORD (id) = 1;
+ }
}
/* The C lexer intermediates between the lexer in cpplib and c-lex.c
@@ -483,7 +493,6 @@ c_token_starts_typename (c_token *token)
{
case RID_UNSIGNED:
case RID_LONG:
- case RID_INT128:
case RID_SHORT:
case RID_SIGNED:
case RID_COMPLEX:
@@ -511,6 +520,10 @@ c_token_starts_typename (c_token *token)
case RID_AUTO_TYPE:
return true;
default:
+ if (token->keyword >= RID_FIRST_INT_N
+ && token->keyword < RID_FIRST_INT_N + NUM_INT_N_ENTS
+ && int_n_enabled_p[token->keyword - RID_FIRST_INT_N])
+ return true;
return false;
}
case CPP_LESS:
@@ -641,7 +654,6 @@ c_token_starts_declspecs (c_token *token)
case RID_THREAD:
case RID_UNSIGNED:
case RID_LONG:
- case RID_INT128:
case RID_SHORT:
case RID_SIGNED:
case RID_COMPLEX:
@@ -670,6 +682,10 @@ c_token_starts_declspecs (c_token *token)
case RID_AUTO_TYPE:
return true;
default:
+ if (token->keyword >= RID_FIRST_INT_N
+ && token->keyword < RID_FIRST_INT_N + NUM_INT_N_ENTS
+ && int_n_enabled_p[token->keyword - RID_FIRST_INT_N])
+ return true;
return false;
}
case CPP_LESS:
@@ -2158,7 +2174,7 @@ c_parser_static_assert_declaration_no_semi (c_parser *parser)
type-specifier:
typeof-specifier
__auto_type
- __int128
+ __intN
_Decimal32
_Decimal64
_Decimal128
@@ -2312,7 +2328,6 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
/* Fall through. */
case RID_UNSIGNED:
case RID_LONG:
- case RID_INT128:
case RID_SHORT:
case RID_SIGNED:
case RID_COMPLEX:
@@ -2328,6 +2343,10 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs,
case RID_FRACT:
case RID_ACCUM:
case RID_SAT:
+ case RID_INT_N_0:
+ case RID_INT_N_1:
+ case RID_INT_N_2:
+ case RID_INT_N_3:
if (!typespec_ok)
goto out;
attrs_ok = true;
@@ -3738,7 +3757,6 @@ c_parser_attribute_any_word (c_parser *parser)
case RID_STATIC:
case RID_UNSIGNED:
case RID_LONG:
- case RID_INT128:
case RID_CONST:
case RID_EXTERN:
case RID_REGISTER:
@@ -3768,6 +3786,10 @@ c_parser_attribute_any_word (c_parser *parser)
case RID_TRANSACTION_CANCEL:
case RID_ATOMIC:
case RID_AUTO_TYPE:
+ case RID_INT_N_0:
+ case RID_INT_N_1:
+ case RID_INT_N_2:
+ case RID_INT_N_3:
ok = true;
break;
default:
@@ -8992,7 +9014,6 @@ c_parser_objc_selector (c_parser *parser)
case RID_ALIGNOF:
case RID_UNSIGNED:
case RID_LONG:
- case RID_INT128:
case RID_CONST:
case RID_SHORT:
case RID_VOLATILE:
@@ -9013,6 +9034,10 @@ c_parser_objc_selector (c_parser *parser)
case RID_BOOL:
case RID_ATOMIC:
case RID_AUTO_TYPE:
+ case RID_INT_N_0:
+ case RID_INT_N_1:
+ case RID_INT_N_2:
+ case RID_INT_N_3:
c_parser_consume_token (parser);
return value;
default:
diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h
index fc145a85..e6aca01 100644
--- a/gcc/c/c-tree.h
+++ b/gcc/c/c-tree.h
@@ -202,7 +202,7 @@ enum c_typespec_keyword {
cts_char,
cts_int,
cts_float,
- cts_int128,
+ cts_int_n,
cts_double,
cts_dfloat32,
cts_dfloat64,
@@ -269,6 +269,8 @@ struct c_declspecs {
specifier, in bytes, or -1 if no such specifiers with nonzero
alignment. */
int align_log;
+ /* For the __intN declspec, this stores the index into the int_n_* arrays. */
+ int int_n_idx;
/* The storage class specifier, or csc_none if none. */
enum c_storage_class storage_class;
/* Any type specifier keyword used such as "int", not reflecting