https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92648
Bug ID: 92648
Summary: Handling of unknown attributes
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jakub at gcc dot gnu.org
Target Milestone: ---
It is still unclear how exactly OpenMP attributes will look like (at least most
of them), but it seems the C++ FE (unlike the C FE) attempts to parse the
arguments as expression list instead of skipping it.
Consider:
void
foo (int x, int y, int z, int u)
{
[[omp::for (linear(x, y: 2), private(z), reduction(+:u))]];
}
ud.C:4:26: error: expected ‘)’ before ‘:’ token
4 | [[omp::for (linear(x, y: 2), private(z), reduction(+:u))]];
| ~ ^
| )
ud.C:4:15: error: ‘linear’ was not declared in this scope
4 | [[omp::for (linear(x, y: 2), private(z), reduction(+:u))]];
| ^~~~~~
ud.C:4:32: error: expected primary-expression before ‘private’
4 | [[omp::for (linear(x, y: 2), private(z), reduction(+:u))]];
| ^~~~~~~
ud.C:4:55: error: expected primary-expression before ‘:’ token
4 | [[omp::for (linear(x, y: 2), private(z), reduction(+:u))]];
| ^
ud.C:4:44: error: ‘reduction’ was not declared in this scope
4 | [[omp::for (linear(x, y: 2), private(z), reduction(+:u))]];
| ^~~~~~~~~
ud.C:4:3: warning: attributes at the beginning of statement are ignored
[-Wattributes]
4 | [[omp::for (linear(x, y: 2), private(z), reduction(+:u))]];
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Compare that to C:
ud.C: In function ‘foo’:
ud.C:4:3: warning: ‘for’ attribute ignored [-Wattributes]
4 | [[omp::for (linear(x, y: 2), private(z), reduction(+:u))]];
| ^
or clang++:
ud.C:4:5: warning: unknown attribute 'for' ignored [-Wunknown-attributes]
[[omp::for (linear(x, y: 2), private(z), reduction(+:u))]];
^
1 warning generated.
I think the syntax just says that the arguments are balanced token sequences,
but if the compiler doesn't know the attribute, it can't assume anything
further.