aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog28
-rw-r--r--gcc/c/c-decl.cc35
-rw-r--r--gcc/c/c-parser.cc47
-rw-r--r--gcc/c/c-typeck.cc8
4 files changed, 89 insertions, 29 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index f5f3ece..0a10d16 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,31 @@
+2023-01-14 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/108365
+ * c-typeck.cc (build_binary_op): Use may_shorten_divmod for integral
+ division or modulo.
+
+2023-01-13 Qing Zhao <qing.zhao@oracle.com>
+
+ * c-decl.cc (strict_flex_array_level_of): ... here.
+
+2023-01-11 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/105972
+ * c-parser.cc (c_parser_declaration_or_fndef): Disable debug non-bind
+ markers for K&R function parameter declarations of nested functions.
+
+2023-01-09 Joseph Myers <joseph@codesourcery.com>
+
+ * c-decl.cc (build_compound_literal): Call record_inline_static.
+
+2023-01-06 Joseph Myers <joseph@codesourcery.com>
+
+ * c-parser.cc (c_parser_postfix_expression): Handle integer
+ generic arguments to functions passed to __builtin_tgmath as
+ _Float32x if any argument has _FloatNx or _Complex _FloatNx type.
+ Do not handle integer arguments to some narrowing functions as
+ _Float64.
+
2022-12-19 Jakub Jelinek <jakub@redhat.com>
PR c/108043
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index e47ca67..38647c1 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -6260,6 +6260,13 @@ build_compound_literal (location_t loc, tree type, tree init, bool non_const,
DECL_USER_ALIGN (decl) = 1;
}
store_init_value (loc, decl, init, NULL_TREE);
+ if (current_scope != file_scope
+ && TREE_STATIC (decl)
+ && !TREE_READONLY (decl)
+ && DECL_DECLARED_INLINE_P (current_function_decl)
+ && DECL_EXTERNAL (current_function_decl))
+ record_inline_static (input_location, current_function_decl,
+ decl, csi_modifiable);
if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type))
{
@@ -9040,6 +9047,34 @@ finish_incomplete_vars (tree incomplete_vars, bool toplevel)
}
}
+/* Get the LEVEL of the strict_flex_array for the ARRAY_FIELD based on the
+ values of attribute strict_flex_array and the flag_strict_flex_arrays. */
+static unsigned int
+strict_flex_array_level_of (tree array_field)
+{
+ gcc_assert (TREE_CODE (array_field) == FIELD_DECL);
+ unsigned int strict_flex_array_level = flag_strict_flex_arrays;
+
+ tree attr_strict_flex_array
+ = lookup_attribute ("strict_flex_array", DECL_ATTRIBUTES (array_field));
+ /* If there is a strict_flex_array attribute attached to the field,
+ override the flag_strict_flex_arrays. */
+ if (attr_strict_flex_array)
+ {
+ /* Get the value of the level first from the attribute. */
+ unsigned HOST_WIDE_INT attr_strict_flex_array_level = 0;
+ gcc_assert (TREE_VALUE (attr_strict_flex_array) != NULL_TREE);
+ attr_strict_flex_array = TREE_VALUE (attr_strict_flex_array);
+ gcc_assert (TREE_VALUE (attr_strict_flex_array) != NULL_TREE);
+ attr_strict_flex_array = TREE_VALUE (attr_strict_flex_array);
+ gcc_assert (tree_fits_uhwi_p (attr_strict_flex_array));
+ attr_strict_flex_array_level = tree_to_uhwi (attr_strict_flex_array);
+
+ /* The attribute has higher priority than flag_struct_flex_array. */
+ strict_flex_array_level = attr_strict_flex_array_level;
+ }
+ return strict_flex_array_level;
+}
/* Determine whether the FIELD_DECL X is a flexible array member according to
the following info:
diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc
index 7d6960f..a698506 100644
--- a/gcc/c/c-parser.cc
+++ b/gcc/c/c-parser.cc
@@ -2804,10 +2804,13 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok,
declarator with a nonempty identifier list in a definition;
and postfix attributes have never been accepted here in
function definitions either. */
+ int save_debug_nonbind_markers_p = debug_nonbind_markers_p;
+ debug_nonbind_markers_p = 0;
while (c_parser_next_token_is_not (parser, CPP_EOF)
&& c_parser_next_token_is_not (parser, CPP_OPEN_BRACE))
c_parser_declaration_or_fndef (parser, false, false, false,
true, false);
+ debug_nonbind_markers_p = save_debug_nonbind_markers_p;
store_parm_decls ();
if (omp_declare_simd_clauses)
c_finish_omp_declare_simd (parser, current_function_decl, NULL_TREE,
@@ -5698,7 +5701,7 @@ c_parser_initializer (c_parser *parser, tree decl)
&& !DECL_EXTERNAL (decl)
&& !TREE_STATIC (decl)
&& ret.value == decl
- && !warn_init_self)
+ && !warning_enabled_at (DECL_SOURCE_LOCATION (decl), OPT_Winit_self))
suppress_warning (decl, OPT_Winit_self);
if (TREE_CODE (ret.value) != STRING_CST
&& (TREE_CODE (ret.value) != COMPOUND_LITERAL_EXPR
@@ -10276,16 +10279,17 @@ c_parser_postfix_expression (c_parser *parser)
types are treated as _Decimal64 if any type-generic
argument is decimal, or if the only alternatives for
type-generic arguments are of decimal types, and are
- otherwise treated as double (or _Complex double for
- complex integer types, or _Float64 or _Complex _Float64
- if all the return types are the same _FloatN or
- _FloatNx type). After that adjustment, types are
- combined following the usual arithmetic conversions.
- If the function only accepts complex arguments, a
- complex type is produced. */
+ otherwise treated as _Float32x (or _Complex _Float32x
+ for complex integer types) if any type-generic argument
+ has _FloatNx type, otherwise as double (or _Complex
+ double for complex integer types). After that
+ adjustment, types are combined following the usual
+ arithmetic conversions. If the function only accepts
+ complex arguments, a complex type is produced. */
bool arg_complex = all_complex;
bool arg_binary = all_binary;
bool arg_int_decimal = all_decimal;
+ bool arg_int_floatnx = false;
for (unsigned int j = 1; j <= nargs; j++)
{
if (parm_kind[j] == tgmath_fixed)
@@ -10380,20 +10384,17 @@ c_parser_postfix_expression (c_parser *parser)
goto out;
}
}
+ tree rtype = TYPE_MAIN_VARIANT (type);
+ if (TREE_CODE (rtype) == COMPLEX_TYPE)
+ rtype = TREE_TYPE (rtype);
+ if (SCALAR_FLOAT_TYPE_P (rtype))
+ for (unsigned int j = 0; j < NUM_FLOATNX_TYPES; j++)
+ if (rtype == FLOATNX_TYPE_NODE (j))
+ {
+ arg_int_floatnx = true;
+ break;
+ }
}
- /* For a macro rounding its result to a narrower type, map
- integer types to _Float64 not double if the return type
- is a _FloatN or _FloatNx type. */
- bool arg_int_float64 = false;
- if (parm_kind[0] == tgmath_fixed
- && SCALAR_FLOAT_TYPE_P (parm_first[0])
- && float64_type_node != NULL_TREE)
- for (unsigned int j = 0; j < NUM_FLOATN_NX_TYPES; j++)
- if (parm_first[0] == FLOATN_TYPE_NODE (j))
- {
- arg_int_float64 = true;
- break;
- }
tree arg_real = NULL_TREE;
for (unsigned int j = 1; j <= nargs; j++)
{
@@ -10406,8 +10407,8 @@ c_parser_postfix_expression (c_parser *parser)
if (INTEGRAL_TYPE_P (type))
type = (arg_int_decimal
? dfloat64_type_node
- : arg_int_float64
- ? float64_type_node
+ : arg_int_floatnx
+ ? float32x_type_node
: double_type_node);
if (arg_real == NULL_TREE)
arg_real = type;
diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index e06f052..418efda 100644
--- a/gcc/c/c-typeck.cc
+++ b/gcc/c/c-typeck.cc
@@ -12431,9 +12431,7 @@ build_binary_op (location_t location, enum tree_code code,
undefined if the quotient can't be represented in the
computation mode. We shorten only if unsigned or if
dividing by something we know != -1. */
- shorten = (TYPE_UNSIGNED (TREE_TYPE (orig_op0))
- || (TREE_CODE (op1) == INTEGER_CST
- && !integer_all_onesp (op1)));
+ shorten = may_shorten_divmod (op0, op1);
common = 1;
}
break;
@@ -12467,9 +12465,7 @@ build_binary_op (location_t location, enum tree_code code,
on some targets, since the modulo instruction is undefined if the
quotient can't be represented in the computation mode. We shorten
only if unsigned or if dividing by something we know != -1. */
- shorten = (TYPE_UNSIGNED (TREE_TYPE (orig_op0))
- || (TREE_CODE (op1) == INTEGER_CST
- && !integer_all_onesp (op1)));
+ shorten = may_shorten_divmod (op0, op1);
common = 1;
}
break;