@acoplan wrote in 
https://forge.sourceware.org/gcc/gcc/pulls/186#issuecomment-6649:

> I think this fails to warn if users use `+tme` in an attribute or target 
> pragma. I tried the following testcases:
> 
> ```text
> __attribute__((target("+tme")))
> void f(void) {}
> ```
> 
> and:
> 
> ```text
> #pragma GCC target ("+tme")
> ```
> 
> we should probably handle those cases too. Otherwise LGTM.

The latest version attempts to address this, but there are limitations due to 
the way the backend is called with new information (there's no real validation 
hook for attributes).

I've hooked into the apply-attribute code to catch the case where TME gets 
enabled when this was previously not the case.  It handles most of the useful 
cases, but not all.  Most notably it doesn't catch the case where an attribute 
is added, but the current architecture already enables TME, so
```
#pragma GCC target ("+tme")
```
will generate a warning if compiled with `-march=armv8-a`, but not if compiled 
with `-march=arm8v-a+tme` (you'll still get a warning for the command-line 
option, but it will mask the code warning).

There seems to be nothing we can do about that with the current hooks; making 
the hook warn every time it is called and TME is enabled will simply flood the 
output with warnings that aren't helpful.  So this is the best compromise.

An additional issue is that precise location information is not available when 
the hook is called - it seems to be pretty close most of the time though, so we 
end up with warnings like:
```
test.c:3:1: warning: the architecture extension ‘+tme’ is deprecated 
[-Wdeprecated]
    3 | [[gnu::target("+tme")]] void e(void) {}
      | ^
```
but 
```
__attribute__((target("+tme")))
void f(void) {}
```
will warn as
```
test.c:6:1: warning: the architecture extension ‘+tme’ is deprecated 
[-Wdeprecated]
    6 | void f(void) {}
      | ^~~~
```
which is slightly confusing given that the attribute is on the preceding line.

--
https://forge.sourceware.org/gcc/gcc/pulls/186#issuecomment-6714

Reply via email to