[clang] [clang] Fix missing diagnostic of declaration use when accessing TypeDecls through typename access (PR #129681)
Hans Wennborg via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 10 05:46:52 PDT 2025
zmodem wrote:
We're seeing new -Wunguarded-availability warnings after this. A reduced example:
```
$ cat /tmp/x.cc
template<class T> struct remove_cv { typedef T type; };
struct __attribute__((__availability__(android, introduced = 29))) AAudioStreamWrapper { };
template <typename T> struct Foo {
T *p;
};
template <typename T> struct Bar {
typename remove_cv<T>::type *p;
};
struct __attribute__((__availability__(android, introduced = 29))) User {
AAudioStreamWrapper a; // okay
Foo<AAudioStreamWrapper> b; // okay
Bar<AAudioStreamWrapper> c; // not okay?
};
$ build/bin/clang -c -target aarch64-linux-android26 -Wunguarded-availability /tmp/x.cc
/tmp/x.cc:10:26: warning: 'AAudioStreamWrapper' is only available on Android 29 or newer [-Wunguarded-availability]
10 | typename remove_cv<T>::type *p;
| ^
/tmp/x.cc:18:28: note: in instantiation of template class 'Bar<AAudioStreamWrapper>' requested here
18 | Bar<AAudioStreamWrapper> c; // not okay?
| ^
/tmp/x.cc:3:68: note: 'AAudioStreamWrapper' has been marked as being introduced in Android 29 here, but the deployment target is Android 26
3 | struct __attribute__((__availability__(android, introduced = 29))) AAudioStreamWrapper { };
| ^
/tmp/x.cc:9:30: note: annotate 'Bar<AAudioStreamWrapper>' with an availability attribute to silence this warning
9 | template <typename T> struct Bar {
| ^
1 warning generated.
```
I believe the new warning is not correct, since `c` (like the other members) is in fact guarded by the availability attribute.
I'll revert to green for now until this can be investigated.
https://github.com/llvm/llvm-project/pull/129681
More information about the cfe-commits
mailing list