aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2022-06-17 13:05:50 +0200
committerMartin Liska <mliska@suse.cz>2022-06-17 13:05:50 +0200
commit910ef4ff32f3a53dbd12445e1eb8c5349d047140 (patch)
treeef0772e400ad08ab2bef318992cc2c1bf6fb5b7e /gcc/c
parentcad2e08f6c249937e10ad5ae0d4a117923979efb (diff)
parent94018fd2675190a4353cb199da4957538f070886 (diff)
downloadgcc-910ef4ff32f3a53dbd12445e1eb8c5349d047140.zip
gcc-910ef4ff32f3a53dbd12445e1eb8c5349d047140.tar.gz
gcc-910ef4ff32f3a53dbd12445e1eb8c5349d047140.tar.bz2
Merge branch 'master' into devel/sphinx
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog148
-rw-r--r--gcc/c/Make-lang.in2
-rw-r--r--gcc/c/c-decl.cc90
-rw-r--r--gcc/c/c-lang.cc12
-rw-r--r--gcc/c/c-objc-common.cc9
-rw-r--r--gcc/c/c-parser.cc216
-rw-r--r--gcc/c/c-tree.h6
-rw-r--r--gcc/c/c-typeck.cc116
-rw-r--r--gcc/c/gimple-parser.cc5
9 files changed, 503 insertions, 101 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 1c0d5ec..077b726 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,151 @@
+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
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-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 129dd72..1704a52 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)
@@ -12752,6 +12771,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 +13048,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,6 +13179,7 @@ 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))
{
c_expr t_expr;
@@ -13154,6 +13190,7 @@ c_parser_omp_variable_list (c_parser *parser,
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))
@@ -13167,7 +13204,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:
@@ -15630,7 +15668,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)
@@ -15638,6 +15686,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))
@@ -15653,6 +15702,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);
}
@@ -15668,15 +15718,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))
{
- error_at (clause_loc, "%<linear%> clause step expression must "
- "be integral");
- step = integer_one_node;
+ 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
+ {
+ 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;
+ }
}
}
@@ -15687,6 +15817,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);
@@ -16040,7 +16171,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 ) */
@@ -16072,6 +16203,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)
@@ -17019,9 +17152,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";
@@ -17122,6 +17259,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;
@@ -19036,12 +19179,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);
}
@@ -20361,7 +20506,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
@@ -20422,7 +20569,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)
@@ -21967,6 +22115,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))
@@ -21981,7 +22130,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);
@@ -22013,9 +22162,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)
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 c0812de..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;
@@ -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)
{
@@ -14463,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))
@@ -14830,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),
@@ -14871,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;
@@ -15213,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)
@@ -15894,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 d1afd42..b909eac 100644
--- a/gcc/c/gimple-parser.cc
+++ b/gcc/c/gimple-parser.cc
@@ -1800,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)
@@ -1848,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)