https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100872

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
The problem is that
   aligned(a : X * 2)

In pt.c's apply_late_template_attributes, we have:
 <tree_list 0x7ffff71372f8
    purpose <identifier_node 0x7ffff7131840 operator bindings
        normal local bindings <(nil)>>
    value <tree_list 0x7ffff7137320
        purpose <identifier_node 0x7ffff6fc4400 operator+ tree_2
            simple-op local bindings <(nil)>> value <error_mark
0x7ffff6fabeb8>>
    chain <tree_list 0x7ffff7137118 tree_0
        purpose <identifier_node 0x7ffff71317c0 omp declare simd
            normal local bindings <(nil)>>
        value <tree_list 0x7ffff71370f0
            value <omp_clause 0x7ffff6fb6f30 aligned
                op-0: <integer_cst 0x7ffff6fcc288 1>
                op-1: <mult_expr 0x7ffff71370c8>>>>>

The comment in apply_late_template_attributes states:

  /* save_template_attributes puts the dependent attributes at the beginning of
     the list; find the non-dependent ones.  */
  for (t = attributes; t; t = TREE_CHAIN (t))
    if (!ATTR_IS_DEPENDENT (t))
      break;

But as the first item is !ATTR_IS_DEPEND, attributes == nondep and the
following loop is skipped - also for 'tree_0', which contains our 'omp declare
simd':

  for (t = attributes; t != nondep; t = TREE_CHAIN (t))
    {
      *q = tsubst_attribute (t, decl_p, args, complain, in_decl);

The latter, i.e. 'tree_0' has a proper
43480               ATTR_IS_DEPENDENT (c) = 1;
set in cp_parser_late_parsing_omp_declare_simd.

However, the problem seems to be that save_template_attributes is never run for
the fndel.

* It is run for 'class TVV' itself.
* And then there is the call:
  tsubst_decl -> tsubst_function_decl
  -> apply_late_template_attributes
  which has the tree as shown above.

Reply via email to