First comments; I need to have a deeper, but now I need fetch some victuals.

Paul-Antoine Arras wrote:
This patch adds support to the C front-end to parse the `dispatch` construct and
the `adjust_args` clause. It also includes some common C/C++ bits for pragmas
and attributes.

Additional common C/C++ testcases are in a later patch in the series.

. . .

--- a/gcc/c-family/c-attribs.cc
+++ b/gcc/c-family/c-attribs.cc
@@ -571,6 +571,8 @@ const struct attribute_spec c_common_gnu_attributes[] =
                              handle_omp_declare_variant_attribute, NULL },
    { "omp declare variant variant", 0, -1, true,  false, false, false,
                              handle_omp_declare_variant_attribute, NULL },
+  { "omp declare variant adjust_args need_device_ptr", 0, -1, true,  false, 
false, false,
+                             handle_omp_declare_variant_attribute, NULL },

the first line is 9 characters too long ...

--- a/gcc/c/c-parser.cc
+++ b/gcc/c/c-parser.cc
@@ -1747,6 +1747,8 @@ static void c_parser_omp_assumption_clauses (c_parser *, 
bool);
  static void c_parser_omp_allocate (c_parser *);
  static void c_parser_omp_assumes (c_parser *);
  static bool c_parser_omp_ordered (c_parser *, enum pragma_context, bool *);
+static tree
+c_parser_omp_dispatch (location_t, c_parser *);

Spurious line break after 'tree' in the declaration.

+// Adapted from c_parser_expr_no_commas

While parts of GCC have started to use // comments of C++ and C99,
this file seemingly hasn't and I am not sure that you want to be the
first one to adds it ...

I think this needs some words on the purpose of this function,
i.e. why it exists - alias what syntax it support and does not
support.

+static tree
+c_parser_omp_dispatch_body (c_parser *parser)
+{

...

+  lhs = c_parser_conditional_expression (parser, NULL, NULL);
+  if (TREE_CODE (lhs.value) == CALL_EXPR)
+    return lhs.value;
+  else
+    {

You can save on indentation and curly braces by removing the 'else {'
as after the 'return' you never need to handle the CALL_EXPR case.

+      location_t op_location = c_parser_peek_token (parser)->location;
+      if (!c_parser_require (parser, CPP_EQ, "expected %<=%>"))
+       return error_mark_node;
+
+      /* Parse function name*/

(Possibly a '.' and then) two spaces before '*/'.

+       for (int i = 0; i < 3; i++)
+         {
+           sizeof_arg[i] = NULL_TREE;
+           sizeof_arg_loc[i] = UNKNOWN_LOCATION;

Wrong size: c_parser_expr_list expects that 6 not 3 values exist.

Looks as if your code predates Jakub's change of Dec 2023:
r14-6741-ge7dd72aefed851 Split -Wcalloc-transposed-args warning from -Walloc-size, -Walloc-size fixes

Tobias

Reply via email to