https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65011
Bug ID: 65011
Summary: misleading error message for target attribute
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: drepper.fsp+rhbz at gmail dot com
The target attribute named "default" is handled special and this causes a
problem in error reporting. If I have code like this:
__attribute__((target("sse2","avx2")))
void foo(double *__restrict r, const double *__restrict a, const double
*__restrict b, double f)
{
for (unsigned i = 0; i < 128; ++i)
r[i] = a[i] * f + b[i];
}
the compiler doesn't complain even though it ignores one of the parameters of
the target attribute. That's a question for another day.
The problem is that replacing one of the strings with "default" causes a
problem:
$ cat u.cc
__attribute__((target("default","avx2")))
void foo(double *__restrict r, const double *__restrict a, const double
*__restrict b, double f)
{
for (unsigned i = 0; i < 128; ++i)
r[i] = a[i] * f + b[i];
}
$ local-gcc -c -O3 u.cc
u.cc:10:96: error: attribute(target("default")) is unknown
void foo(double *__restrict r, const double *__restrict a, const double
*__restrict b, double f)
^
Of course "default" is known. But it is not parsed in
ix86_valid_target_attribute_inner_p. It seems (haven't verified it) that the
caller checks for "default" being the entire string and if this is not the case
defers parsing to ix86_valid_target_attribute_inner_p.