aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2022-07-27 10:15:41 -0700
committerIan Lance Taylor <iant@golang.org>2022-07-27 10:15:41 -0700
commit9f62ed218fa656607740b386c0caa03e65dcd283 (patch)
tree6bde49bc5e4c4241266b108e4277baef4b85535d /gcc/c
parent71e955da39cea0ebffcfee3432effa622d14ca99 (diff)
parent5eb9f117a361538834b9740d59219911680717d1 (diff)
downloadgcc-9f62ed218fa656607740b386c0caa03e65dcd283.zip
gcc-9f62ed218fa656607740b386c0caa03e65dcd283.tar.gz
gcc-9f62ed218fa656607740b386c0caa03e65dcd283.tar.bz2
Merge from trunk revision 5eb9f117a361538834b9740d59219911680717d1.
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog207
-rw-r--r--gcc/c/Make-lang.in2
-rw-r--r--gcc/c/c-decl.cc90
-rw-r--r--gcc/c/c-fold.cc1
-rw-r--r--gcc/c/c-lang.cc12
-rw-r--r--gcc/c/c-objc-common.cc9
-rw-r--r--gcc/c/c-parser.cc273
-rw-r--r--gcc/c/c-tree.h6
-rw-r--r--gcc/c/c-typeck.cc127
-rw-r--r--gcc/c/gimple-parser.cc39
10 files changed, 645 insertions, 121 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 6e420e0..3aa672b 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,210 @@
+2022-07-10 Lewis Hyatt <lhyatt@gmail.com>
+
+ PR preprocessor/97498
+ * c-parser.cc (c_parser_pragma): Set input_location to the
+ location of the pragma, rather than the start of the line.
+
+2022-07-04 Tobias Burnus <tobias@codesourcery.com>
+ Chung-Lin Tang <cltang@codesourcery.com>
+ Thomas Schwinge <thomas@codesourcery.com>
+
+ * c-parser.cc (c_parser_omp_target_data, c_parser_omp_target_update,
+ c_parser_omp_target_enter_data, c_parser_omp_target_exit_data): Set
+ OMP_REQUIRES_TARGET_USED.
+ (c_parser_omp_requires): Remove sorry.
+
+2022-07-01 Tobias Burnus <tobias@codesourcery.com>
+
+ * c-parser.cc (c_parser_omp_target_enter_data,
+ c_parser_omp_target_exit_data): Accept tofrom
+ map-type modifier but use 'to' / 'from' internally.
+
+2022-06-16 David Malcolm <dmalcolm@redhat.com>
+
+ * c-decl.cc (implicitly_declare): Add auto_diagnostic_group to
+ group the warning with any note.
+ (warn_about_goto): Likewise to group error or warning with note.
+ Bail out if the warning wasn't emitted, to avoid emitting orphan
+ notes.
+ (lookup_label_for_goto): Add auto_diagnostic_group to
+ group the error with the note.
+ (check_earlier_gotos): Likewise.
+ (c_check_switch_jump_warnings): Likewise for any error/warning.
+ Conditionalize emission of the notes.
+ (diagnose_uninitialized_cst_member): Likewise for warning,
+ conditionalizing emission of the note.
+ (grokdeclarator): Add auto_diagnostic_group to group the "array
+ type has incomplete element type" error with any note.
+ (parser_xref_tag): Add auto_diagnostic_group to group warnings
+ with their notes. Conditionalize emission of notes.
+ (start_struct): Add auto_diagnostic_group to group the
+ "redefinition of" errors with any note.
+ (start_enum): Likewise for "redeclaration of %<enum %E%>" error.
+ (check_for_loop_decls): Likewise for pre-C99 error.
+
+2022-06-07 Jakub Jelinek <jakub@redhat.com>
+
+ * c-parser.cc (c_parser_omp_clause_linear): Parse OpenMP 5.2
+ style linear clause modifiers. Set
+ OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER flag on the clauses when
+ old style modifiers are used.
+ * c-typeck.cc (c_finish_omp_clauses): Only reject linear clause
+ with val modifier on simd or for if the old style modifiers are
+ used.
+
+2022-06-02 David Malcolm <dmalcolm@redhat.com>
+
+ * c-lang.cc (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Redefine.
+ (c_get_sarif_source_language): New.
+ * c-tree.h (c_get_sarif_source_language): New decl.
+
+2022-05-31 Jason Merrill <jason@redhat.com>
+
+ * Make-lang.in (c.tags): Look at *.cc.
+
+2022-05-31 Jakub Jelinek <jakub@redhat.com>
+
+ * c-parser.cc (OMP_SCOPE_CLAUSE_MASK): Add firstprivate and allocate
+ clauses.
+
+2022-05-28 Jakub Jelinek <jakub@redhat.com>
+
+ * c-parser.cc (c_parser_omp_declare_target): If OMP_CLAUSE_LINK was
+ seen first, use "%<to%>" or "%<enter%>" depending on
+ OMP_CLAUSE_ENTER_TO of the current clause, otherwise use
+ "%<to%> or %<enter%>" wording.
+
+2022-05-27 Jakub Jelinek <jakub@redhat.com>
+
+ * c-parser.cc (c_parser_omp_clause_name): Parse enter clause.
+ (c_parser_omp_all_clauses): For to clause on declare target, use
+ OMP_CLAUSE_ENTER clause with OMP_CLAUSE_ENTER_TO instead of
+ OMP_CLAUSE_TO_DECLARE clause. Handle PRAGMA_OMP_CLAUSE_ENTER.
+ (OMP_DECLARE_TARGET_CLAUSE_MASK): Add enter clause.
+ (c_parser_omp_declare_target): Use OMP_CLAUSE_ENTER instead of
+ OMP_CLAUSE_TO_DECLARE.
+ * c-typeck.cc (c_finish_omp_clauses): Handle OMP_CLAUSE_ENTER instead
+ of OMP_CLAUSE_TO_DECLARE, to OMP_CLAUSE_ENTER_TO use "to" as clause
+ name in diagnostics instead of
+ omp_clause_code_name[OMP_CLAUSE_CODE (c)].
+
+2022-05-25 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/91134
+ * c-tree.h (build_component_ref): Add ARROW_LOC location_t argument.
+ * c-typeck.cc (build_component_ref): Likewise. If DATUM is
+ INDIRECT_REF and ARROW_LOC isn't UNKNOWN_LOCATION, print a different
+ diagnostic and fixit hint if DATUM has pointer type.
+ * c-parser.cc (c_parser_postfix_expression,
+ c_parser_omp_variable_list): Adjust build_component_ref callers.
+ * gimple-parser.cc (c_parser_gimple_postfix_expression_after_primary):
+ Likewise.
+
+2022-05-24 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/105378
+ * c-parser.cc (OMP_TASKWAIT_CLAUSE_MASK): Add nowait clause.
+
+2022-05-18 Marek Polacek <polacek@redhat.com>
+
+ PR c/105131
+ * c-decl.cc (diagnose_mismatched_decls): Warn about enum/integer type
+ mismatches.
+ * c-tree.h (comptypes_check_enum_int): Declare.
+ * c-typeck.cc (comptypes): No longer static.
+
+2022-05-17 Marek Polacek <polacek@redhat.com>
+
+ * c-decl.cc (finish_enum): Store the CONST_DECL into TREE_VALUE, not
+ its value.
+
+2022-05-17 Jakub Jelinek <jakub@redhat.com>
+
+ * c-parser.cc (c_parser_omp_clause_depend): Parse
+ inoutset depend-kind.
+ (c_parser_omp_depobj): Likewise.
+
+2022-05-16 Martin Liska <mliska@suse.cz>
+
+ * c-decl.cc (match_builtin_function_types): Use ARRAY_SIZE.
+
+2022-05-12 Jakub Jelinek <jakub@redhat.com>
+
+ * c-parser.cc (c_parse_init): Register omp_all_memory as keyword
+ if flag_openmp.
+ (c_parser_postfix_expression): Diagnose uses of omp_all_memory
+ in postfix expressions.
+ (c_parser_omp_variable_list): Handle omp_all_memory in depend
+ clause.
+ * c-typeck.cc (c_finish_omp_clauses): Handle omp_all_memory
+ keyword in depend clause as null_pointer_node, diagnose invalid
+ uses.
+
+2022-05-09 Martin Liska <mliska@suse.cz>
+
+ * c-parser.cc (c_parser_conditional_expression): Use {,UN}LIKELY
+ macros.
+ (c_parser_binary_expression): Likewise.
+
+2022-05-07 Marek Polacek <polacek@redhat.com>
+
+ PR c++/101833
+ PR c++/47634
+ * c-objc-common.cc (maybe_adjust_arg_pos_for_attribute): New.
+
+2022-04-08 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/105149
+ * c-typeck.cc (c_build_va_arg): Reject function types.
+
+2022-03-22 Marek Polacek <polacek@redhat.com>
+
+ PR c/82283
+ PR c/84685
+ * c-typeck.cc (struct initializer_stack): Add 'designated' member.
+ (start_init): Set it.
+ (finish_init): Restore constructor_designated.
+ (push_init_level): Set constructor_designated to the value of
+ constructor_designated in the upper constructor_stack.
+
+2022-03-12 Thomas Schwinge <thomas@codesourcery.com>
+
+ PR other/65095
+ * c-typeck.cc (handle_omp_array_sections_1)
+ (c_oacc_check_attachments): Call 'user_omp_clause_code_name'
+ instead of 'c_omp_map_clause_name'.
+
+2022-03-09 Joseph Myers <joseph@codesourcery.com>
+
+ * c-typeck.cc (function_types_compatible_p): Do not handle C2X
+ differently from earlier standards for unprototyped function type
+ compatibility.
+
+2022-03-09 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/104711
+ * c-fold.cc (c_fully_fold_internal): Don't emit
+ -Wshift-negative-value warning if TYPE_OVERFLOW_WRAPS.
+ * c-typeck.cc (build_binary_op): Likewise.
+
+2022-03-07 Jakub Jelinek <jakub@redhat.com>
+
+ * c-parser.cc (c_parser_omp_clause_map): Add missing space in string
+ literal.
+
+2022-02-23 Richard Biener <rguenther@suse.de>
+
+ * gimple-parser.cc (c_parser_parse_gimple_body): Diagnose
+ SSA names without definition.
+ (c_parser_gimple_declaration): Handle pointer typed SSA names.
+
+2022-02-17 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/104532
+ * c-parser.cc (c_parser_omp_variable_list): For CPP_DEREF, use
+ convert_lvalue_to_rvalue and build_indirect_ref instead of
+ build_simple_mem_ref.
+
2022-02-11 Richard Biener <rguenther@suse.de>
* gimple-parser.cc (c_parser_gimple_statement): Properly parse
diff --git a/gcc/c/Make-lang.in b/gcc/c/Make-lang.in
index 1367a10..9bd9c0e 100644
--- a/gcc/c/Make-lang.in
+++ b/gcc/c/Make-lang.in
@@ -109,7 +109,7 @@ c.srcinfo:
c.srcextra: gengtype-lex.cc
-cp -p $^ $(srcdir)
c.tags: force
- cd $(srcdir)/c; $(ETAGS) -o TAGS.sub *.c *.h; \
+ cd $(srcdir)/c; $(ETAGS) -o TAGS.sub *.cc *.h; \
$(ETAGS) --include TAGS.sub --include ../TAGS.sub
c.man:
c.srcman:
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index c701f07..ae8990c 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -1658,7 +1658,7 @@ c_bind (location_t loc, tree decl, bool is_global)
Used only by match_builtin_function_types. */
static const unsigned builtin_structptr_type_count
- = sizeof builtin_structptr_types / sizeof builtin_structptr_types[0];
+ = ARRAY_SIZE (builtin_structptr_types);
static GTY(()) tree last_structptr_types[builtin_structptr_type_count];
@@ -1705,10 +1705,8 @@ match_builtin_function_types (tree newtype, tree oldtype,
tree newargs = TYPE_ARG_TYPES (newtype);
tree tryargs = newargs;
- const unsigned nlst
- = sizeof last_structptr_types / sizeof last_structptr_types[0];
- const unsigned nbst
- = sizeof builtin_structptr_types / sizeof builtin_structptr_types[0];
+ const unsigned nlst = ARRAY_SIZE (last_structptr_types);
+ const unsigned nbst = ARRAY_SIZE (builtin_structptr_types);
gcc_checking_assert (nlst == nbst);
@@ -1995,9 +1993,12 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
bool pedwarned = false;
bool warned = false;
+ bool enum_and_int_p = false;
auto_diagnostic_group d;
- if (!comptypes (oldtype, newtype))
+ int comptypes_result = comptypes_check_enum_int (oldtype, newtype,
+ &enum_and_int_p);
+ if (!comptypes_result)
{
if (TREE_CODE (olddecl) == FUNCTION_DECL
&& fndecl_built_in_p (olddecl, BUILT_IN_NORMAL)
@@ -2139,6 +2140,13 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
return false;
}
}
+ /* Warn about enum/integer type mismatches. They are compatible types
+ (C2X 6.7.2.2/5), but may pose portability problems. */
+ else if (enum_and_int_p && TREE_CODE (newdecl) != TYPE_DECL)
+ warned = warning_at (DECL_SOURCE_LOCATION (newdecl),
+ OPT_Wenum_int_mismatch,
+ "conflicting types for %q+D due to enum/integer "
+ "mismatch; have %qT", newdecl, newtype);
/* Redeclaration of a type is a constraint violation (6.7.2.3p1),
but silently ignore the redeclaration if either is in a system
@@ -2148,7 +2156,6 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
if (TREE_CODE (newdecl) == TYPE_DECL)
{
bool types_different = false;
- int comptypes_result;
comptypes_result
= comptypes_check_different_types (oldtype, newtype, &types_different);
@@ -3690,6 +3697,7 @@ implicitly_declare (location_t loc, tree functionid)
(TREE_TYPE (decl)));
if (!comptypes (newtype, TREE_TYPE (decl)))
{
+ auto_diagnostic_group d;
bool warned = warning_at (loc,
OPT_Wbuiltin_declaration_mismatch,
"incompatible implicit "
@@ -3883,12 +3891,14 @@ lookup_label (tree name)
static void
warn_about_goto (location_t goto_loc, tree label, tree decl)
{
+ auto_diagnostic_group d;
if (variably_modified_type_p (TREE_TYPE (decl), NULL_TREE))
error_at (goto_loc,
"jump into scope of identifier with variably modified type");
else
- warning_at (goto_loc, OPT_Wjump_misses_init,
- "jump skips variable initialization");
+ if (!warning_at (goto_loc, OPT_Wjump_misses_init,
+ "jump skips variable initialization"))
+ return;
inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", label);
inform (DECL_SOURCE_LOCATION (decl), "%qD declared here", decl);
}
@@ -3943,6 +3953,7 @@ lookup_label_for_goto (location_t loc, tree name)
if (label_vars->label_bindings.left_stmt_expr)
{
+ auto_diagnostic_group d;
error_at (loc, "jump into statement expression");
inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", label);
}
@@ -4033,6 +4044,7 @@ check_earlier_gotos (tree label, struct c_label_vars* label_vars)
if (g->goto_bindings.stmt_exprs > 0)
{
+ auto_diagnostic_group d;
error_at (g->loc, "jump into statement expression");
inform (DECL_SOURCE_LOCATION (label), "label %qD defined here",
label);
@@ -4152,19 +4164,26 @@ c_check_switch_jump_warnings (struct c_spot_bindings *switch_bindings,
{
if (decl_jump_unsafe (b->decl))
{
+ auto_diagnostic_group d;
+ bool emitted;
if (variably_modified_type_p (TREE_TYPE (b->decl), NULL_TREE))
{
saw_error = true;
error_at (case_loc,
("switch jumps into scope of identifier with "
"variably modified type"));
+ emitted = true;
}
else
- warning_at (case_loc, OPT_Wjump_misses_init,
- "switch jumps over variable initialization");
- inform (switch_loc, "switch starts here");
- inform (DECL_SOURCE_LOCATION (b->decl), "%qD declared here",
- b->decl);
+ emitted
+ = warning_at (case_loc, OPT_Wjump_misses_init,
+ "switch jumps over variable initialization");
+ if (emitted)
+ {
+ inform (switch_loc, "switch starts here");
+ inform (DECL_SOURCE_LOCATION (b->decl), "%qD declared here",
+ b->decl);
+ }
}
}
}
@@ -4172,6 +4191,7 @@ c_check_switch_jump_warnings (struct c_spot_bindings *switch_bindings,
if (switch_bindings->stmt_exprs > 0)
{
saw_error = true;
+ auto_diagnostic_group d;
error_at (case_loc, "switch jumps into statement expression");
inform (switch_loc, "switch starts here");
}
@@ -5310,10 +5330,11 @@ diagnose_uninitialized_cst_member (tree decl, tree type)
if (TYPE_QUALS (field_type) & TYPE_QUAL_CONST)
{
- warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
- "uninitialized const member in %qT is invalid in C++",
- strip_array_types (TREE_TYPE (decl)));
- inform (DECL_SOURCE_LOCATION (field), "%qD should be initialized", field);
+ auto_diagnostic_group d;
+ if (warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
+ "uninitialized const member in %qT is invalid in C++",
+ strip_array_types (TREE_TYPE (decl))))
+ inform (DECL_SOURCE_LOCATION (field), "%qD should be initialized", field);
}
if (RECORD_OR_UNION_TYPE_P (field_type))
@@ -6935,6 +6956,7 @@ grokdeclarator (const struct c_declarator *declarator,
/* Complain about arrays of incomplete types. */
if (!COMPLETE_TYPE_P (type))
{
+ auto_diagnostic_group d;
error_at (loc, "array type has incomplete element type %qT",
type);
/* See if we can be more helpful. */
@@ -8194,25 +8216,26 @@ parser_xref_tag (location_t loc, enum tree_code code, tree name,
&& loc != UNKNOWN_LOCATION
&& warn_cxx_compat)
{
+ auto_diagnostic_group d;
switch (code)
{
case ENUMERAL_TYPE:
- warning_at (loc, OPT_Wc___compat,
- ("enum type defined in struct or union "
- "is not visible in C++"));
- inform (refloc, "enum type defined here");
+ if (warning_at (loc, OPT_Wc___compat,
+ ("enum type defined in struct or union "
+ "is not visible in C++")))
+ inform (refloc, "enum type defined here");
break;
case RECORD_TYPE:
- warning_at (loc, OPT_Wc___compat,
- ("struct defined in struct or union "
- "is not visible in C++"));
- inform (refloc, "struct defined here");
+ if (warning_at (loc, OPT_Wc___compat,
+ ("struct defined in struct or union "
+ "is not visible in C++")))
+ inform (refloc, "struct defined here");
break;
case UNION_TYPE:
- warning_at (loc, OPT_Wc___compat,
- ("union defined in struct or union "
- "is not visible in C++"));
- inform (refloc, "union defined here");
+ if (warning_at (loc, OPT_Wc___compat,
+ ("union defined in struct or union "
+ "is not visible in C++")))
+ inform (refloc, "union defined here");
break;
default:
gcc_unreachable();
@@ -8288,6 +8311,7 @@ start_struct (location_t loc, enum tree_code code, tree name,
if (TYPE_SIZE (ref))
{
+ auto_diagnostic_group d;
if (code == UNION_TYPE)
error_at (loc, "redefinition of %<union %E%>", name);
else
@@ -9114,6 +9138,7 @@ start_enum (location_t loc, struct c_enum_contents *the_enum, tree name)
if (TYPE_VALUES (enumtype) != NULL_TREE)
{
/* This enum is a named one that has been declared already. */
+ auto_diagnostic_group d;
error_at (loc, "redeclaration of %<enum %E%>", name);
if (enumloc != UNKNOWN_LOCATION)
inform (enumloc, "originally defined here");
@@ -9255,7 +9280,9 @@ finish_enum (tree enumtype, tree values, tree attributes)
DECL_INITIAL (enu) = ini;
TREE_PURPOSE (pair) = DECL_NAME (enu);
- TREE_VALUE (pair) = ini;
+ /* To match the C++ FE, store the CONST_DECL rather than just its
+ value. */
+ TREE_VALUE (pair) = enu;
}
TYPE_VALUES (enumtype) = values;
@@ -10419,6 +10446,7 @@ check_for_loop_decls (location_t loc, bool turn_off_iso_c99_error)
/* If we get here, declarations have been used in a for loop without
the C99 for loop scope. This doesn't make much sense, so don't
allow it. */
+ auto_diagnostic_group d;
error_at (loc, "%<for%> loop initial declarations "
"are only allowed in C99 or C11 mode");
if (hint)
diff --git a/gcc/c/c-fold.cc b/gcc/c/c-fold.cc
index 76ea25b..ac4ceaa 100644
--- a/gcc/c/c-fold.cc
+++ b/gcc/c/c-fold.cc
@@ -382,6 +382,7 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands,
&& TREE_CODE (TREE_TYPE (orig_op0)) == INTEGER_TYPE
&& TREE_CODE (op0) == INTEGER_CST
&& c_inhibit_evaluation_warnings == 0
+ && !TYPE_OVERFLOW_WRAPS (TREE_TYPE (orig_op0))
&& tree_int_cst_sgn (op0) < 0)
warning_at (loc, OPT_Wshift_negative_value,
"left shift of negative value");
diff --git a/gcc/c/c-lang.cc b/gcc/c/c-lang.cc
index eecc0a0..0e67045 100644
--- a/gcc/c/c-lang.cc
+++ b/gcc/c/c-lang.cc
@@ -46,9 +46,21 @@ enum c_language_kind c_language = clk_c;
#undef LANG_HOOKS_GET_SUBSTRING_LOCATION
#define LANG_HOOKS_GET_SUBSTRING_LOCATION c_get_substring_location
+#undef LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE
+#define LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE c_get_sarif_source_language
+
/* Each front end provides its own lang hook initializer. */
struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
+/* Get a value for the SARIF v2.1.0 "artifact.sourceLanguage" property,
+ based on the list in SARIF v2.1.0 Appendix J. */
+
+const char *
+c_get_sarif_source_language (const char *)
+{
+ return "c";
+}
+
#if CHECKING_P
namespace selftest {
diff --git a/gcc/c/c-objc-common.cc b/gcc/c/c-objc-common.cc
index 97850ad..70e10a9 100644
--- a/gcc/c/c-objc-common.cc
+++ b/gcc/c/c-objc-common.cc
@@ -394,3 +394,12 @@ c_get_alias_set (tree t)
return c_common_get_alias_set (t);
}
+
+/* In C there are no invisible parameters like in C++ (this, in-charge, VTT,
+ etc.). */
+
+int
+maybe_adjust_arg_pos_for_attribute (const_tree)
+{
+ return 0;
+}
diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc
index 3b1d2d4..92049d1 100644
--- a/gcc/c/c-parser.cc
+++ b/gcc/c/c-parser.cc
@@ -165,6 +165,14 @@ c_parse_init (void)
C_SET_RID_CODE (id, RID_FIRST_INT_N + i);
C_IS_RESERVED_WORD (id) = 1;
}
+
+ if (flag_openmp)
+ {
+ id = get_identifier ("omp_all_memory");
+ C_SET_RID_CODE (id, RID_OMP_ALL_MEMORY);
+ C_IS_RESERVED_WORD (id) = 1;
+ ridpointers [RID_OMP_ALL_MEMORY] = id;
+ }
}
/* A parser structure recording information about the state and
@@ -7669,7 +7677,7 @@ c_parser_conditional_expression (c_parser *parser, struct c_expr *after,
c_inhibit_evaluation_warnings -= cond.value == truthvalue_true_node;
location_t loc1 = make_location (exp1.get_start (), exp1.src_range);
location_t loc2 = make_location (exp2.get_start (), exp2.src_range);
- if (__builtin_expect (omp_atomic_lhs != NULL, 0)
+ if (UNLIKELY (omp_atomic_lhs != NULL)
&& (TREE_CODE (cond.value) == GT_EXPR
|| TREE_CODE (cond.value) == LT_EXPR
|| TREE_CODE (cond.value) == EQ_EXPR)
@@ -7865,7 +7873,7 @@ c_parser_binary_expression (c_parser *parser, struct c_expr *after,
stack[sp].expr \
= convert_lvalue_to_rvalue (stack[sp].loc, \
stack[sp].expr, true, true); \
- if (__builtin_expect (omp_atomic_lhs != NULL_TREE, 0) && sp == 1 \
+ if (UNLIKELY (omp_atomic_lhs != NULL_TREE) && sp == 1 \
&& ((c_parser_next_token_is (parser, CPP_SEMICOLON) \
&& ((1 << stack[sp].prec) \
& ((1 << PREC_BITOR) | (1 << PREC_BITXOR) \
@@ -9227,8 +9235,9 @@ c_parser_postfix_expression (c_parser *parser)
if (c_parser_next_token_is (parser, CPP_NAME))
{
c_token *comp_tok = c_parser_peek_token (parser);
- offsetof_ref = build_component_ref
- (loc, offsetof_ref, comp_tok->value, comp_tok->location);
+ offsetof_ref
+ = build_component_ref (loc, offsetof_ref, comp_tok->value,
+ comp_tok->location, UNKNOWN_LOCATION);
c_parser_consume_token (parser);
while (c_parser_next_token_is (parser, CPP_DOT)
|| c_parser_next_token_is (parser,
@@ -9255,9 +9264,11 @@ c_parser_postfix_expression (c_parser *parser)
break;
}
c_token *comp_tok = c_parser_peek_token (parser);
- offsetof_ref = build_component_ref
- (loc, offsetof_ref, comp_tok->value,
- comp_tok->location);
+ offsetof_ref
+ = build_component_ref (loc, offsetof_ref,
+ comp_tok->value,
+ comp_tok->location,
+ UNKNOWN_LOCATION);
c_parser_consume_token (parser);
}
else
@@ -10202,6 +10213,13 @@ c_parser_postfix_expression (c_parser *parser)
case RID_GENERIC:
expr = c_parser_generic_selection (parser);
break;
+ case RID_OMP_ALL_MEMORY:
+ gcc_assert (flag_openmp);
+ c_parser_consume_token (parser);
+ error_at (loc, "%<omp_all_memory%> may only be used in OpenMP "
+ "%<depend%> clause");
+ expr.set_error ();
+ break;
default:
c_parser_error (parser, "expected expression");
expr.set_error ();
@@ -10597,7 +10615,7 @@ c_parser_postfix_expression_after_primary (c_parser *parser,
finish = c_parser_peek_token (parser)->get_finish ();
c_parser_consume_token (parser);
expr.value = build_component_ref (op_loc, expr.value, ident,
- comp_loc);
+ comp_loc, UNKNOWN_LOCATION);
set_c_expr_source_range (&expr, start, finish);
expr.original_code = ERROR_MARK;
if (TREE_CODE (expr.value) != COMPONENT_REF)
@@ -10637,7 +10655,8 @@ c_parser_postfix_expression_after_primary (c_parser *parser,
build_indirect_ref (op_loc,
expr.value,
RO_ARROW),
- ident, comp_loc);
+ ident, comp_loc,
+ expr.get_location ());
set_c_expr_source_range (&expr, start, finish);
expr.original_code = ERROR_MARK;
if (TREE_CODE (expr.value) != COMPONENT_REF)
@@ -12378,6 +12397,7 @@ c_parser_pragma (c_parser *parser, enum pragma_context context, bool *if_p)
unsigned int id;
const char *construct = NULL;
+ input_location = c_parser_peek_token (parser)->location;
id = c_parser_peek_token (parser)->pragma_kind;
gcc_assert (id != PRAGMA_NONE);
@@ -12752,6 +12772,10 @@ c_parser_omp_clause_name (c_parser *parser)
else if (!strcmp ("dist_schedule", p))
result = PRAGMA_OMP_CLAUSE_DIST_SCHEDULE;
break;
+ case 'e':
+ if (!strcmp ("enter", p))
+ result = PRAGMA_OMP_CLAUSE_ENTER;
+ break;
case 'f':
if (!strcmp ("filter", p))
result = PRAGMA_OMP_CLAUSE_FILTER;
@@ -13025,7 +13049,19 @@ c_parser_omp_variable_list (c_parser *parser,
if (c_parser_next_token_is_not (parser, CPP_NAME)
|| c_parser_peek_token (parser)->id_kind != C_ID_ID)
{
- struct c_expr expr = c_parser_expr_no_commas (parser, NULL);
+ struct c_expr expr;
+ if (kind == OMP_CLAUSE_DEPEND
+ && c_parser_next_token_is_keyword (parser,
+ RID_OMP_ALL_MEMORY)
+ && (c_parser_peek_2nd_token (parser)->type == CPP_COMMA
+ || (c_parser_peek_2nd_token (parser)->type
+ == CPP_CLOSE_PAREN)))
+ {
+ expr.value = ridpointers[RID_OMP_ALL_MEMORY];
+ c_parser_consume_token (parser);
+ }
+ else
+ expr = c_parser_expr_no_commas (parser, NULL);
if (expr.value != error_mark_node)
{
tree u = build_omp_clause (clause_loc, kind);
@@ -13144,8 +13180,19 @@ c_parser_omp_variable_list (c_parser *parser,
&& c_parser_next_token_is (parser, CPP_DEREF)))
{
location_t op_loc = c_parser_peek_token (parser)->location;
+ location_t arrow_loc = UNKNOWN_LOCATION;
if (c_parser_next_token_is (parser, CPP_DEREF))
- t = build_simple_mem_ref (t);
+ {
+ c_expr t_expr;
+ t_expr.value = t;
+ t_expr.original_code = ERROR_MARK;
+ t_expr.original_type = NULL;
+ set_c_expr_source_range (&t_expr, op_loc, op_loc);
+ t_expr = convert_lvalue_to_rvalue (op_loc, t_expr,
+ true, false);
+ t = build_indirect_ref (op_loc, t_expr.value, RO_ARROW);
+ arrow_loc = t_expr.get_location ();
+ }
c_parser_consume_token (parser);
if (!c_parser_next_token_is (parser, CPP_NAME))
{
@@ -13158,7 +13205,8 @@ c_parser_omp_variable_list (c_parser *parser,
tree ident = comp_tok->value;
location_t comp_loc = comp_tok->location;
c_parser_consume_token (parser);
- t = build_component_ref (op_loc, t, ident, comp_loc);
+ t = build_component_ref (op_loc, t, ident, comp_loc,
+ arrow_loc);
}
/* FALLTHROUGH */
case OMP_CLAUSE_AFFINITY:
@@ -15621,7 +15669,17 @@ c_parser_omp_clause_allocate (c_parser *parser, tree list)
OpenMP 4.5:
linear ( modifier ( variable-list ) )
- linear ( modifier ( variable-list ) : expression ) */
+ linear ( modifier ( variable-list ) : expression )
+
+ modifier:
+ val
+
+ OpenMP 5.2:
+ linear ( variable-list : modifiers-list )
+
+ modifiers:
+ val
+ step ( expression ) */
static tree
c_parser_omp_clause_linear (c_parser *parser, tree list)
@@ -15629,6 +15687,7 @@ c_parser_omp_clause_linear (c_parser *parser, tree list)
location_t clause_loc = c_parser_peek_token (parser)->location;
tree nl, c, step;
enum omp_clause_linear_kind kind = OMP_CLAUSE_LINEAR_DEFAULT;
+ bool old_linear_modifier = false;
matching_parens parens;
if (!parens.require_open (parser))
@@ -15644,6 +15703,7 @@ c_parser_omp_clause_linear (c_parser *parser, tree list)
kind = OMP_CLAUSE_LINEAR_DEFAULT;
if (kind != OMP_CLAUSE_LINEAR_DEFAULT)
{
+ old_linear_modifier = true;
c_parser_consume_token (parser);
c_parser_consume_token (parser);
}
@@ -15659,15 +15719,95 @@ c_parser_omp_clause_linear (c_parser *parser, tree list)
{
c_parser_consume_token (parser);
location_t expr_loc = c_parser_peek_token (parser)->location;
- c_expr expr = c_parser_expr_no_commas (parser, NULL);
- expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true);
- step = expr.value;
- step = c_fully_fold (step, false, NULL);
- if (!INTEGRAL_TYPE_P (TREE_TYPE (step)))
+ bool has_modifiers = false;
+ if (kind == OMP_CLAUSE_LINEAR_DEFAULT
+ && c_parser_next_token_is (parser, CPP_NAME))
+ {
+ c_token *tok = c_parser_peek_token (parser);
+ const char *p = IDENTIFIER_POINTER (tok->value);
+ unsigned int pos = 0;
+ if (strcmp ("val", p) == 0)
+ pos = 2;
+ else if (strcmp ("step", p) == 0
+ && c_parser_peek_2nd_token (parser)->type == CPP_OPEN_PAREN)
+ {
+ pos = 3;
+ if (c_parser_check_balanced_raw_token_sequence (parser, &pos)
+ && (c_parser_peek_nth_token_raw (parser, pos)->type
+ == CPP_CLOSE_PAREN))
+ ++pos;
+ else
+ pos = 0;
+ }
+ if (pos)
+ {
+ tok = c_parser_peek_nth_token_raw (parser, pos);
+ if (tok->type == CPP_COMMA || tok->type == CPP_CLOSE_PAREN)
+ has_modifiers = true;
+ }
+ }
+ if (has_modifiers)
+ {
+ step = NULL_TREE;
+ while (c_parser_next_token_is (parser, CPP_NAME))
+ {
+ c_token *tok = c_parser_peek_token (parser);
+ const char *p = IDENTIFIER_POINTER (tok->value);
+ if (strcmp ("val", p) == 0)
+ {
+ if (kind != OMP_CLAUSE_LINEAR_DEFAULT)
+ error_at (tok->location, "multiple linear modifiers");
+ kind = OMP_CLAUSE_LINEAR_DEFAULT;
+ c_parser_consume_token (parser);
+ }
+ else if (strcmp ("step", p) == 0)
+ {
+ c_parser_consume_token (parser);
+ matching_parens parens2;
+ if (parens2.require_open (parser))
+ {
+ if (step)
+ error_at (tok->location,
+ "multiple %<step%> modifiers");
+ expr_loc = c_parser_peek_token (parser)->location;
+ c_expr expr = c_parser_expr_no_commas (parser, NULL);
+ expr = convert_lvalue_to_rvalue (expr_loc, expr, false,
+ true);
+ step = c_fully_fold (expr.value, false, NULL);
+ if (!INTEGRAL_TYPE_P (TREE_TYPE (step)))
+ {
+ error_at (clause_loc, "%<linear%> clause step "
+ "expression must be integral");
+ step = integer_one_node;
+ }
+ parens2.skip_until_found_close (parser);
+ }
+ else
+ break;
+ }
+ else
+ break;
+ if (c_parser_next_token_is (parser, CPP_COMMA))
+ {
+ c_parser_consume_token (parser);
+ continue;
+ }
+ break;
+ }
+ if (!step)
+ step = integer_one_node;
+ }
+ else
{
- error_at (clause_loc, "%<linear%> clause step expression must "
- "be integral");
- step = integer_one_node;
+ c_expr expr = c_parser_expr_no_commas (parser, NULL);
+ expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true);
+ step = c_fully_fold (expr.value, false, NULL);
+ if (!INTEGRAL_TYPE_P (TREE_TYPE (step)))
+ {
+ error_at (clause_loc, "%<linear%> clause step expression must "
+ "be integral");
+ step = integer_one_node;
+ }
}
}
@@ -15678,6 +15818,7 @@ c_parser_omp_clause_linear (c_parser *parser, tree list)
{
OMP_CLAUSE_LINEAR_STEP (c) = step;
OMP_CLAUSE_LINEAR_KIND (c) = kind;
+ OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER (c) = old_linear_modifier;
}
parens.skip_until_found_close (parser);
@@ -16031,7 +16172,7 @@ c_parser_omp_clause_affinity (c_parser *parser, tree list)
depend ( depend-modifier , depend-kind: variable-list )
depend-kind:
- in | out | inout | mutexinoutset | depobj
+ in | out | inout | mutexinoutset | depobj | inoutset
depend-modifier:
iterator ( iterators-definition ) */
@@ -16063,6 +16204,8 @@ c_parser_omp_clause_depend (c_parser *parser, tree list)
kind = OMP_CLAUSE_DEPEND_IN;
else if (strcmp ("inout", p) == 0)
kind = OMP_CLAUSE_DEPEND_INOUT;
+ else if (strcmp ("inoutset", p) == 0)
+ kind = OMP_CLAUSE_DEPEND_INOUTSET;
else if (strcmp ("mutexinoutset", p) == 0)
kind = OMP_CLAUSE_DEPEND_MUTEXINOUTSET;
else if (strcmp ("out", p) == 0)
@@ -16221,8 +16364,8 @@ c_parser_omp_clause_map (c_parser *parser, tree list)
else
{
c_parser_error (parser, "%<#pragma omp target%> with "
- "modifier other than %<always%> or %<close%>"
- "on %<map%> clause");
+ "modifier other than %<always%> or "
+ "%<close%> on %<map%> clause");
parens.skip_until_found_close (parser);
return list;
}
@@ -17010,9 +17153,13 @@ c_parser_omp_all_clauses (c_parser *parser, omp_clause_mask mask,
break;
case PRAGMA_OMP_CLAUSE_TO:
if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_LINK)) != 0)
- clauses
- = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_TO_DECLARE,
- clauses);
+ {
+ tree nl = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_ENTER,
+ clauses);
+ for (tree c = nl; c != clauses; c = OMP_CLAUSE_CHAIN (c))
+ OMP_CLAUSE_ENTER_TO (c) = 1;
+ clauses = nl;
+ }
else
clauses = c_parser_omp_clause_to (parser, clauses);
c_name = "to";
@@ -17113,6 +17260,12 @@ c_parser_omp_all_clauses (c_parser *parser, omp_clause_mask mask,
clauses);
c_name = "simd";
break;
+ case PRAGMA_OMP_CLAUSE_ENTER:
+ clauses
+ = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_ENTER,
+ clauses);
+ c_name = "enter";
+ break;
default:
c_parser_error (parser, "expected %<#pragma omp%> clause");
goto saw_error;
@@ -19027,12 +19180,14 @@ c_parser_omp_depobj (c_parser *parser)
kind = OMP_CLAUSE_DEPEND_INOUT;
else if (!strcmp ("mutexinoutset", p2))
kind = OMP_CLAUSE_DEPEND_MUTEXINOUTSET;
+ else if (!strcmp ("inoutset", p2))
+ kind = OMP_CLAUSE_DEPEND_INOUTSET;
}
if (kind == OMP_CLAUSE_DEPEND_SOURCE)
{
clause = error_mark_node;
- error_at (c2_loc, "expected %<in%>, %<out%>, %<inout%> or "
- "%<mutexinoutset%>");
+ error_at (c2_loc, "expected %<in%>, %<out%>, %<inout%>, "
+ "%<mutexinoutset%> or %<inoutset%>");
}
c_parens.skip_until_found_close (parser);
}
@@ -20352,7 +20507,9 @@ c_parser_omp_single (location_t loc, c_parser *parser, bool *if_p)
#define OMP_SCOPE_CLAUSE_MASK \
( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIVATE) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FIRSTPRIVATE) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_REDUCTION) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ALLOCATE) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT))
static tree
@@ -20413,7 +20570,8 @@ c_parser_omp_task (location_t loc, c_parser *parser, bool *if_p)
*/
#define OMP_TASKWAIT_CLAUSE_MASK \
- (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND)
+ ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT))
static void
c_parser_omp_taskwait (c_parser *parser)
@@ -20758,6 +20916,10 @@ c_parser_omp_teams (location_t loc, c_parser *parser,
static tree
c_parser_omp_target_data (location_t loc, c_parser *parser, bool *if_p)
{
+ if (flag_openmp)
+ omp_requires_mask
+ = (enum omp_requires) (omp_requires_mask | OMP_REQUIRES_TARGET_USED);
+
tree clauses
= c_parser_omp_all_clauses (parser, OMP_TARGET_DATA_CLAUSE_MASK,
"#pragma omp target data");
@@ -20853,6 +21015,10 @@ c_parser_omp_target_update (location_t loc, c_parser *parser,
return false;
}
+ if (flag_openmp)
+ omp_requires_mask
+ = (enum omp_requires) (omp_requires_mask | OMP_REQUIRES_TARGET_USED);
+
tree stmt = make_node (OMP_TARGET_UPDATE);
TREE_TYPE (stmt) = void_type_node;
OMP_TARGET_UPDATE_CLAUSES (stmt) = clauses;
@@ -20900,6 +21066,10 @@ c_parser_omp_target_enter_data (location_t loc, c_parser *parser,
return true;
}
+ if (flag_openmp)
+ omp_requires_mask
+ = (enum omp_requires) (omp_requires_mask | OMP_REQUIRES_TARGET_USED);
+
tree clauses
= c_parser_omp_all_clauses (parser, OMP_TARGET_ENTER_DATA_CLAUSE_MASK,
"#pragma omp target enter data");
@@ -20915,6 +21085,14 @@ c_parser_omp_target_enter_data (location_t loc, c_parser *parser,
case GOMP_MAP_ALLOC:
map_seen = 3;
break;
+ case GOMP_MAP_TOFROM:
+ OMP_CLAUSE_SET_MAP_KIND (*pc, GOMP_MAP_TO);
+ map_seen = 3;
+ break;
+ case GOMP_MAP_ALWAYS_TOFROM:
+ OMP_CLAUSE_SET_MAP_KIND (*pc, GOMP_MAP_ALWAYS_TO);
+ map_seen = 3;
+ break;
case GOMP_MAP_FIRSTPRIVATE_POINTER:
case GOMP_MAP_ALWAYS_POINTER:
case GOMP_MAP_ATTACH_DETACH:
@@ -20923,7 +21101,7 @@ c_parser_omp_target_enter_data (location_t loc, c_parser *parser,
map_seen |= 1;
error_at (OMP_CLAUSE_LOCATION (*pc),
"%<#pragma omp target enter data%> with map-type other "
- "than %<to%> or %<alloc%> on %<map%> clause");
+ "than %<to%>, %<tofrom%> or %<alloc%> on %<map%> clause");
*pc = OMP_CLAUSE_CHAIN (*pc);
continue;
}
@@ -20986,6 +21164,10 @@ c_parser_omp_target_exit_data (location_t loc, c_parser *parser,
return true;
}
+ if (flag_openmp)
+ omp_requires_mask
+ = (enum omp_requires) (omp_requires_mask | OMP_REQUIRES_TARGET_USED);
+
tree clauses
= c_parser_omp_all_clauses (parser, OMP_TARGET_EXIT_DATA_CLAUSE_MASK,
"#pragma omp target exit data");
@@ -21002,6 +21184,14 @@ c_parser_omp_target_exit_data (location_t loc, c_parser *parser,
case GOMP_MAP_DELETE:
map_seen = 3;
break;
+ case GOMP_MAP_TOFROM:
+ OMP_CLAUSE_SET_MAP_KIND (*pc, GOMP_MAP_FROM);
+ map_seen = 3;
+ break;
+ case GOMP_MAP_ALWAYS_TOFROM:
+ OMP_CLAUSE_SET_MAP_KIND (*pc, GOMP_MAP_ALWAYS_FROM);
+ map_seen = 3;
+ break;
case GOMP_MAP_FIRSTPRIVATE_POINTER:
case GOMP_MAP_ALWAYS_POINTER:
case GOMP_MAP_ATTACH_DETACH:
@@ -21010,8 +21200,8 @@ c_parser_omp_target_exit_data (location_t loc, c_parser *parser,
map_seen |= 1;
error_at (OMP_CLAUSE_LOCATION (*pc),
"%<#pragma omp target exit data%> with map-type other "
- "than %<from%>, %<release%> or %<delete%> on %<map%>"
- " clause");
+ "than %<from%>, %<tofrom%>, %<release%> or %<delete%> "
+ "on %<map%> clause");
*pc = OMP_CLAUSE_CHAIN (*pc);
continue;
}
@@ -21958,6 +22148,7 @@ c_finish_omp_declare_simd (c_parser *parser, tree fndecl, tree parms,
#define OMP_DECLARE_TARGET_CLAUSE_MASK \
( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_TO) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ENTER) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_LINK) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEVICE_TYPE))
@@ -21972,7 +22163,7 @@ c_parser_omp_declare_target (c_parser *parser)
"#pragma omp declare target");
else if (c_parser_next_token_is (parser, CPP_OPEN_PAREN))
{
- clauses = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_TO_DECLARE,
+ clauses = c_parser_omp_var_list_parens (parser, OMP_CLAUSE_ENTER,
clauses);
clauses = c_finish_omp_clauses (clauses, C_ORT_OMP);
c_parser_skip_to_pragma_eol (parser);
@@ -22004,9 +22195,14 @@ c_parser_omp_declare_target (c_parser *parser)
id = get_identifier ("omp declare target");
if (at2)
{
- error_at (OMP_CLAUSE_LOCATION (c),
- "%qD specified both in declare target %<link%> and %<to%>"
- " clauses", t);
+ if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER)
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD specified both in declare target %<link%> and %qs"
+ " clauses", t, OMP_CLAUSE_ENTER_TO (c) ? "to" : "enter");
+ else
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qD specified both in declare target %<link%> and "
+ "%<to%> or %<enter%> clauses", t);
continue;
}
if (!at1)
@@ -22600,9 +22796,6 @@ c_parser_omp_requires (c_parser *parser)
c_parser_skip_to_pragma_eol (parser, false);
return;
}
- if (p && this_req != OMP_REQUIRES_DYNAMIC_ALLOCATORS)
- sorry_at (cloc, "%qs clause on %<requires%> directive not "
- "supported yet", p);
if (p)
c_parser_consume_token (parser);
if (this_req)
diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h
index c70f0ba..e655afd 100644
--- a/gcc/c/c-tree.h
+++ b/gcc/c/c-tree.h
@@ -685,6 +685,7 @@ extern tree require_complete_type (location_t, tree);
extern bool same_translation_unit_p (const_tree, const_tree);
extern int comptypes (tree, tree);
extern int comptypes_check_different_types (tree, tree, bool *);
+extern int comptypes_check_enum_int (tree, tree, bool *);
extern bool c_vla_type_p (const_tree);
extern bool c_mark_addressable (tree, bool = false);
extern void c_incomplete_type_error (location_t, const_tree, const_tree);
@@ -698,7 +699,8 @@ extern struct c_expr convert_lvalue_to_rvalue (location_t, struct c_expr,
extern tree decl_constant_value_1 (tree, bool);
extern void mark_exp_read (tree);
extern tree composite_type (tree, tree);
-extern tree build_component_ref (location_t, tree, tree, location_t);
+extern tree build_component_ref (location_t, tree, tree, location_t,
+ location_t);
extern tree build_array_ref (location_t, tree, tree);
extern tree build_external_ref (location_t, tree, bool, tree *);
extern void pop_maybe_used (bool);
@@ -835,6 +837,8 @@ set_c_expr_source_range (c_expr *expr,
/* In c-fold.cc */
extern vec<tree> incomplete_record_decls;
+extern const char *c_get_sarif_source_language (const char *filename);
+
#if CHECKING_P
namespace selftest {
extern void run_c_tests (void);
diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index 3075c88..fd0a7f8 100644
--- a/gcc/c/c-typeck.cc
+++ b/gcc/c/c-typeck.cc
@@ -1055,7 +1055,7 @@ comptypes (tree type1, tree type2)
/* Like comptypes, but if it returns non-zero because enum and int are
compatible, it sets *ENUM_AND_INT_P to true. */
-static int
+int
comptypes_check_enum_int (tree type1, tree type2, bool *enum_and_int_p)
{
const struct tagged_tu_seen_cache * tagged_tu_seen_base1 = tagged_tu_seen_base;
@@ -1693,7 +1693,7 @@ function_types_compatible_p (const_tree f1, const_tree f2,
if (args1 == NULL_TREE)
{
- if (flag_isoc2x ? stdarg_p (f2) : !self_promoting_args_p (args2))
+ if (!self_promoting_args_p (args2))
return 0;
/* If one of these types comes from a non-prototype fn definition,
compare that with the other type's arglist.
@@ -1706,7 +1706,7 @@ function_types_compatible_p (const_tree f1, const_tree f2,
}
if (args2 == NULL_TREE)
{
- if (flag_isoc2x ? stdarg_p (f1) : !self_promoting_args_p (args1))
+ if (!self_promoting_args_p (args1))
return 0;
if (TYPE_ACTUAL_ARG_TYPES (f2)
&& type_lists_compatible_p (args1, TYPE_ACTUAL_ARG_TYPES (f2),
@@ -2457,11 +2457,12 @@ should_suggest_deref_p (tree datum_type)
/* Make an expression to refer to the COMPONENT field of structure or
union value DATUM. COMPONENT is an IDENTIFIER_NODE. LOC is the
location of the COMPONENT_REF. COMPONENT_LOC is the location
- of COMPONENT. */
+ of COMPONENT. ARROW_LOC is the location of the first -> operand if
+ it is from -> operator. */
tree
build_component_ref (location_t loc, tree datum, tree component,
- location_t component_loc)
+ location_t component_loc, location_t arrow_loc)
{
tree type = TREE_TYPE (datum);
enum tree_code code = TREE_CODE (type);
@@ -2577,11 +2578,23 @@ build_component_ref (location_t loc, tree datum, tree component,
/* Special-case the error message for "ptr.field" for the case
where the user has confused "." vs "->". */
rich_location richloc (line_table, loc);
- /* "loc" should be the "." token. */
- richloc.add_fixit_replace ("->");
- error_at (&richloc,
- "%qE is a pointer; did you mean to use %<->%>?",
- datum);
+ if (TREE_CODE (datum) == INDIRECT_REF && arrow_loc != UNKNOWN_LOCATION)
+ {
+ richloc.add_fixit_insert_before (arrow_loc, "(*");
+ richloc.add_fixit_insert_after (arrow_loc, ")");
+ error_at (&richloc,
+ "%qE is a pointer to pointer; did you mean to dereference "
+ "it before applying %<->%> to it?",
+ TREE_OPERAND (datum, 0));
+ }
+ else
+ {
+ /* "loc" should be the "." token. */
+ richloc.add_fixit_replace ("->");
+ error_at (&richloc,
+ "%qE is a pointer; did you mean to use %<->%>?",
+ datum);
+ }
return error_mark_node;
}
else if (code != ERROR_MARK)
@@ -8438,6 +8451,7 @@ struct initializer_stack
char top_level;
char require_constant_value;
char require_constant_elements;
+ char designated;
rich_location *missing_brace_richloc;
};
@@ -8464,6 +8478,7 @@ start_init (tree decl, tree asmspec_tree ATTRIBUTE_UNUSED, int top_level,
p->top_level = constructor_top_level;
p->next = initializer_stack;
p->missing_brace_richloc = richloc;
+ p->designated = constructor_designated;
initializer_stack = p;
constructor_decl = decl;
@@ -8522,6 +8537,7 @@ finish_init (void)
require_constant_value = p->require_constant_value;
require_constant_elements = p->require_constant_elements;
constructor_stack = p->constructor_stack;
+ constructor_designated = p->designated;
constructor_range_stack = p->constructor_range_stack;
constructor_elements = p->elements;
spelling = p->spelling;
@@ -8731,7 +8747,9 @@ push_init_level (location_t loc, int implicit,
constructor_depth = SPELLING_DEPTH ();
constructor_elements = NULL;
constructor_incremental = 1;
- constructor_designated = 0;
+ /* If the upper initializer is designated, then mark this as
+ designated too to prevent bogus warnings. */
+ constructor_designated = p->designated;
constructor_pending_elts = 0;
if (!implicit)
{
@@ -8756,9 +8774,6 @@ push_init_level (location_t loc, int implicit,
push_member_name (constructor_fields);
constructor_depth++;
}
- /* If upper initializer is designated, then mark this as
- designated too to prevent bogus warnings. */
- constructor_designated = p->designated;
}
else if (TREE_CODE (constructor_type) == ARRAY_TYPE)
{
@@ -12213,7 +12228,8 @@ build_binary_op (location_t location, enum tree_code code,
{
doing_shift = true;
if (TREE_CODE (op0) == INTEGER_CST
- && tree_int_cst_sgn (op0) < 0)
+ && tree_int_cst_sgn (op0) < 0
+ && !TYPE_OVERFLOW_WRAPS (type0))
{
/* Don't reject a left shift of a negative value in a context
where a constant expression is needed in C90. */
@@ -13372,7 +13388,7 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types,
{
error_at (OMP_CLAUSE_LOCATION (c),
"expected single pointer in %qs clause",
- c_omp_map_clause_name (c, ort == C_ORT_ACC));
+ user_omp_clause_code_name (c, ort == C_ORT_ACC));
return error_mark_node;
}
}
@@ -14095,7 +14111,7 @@ c_oacc_check_attachments (tree c)
if (TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE)
{
error_at (OMP_CLAUSE_LOCATION (c), "expected pointer in %qs clause",
- c_omp_map_clause_name (c, true));
+ user_omp_clause_code_name (c, true));
return true;
}
}
@@ -14462,11 +14478,13 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
need_implicitly_determined = true;
t = OMP_CLAUSE_DECL (c);
if (ort != C_ORT_OMP_DECLARE_SIMD
- && OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_DEFAULT)
+ && OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_DEFAULT
+ && OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER (c))
{
error_at (OMP_CLAUSE_LOCATION (c),
"modifier should not be specified in %<linear%> "
- "clause on %<simd%> or %<for%> constructs");
+ "clause on %<simd%> or %<for%> constructs when not "
+ "using OpenMP 5.2 modifiers");
OMP_CLAUSE_LINEAR_KIND (c) = OMP_CLAUSE_LINEAR_DEFAULT;
}
if (!INTEGRAL_TYPE_P (TREE_TYPE (t))
@@ -14829,6 +14847,18 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
}
if (t == error_mark_node)
remove = true;
+ else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND
+ && t == ridpointers[RID_OMP_ALL_MEMORY])
+ {
+ if (OMP_CLAUSE_DEPEND_KIND (c) != OMP_CLAUSE_DEPEND_OUT
+ && OMP_CLAUSE_DEPEND_KIND (c) != OMP_CLAUSE_DEPEND_INOUT)
+ {
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<omp_all_memory%> used with %<depend%> kind "
+ "other than %<out%> or %<inout%>");
+ remove = true;
+ }
+ }
else if (!lvalue_p (t))
{
error_at (OMP_CLAUSE_LOCATION (c),
@@ -14870,24 +14900,32 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
}
if (!remove)
{
- tree addr = build_unary_op (OMP_CLAUSE_LOCATION (c), ADDR_EXPR,
- t, false);
- if (addr == error_mark_node)
- remove = true;
+ if (t == ridpointers[RID_OMP_ALL_MEMORY])
+ t = null_pointer_node;
else
{
+ tree addr = build_unary_op (OMP_CLAUSE_LOCATION (c),
+ ADDR_EXPR, t, false);
+ if (addr == error_mark_node)
+ {
+ remove = true;
+ break;
+ }
t = build_indirect_ref (OMP_CLAUSE_LOCATION (c), addr,
RO_UNARY_STAR);
if (t == error_mark_node)
- remove = true;
- else if (TREE_CODE (OMP_CLAUSE_DECL (c)) == TREE_LIST
- && TREE_PURPOSE (OMP_CLAUSE_DECL (c))
- && (TREE_CODE (TREE_PURPOSE (OMP_CLAUSE_DECL (c)))
- == TREE_VEC))
- TREE_VALUE (OMP_CLAUSE_DECL (c)) = t;
- else
- OMP_CLAUSE_DECL (c) = t;
+ {
+ remove = true;
+ break;
+ }
}
+ if (TREE_CODE (OMP_CLAUSE_DECL (c)) == TREE_LIST
+ && TREE_PURPOSE (OMP_CLAUSE_DECL (c))
+ && (TREE_CODE (TREE_PURPOSE (OMP_CLAUSE_DECL (c)))
+ == TREE_VEC))
+ TREE_VALUE (OMP_CLAUSE_DECL (c)) = t;
+ else
+ OMP_CLAUSE_DECL (c) = t;
}
break;
@@ -15212,37 +15250,40 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
}
break;
- case OMP_CLAUSE_TO_DECLARE:
+ case OMP_CLAUSE_ENTER:
case OMP_CLAUSE_LINK:
t = OMP_CLAUSE_DECL (c);
+ const char *cname;
+ cname = omp_clause_code_name[OMP_CLAUSE_CODE (c)];
+ if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER
+ && OMP_CLAUSE_ENTER_TO (c))
+ cname = "to";
if (TREE_CODE (t) == FUNCTION_DECL
- && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TO_DECLARE)
+ && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER)
;
else if (!VAR_P (t))
{
- if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TO_DECLARE)
+ if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER)
error_at (OMP_CLAUSE_LOCATION (c),
"%qE is neither a variable nor a function name in "
- "clause %qs", t,
- omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
+ "clause %qs", t, cname);
else
error_at (OMP_CLAUSE_LOCATION (c),
- "%qE is not a variable in clause %qs", t,
- omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
+ "%qE is not a variable in clause %qs", t, cname);
remove = true;
}
else if (DECL_THREAD_LOCAL_P (t))
{
error_at (OMP_CLAUSE_LOCATION (c),
"%qD is threadprivate variable in %qs clause", t,
- omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
+ cname);
remove = true;
}
else if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (t)))
{
error_at (OMP_CLAUSE_LOCATION (c),
"%qD does not have a mappable type in %qs clause", t,
- omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
+ cname);
remove = true;
}
if (remove)
@@ -15893,6 +15934,12 @@ c_build_va_arg (location_t loc1, tree expr, location_t loc2, tree type)
"type %qT", type);
return error_mark_node;
}
+ else if (TREE_CODE (type) == FUNCTION_TYPE)
+ {
+ error_at (loc2, "second argument to %<va_arg%> is a function type %qT",
+ type);
+ return error_mark_node;
+ }
else if (warn_cxx_compat && TREE_CODE (type) == ENUMERAL_TYPE)
warning_at (loc2, OPT_Wc___compat,
"C++ requires promoted type, not enum type, in %<va_arg%>");
diff --git a/gcc/c/gimple-parser.cc b/gcc/c/gimple-parser.cc
index 31075237..b909eac 100644
--- a/gcc/c/gimple-parser.cc
+++ b/gcc/c/gimple-parser.cc
@@ -330,13 +330,17 @@ c_parser_parse_gimple_body (c_parser *cparser, char *gimple_pass,
}
gsi_remove (&gsi, true);
}
- /* Fill SSA name gaps, putting them on the freelist. */
+ /* Fill SSA name gaps, putting them on the freelist and diagnose
+ SSA names without definition. */
for (unsigned i = 1; i < num_ssa_names; ++i)
if (!ssa_name (i))
{
tree name = make_ssa_name_fn (cfun, integer_type_node, NULL, i);
release_ssa_name_fn (cfun, name);
}
+ else if (!SSA_NAME_DEF_STMT (ssa_name (i)))
+ error ("SSA name %qE with version %d has no definition",
+ ssa_name (i), i);
/* No explicit virtual operands (yet). */
bitmap_obstack_initialize (NULL);
update_ssa (TODO_update_ssa_only_virtuals);
@@ -1796,7 +1800,7 @@ c_parser_gimple_postfix_expression_after_primary (gimple_parser &parser,
finish = c_parser_peek_token (parser)->get_finish ();
c_parser_consume_token (parser);
expr.value = build_component_ref (op_loc, expr.value, ident,
- comp_loc);
+ comp_loc, UNKNOWN_LOCATION);
set_c_expr_source_range (&expr, start, finish);
expr.original_code = ERROR_MARK;
if (TREE_CODE (expr.value) != COMPONENT_REF)
@@ -1844,7 +1848,8 @@ c_parser_gimple_postfix_expression_after_primary (gimple_parser &parser,
expr.value = build_component_ref (op_loc,
build_simple_mem_ref_loc
(op_loc, expr.value),
- ident, comp_loc);
+ ident, comp_loc,
+ expr.get_location ());
set_c_expr_source_range (&expr, start, finish);
expr.original_code = ERROR_MARK;
if (TREE_CODE (expr.value) != COMPONENT_REF)
@@ -2061,16 +2066,34 @@ c_parser_gimple_declaration (gimple_parser &parser)
/* Handle SSA name decls specially, they do not go into the identifier
table but we simply build the SSA name for later lookup. */
unsigned version, ver_offset;
- if (declarator->kind == cdk_id
- && is_gimple_reg_type (specs->type)
- && c_parser_parse_ssa_name_id (declarator->u.id.id,
+ /* Handle SSA pointer declarations in a very simplistic ways, we
+ probably would like to call grokdeclarator in a special mode to
+ just build the type of the decl - start_decl already pushes
+ the identifier to the bindings for lookup, something we do not
+ want. */
+ struct c_declarator *id_declarator = declarator;
+ while (id_declarator->kind == cdk_pointer)
+ id_declarator = id_declarator->declarator;
+ if (id_declarator->kind == cdk_id
+ && (declarator->kind == cdk_pointer
+ || is_gimple_reg_type (specs->type))
+ && c_parser_parse_ssa_name_id (id_declarator->u.id.id,
&version, &ver_offset)
/* The following restricts it to unnamed anonymous SSA names
which fails parsing of named ones in dumps (we could
decide to not dump their name for -gimple). */
&& ver_offset == 0)
- c_parser_parse_ssa_name (parser, declarator->u.id.id, specs->type,
- version, ver_offset);
+ {
+ struct c_declarator *p = declarator;
+ tree type = specs->type;
+ while (p->kind == cdk_pointer)
+ {
+ type = build_pointer_type (type);
+ p = p->declarator;
+ }
+ c_parser_parse_ssa_name (parser, id_declarator->u.id.id, type,
+ version, ver_offset);
+ }
else
{
tree postfix_attrs = NULL_TREE;