+2019-06-25 Jozef Lawrynowicz <jozef.l@mittosystems.com>
+
+ * gcc/c-family/c-common.c (c_common_nodes_and_builtins): Define
+ alternate "__intN__" name for "__intN" types.
+ * gcc/c/c-parser.c (c_parse_init): Create keyword for "__intN__" type.
+ * gcc/cp/lex.c (init_reswords): Likewise.
+ * gcc/config/msp430/msp430.h: Use __int20__ for SIZE_TYPE and
+ PTRDIFF_TYPE.
+ * gcc/cp/cp-tree.h (cp_decl_specifier_seq): New bitfield "int_n_alt".
+ * gcc/c/c-decl.c (declspecs_add_type): Don't pedwarn about "__intN" ISO
+ C incompatibility if alternate "__intN__" form is used.
+ * gcc/cp/decl.c (grokdeclarator): Likewise.
+ * gcc/cp/parser.c (cp_parser_simple_type_specifier): Set
+ decl_specs->int_n_alt if "__intN__" form is used.
+ * gcc/gimple-ssa-sprintf.c (build_intmax_type_nodes): Accept "__intN__"
+ format of "__intN" types for UINTMAX_TYPE.
+ * gcc/brig/brig-lang.c (brig_build_c_type_nodes): Accept "__intN__"
+ format of "__intN" types for SIZE_TYPE.
+ * gcc/lto/lto-lang.c (lto_build_c_type_nodes): Likewise.
+ * gcc/stor-layout.c (initialize_sizetypes): Accept "__intN__"
+ format of "__intN" types for SIZETYPE.
+ * gcc/tree.c (build_common_tree_nodes): Accept "__intN__"
+ format of "__intN" types for SIZE_TYPE and PTRDIFF_TYPE.
+ * gcc/doc/invoke.texi: Document that __intN__ disables pedantic
+ warnings.
+
2019-06-25 Jan Hubicka <jh@suse.cz>
* tree-ssa-alias.c (indirect_ref_may_alias_decl_p): Check that
for (i = 0; i < NUM_INT_N_ENTS; i++)
if (int_n_enabled_p[i])
{
- char name[50];
+ char name[50], altname[50];
sprintf (name, "__int%d unsigned", int_n_data[i].bitsize);
+ sprintf (altname, "__int%d__ unsigned", int_n_data[i].bitsize);
- if (strcmp (name, SIZE_TYPE) == 0)
+ if (strcmp (name, SIZE_TYPE) == 0
+ || strcmp (altname, SIZE_TYPE) == 0)
{
intmax_type_node = int_n_trees[i].signed_type;
uintmax_type_node = int_n_trees[i].unsigned_type;
sprintf (name, "__int%d", int_n_data[i].bitsize);
record_builtin_type ((enum rid)(RID_FIRST_INT_N + i), name,
int_n_trees[i].signed_type);
+ sprintf (name, "__int%d__", int_n_data[i].bitsize);
+ record_builtin_type ((enum rid)(RID_FIRST_INT_N + i), name,
+ int_n_trees[i].signed_type);
+
sprintf (name, "__int%d unsigned", int_n_data[i].bitsize);
record_builtin_type (RID_MAX, name, int_n_trees[i].unsigned_type);
+ sprintf (name, "__int%d__ unsigned", int_n_data[i].bitsize);
+ record_builtin_type (RID_MAX, name, int_n_trees[i].unsigned_type);
}
if (c_dialect_cxx ())
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))
+ if (!in_system_header_at (input_location)
+ /* If the INT_N type ends in "__", and so is of the format
+ "__intN__", don't pedwarn. */
+ && (strncmp (IDENTIFIER_POINTER (type)
+ + (IDENTIFIER_LENGTH (type) - 2), "__", 2) != 0))
pedwarn (loc, OPT_Wpedantic,
"ISO C does not support %<__int%d%> types",
int_n_data[specs->int_n_idx].bitsize);
id = get_identifier (name);
C_SET_RID_CODE (id, RID_FIRST_INT_N + i);
C_IS_RESERVED_WORD (id) = 1;
+
+ sprintf (name, "__int%d__", int_n_data[i].bitsize);
+ id = get_identifier (name);
+ C_SET_RID_CODE (id, RID_FIRST_INT_N + i);
+ C_IS_RESERVED_WORD (id) = 1;
}
}
\f
/* Layout of Source Language Data Types */
#undef SIZE_TYPE
-#define SIZE_TYPE (TARGET_LARGE ? "__int20 unsigned" : "unsigned int")
+#define SIZE_TYPE (TARGET_LARGE \
+ ? "__int20__ unsigned" \
+ : "unsigned int")
#undef PTRDIFF_TYPE
-#define PTRDIFF_TYPE (TARGET_LARGE ? "__int20" : "int")
+#define PTRDIFF_TYPE (TARGET_LARGE ? "__int20__" : "int")
#undef WCHAR_TYPE
#define WCHAR_TYPE "long int"
#undef WCHAR_TYPE_SIZE
BOOL_BITFIELD gnu_thread_keyword_p : 1;
/* True iff the type is a decltype. */
BOOL_BITFIELD decltype_p : 1;
+ /* True iff the alternate "__intN__" form of the __intN type has been
+ used. */
+ BOOL_BITFIELD int_n_alt: 1;
};
/* The various kinds of declarators. */
tree type = NULL_TREE;
int longlong = 0;
int explicit_intN = 0;
+ int int_n_alt = 0;
int virtualp, explicitp, friendp, inlinep, staticp;
int explicit_int = 0;
int explicit_char = 0;
long_p = decl_spec_seq_has_spec_p (declspecs, ds_long);
longlong = decl_spec_seq_has_spec_p (declspecs, ds_long_long);
explicit_intN = declspecs->explicit_intN_p;
+ int_n_alt = declspecs->int_n_alt;
thread_p = decl_spec_seq_has_spec_p (declspecs, ds_thread);
// Was concept_p specified? Note that ds_concept
int_n_data[declspecs->int_n_idx].bitsize);
explicit_intN = false;
}
- else if (pedantic && ! in_system_header_at (input_location))
+ /* Don't pedwarn if the alternate "__intN__" form has been used instead
+ of "__intN". */
+ else if (!int_n_alt && pedantic && ! in_system_header_at (input_location))
pedwarn (input_location, OPT_Wpedantic,
"ISO C++ does not support %<__int%d%> for %qs",
int_n_data[declspecs->int_n_idx].bitsize, name);
id = get_identifier (name);
C_SET_RID_CODE (id, RID_FIRST_INT_N + i);
set_identifier_kind (id, cik_keyword);
+
+ sprintf (name, "__int%d__", int_n_data[i].bitsize);
+ id = get_identifier (name);
+ C_SET_RID_CODE (id, RID_FIRST_INT_N + i);
+ set_identifier_kind (id, cik_keyword);
}
}
{
decl_specs->explicit_intN_p = true;
decl_specs->int_n_idx = idx;
+ /* Check if the alternate "__intN__" form has been used instead of
+ "__intN". */
+ if (strncmp (IDENTIFIER_POINTER (token->u.value)
+ + (IDENTIFIER_LENGTH (token->u.value) - 2),
+ "__", 2) == 0)
+ decl_specs->int_n_alt = true;
}
type = int_n_trees [idx].signed_type;
break;
features are supported as well. With this option, they are rejected.
@option{-Wpedantic} does not cause warning messages for use of the
-alternate keywords whose names begin and end with @samp{__}. Pedantic
-warnings are also disabled in the expression that follows
+alternate keywords whose names begin and end with @samp{__}. This alternate
+format can also be used to disable warnings for non-ISO @samp{__intN} types,
+i.e. @samp{__intN__}.
+Pedantic warnings are also disabled in the expression that follows
@code{__extension__}. However, only system header files should use
these escape routes; application programs should avoid them.
@xref{Alternate Keywords}.
for (int i = 0; i < NUM_INT_N_ENTS; i++)
if (int_n_enabled_p[i])
{
- char name[50];
+ char name[50], altname[50];
sprintf (name, "__int%d unsigned", int_n_data[i].bitsize);
+ sprintf (altname, "__int%d__ unsigned", int_n_data[i].bitsize);
- if (strcmp (name, UINTMAX_TYPE) == 0)
+ if (strcmp (name, UINTMAX_TYPE) == 0
+ || strcmp (altname, UINTMAX_TYPE) == 0)
{
*pintmax = int_n_trees[i].signed_type;
*puintmax = int_n_trees[i].unsigned_type;
for (i = 0; i < NUM_INT_N_ENTS; i++)
if (int_n_enabled_p[i])
{
- char name[50];
+ char name[50], altname[50];
sprintf (name, "__int%d unsigned", int_n_data[i].bitsize);
+ sprintf (altname, "__int%d__ unsigned", int_n_data[i].bitsize);
- if (strcmp (name, SIZE_TYPE) == 0)
+ if (strcmp (name, SIZE_TYPE) == 0
+ || strcmp (altname, SIZE_TYPE) == 0)
{
intmax_type_node = int_n_trees[i].signed_type;
uintmax_type_node = int_n_trees[i].unsigned_type;
for (i = 0; i < NUM_INT_N_ENTS; i++)
if (int_n_enabled_p[i])
{
- char name[50];
+ char name[50], altname[50];
sprintf (name, "__int%d unsigned", int_n_data[i].bitsize);
+ sprintf (altname, "__int%d__ unsigned", int_n_data[i].bitsize);
- if (strcmp (name, SIZETYPE) == 0)
+ if (strcmp (name, SIZETYPE) == 0
+ || strcmp (altname, SIZETYPE) == 0)
{
precision = int_n_data[i].bitsize;
}
+2019-06-25 Jozef Lawrynowicz <jozef.l@mittosystems.com>
+
+ * gcc.target/msp430/mlarge-pedwarns.c: New test.
+
2019-06-25 Jakub Jelinek <jakub@redhat.com>
PR sanitizer/90954
--- /dev/null
+/* { dg-do compile } */
+/* { dg-skip-if "" { "*-*-*" } { "-mcpu=msp430" } { "" } } */
+/* { dg-options "-mlarge -pedantic-errors" } */
+
+/* Ensure the use of builtin macros that contain __int20__ in their
+ expansion don't cause ISO C errors when -pedantic-errors is passed. */
+
+__SIZE_TYPE__ a;
+__INTPTR_TYPE__ b;
+__UINTPTR_TYPE__ c;
+__PTRDIFF_TYPE__ d;
for (i = 0; i < NUM_INT_N_ENTS; i++)
if (int_n_enabled_p[i])
{
- char name[50];
+ char name[50], altname[50];
sprintf (name, "__int%d unsigned", int_n_data[i].bitsize);
+ sprintf (altname, "__int%d__ unsigned", int_n_data[i].bitsize);
- if (strcmp (name, SIZE_TYPE) == 0)
+ if (strcmp (name, SIZE_TYPE) == 0
+ || strcmp (altname, SIZE_TYPE) == 0)
{
size_type_node = int_n_trees[i].unsigned_type;
}
for (int i = 0; i < NUM_INT_N_ENTS; i++)
if (int_n_enabled_p[i])
{
- char name[50];
+ char name[50], altname[50];
sprintf (name, "__int%d", int_n_data[i].bitsize);
- if (strcmp (name, PTRDIFF_TYPE) == 0)
+ sprintf (altname, "__int%d__", int_n_data[i].bitsize);
+
+ if (strcmp (name, PTRDIFF_TYPE) == 0
+ || strcmp (altname, PTRDIFF_TYPE) == 0)
ptrdiff_type_node = int_n_trees[i].signed_type;
}
if (ptrdiff_type_node == NULL_TREE)