diff options
author | Patrick Palka <ppalka@redhat.com> | 2021-12-27 10:01:42 -0500 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2021-12-27 10:01:42 -0500 |
commit | 916ec36d0a3ef3fe44c1657746922a5f18b60326 (patch) | |
tree | ac70f29d20a40cf5f28ec81242c8e0d6fdefb6e2 /gcc | |
parent | 88cdcb5c18d73bfc9960d774c678f0e8103b8031 (diff) | |
download | gcc-916ec36d0a3ef3fe44c1657746922a5f18b60326.zip gcc-916ec36d0a3ef3fe44c1657746922a5f18b60326.tar.gz gcc-916ec36d0a3ef3fe44c1657746922a5f18b60326.tar.bz2 |
c++: Add testcase for SFINAE w/ p[N] and incomplete type [PR101239]
The r12-6123 fix for SFINAE with p+N and incomplete type also fixed
the analogous issue with p[N].
PR c++/101239
gcc/testsuite/ChangeLog:
* g++.dg/template/sfinae32a.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/g++.dg/template/sfinae32a.C | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/template/sfinae32a.C b/gcc/testsuite/g++.dg/template/sfinae32a.C new file mode 100644 index 0000000..e9dbe88 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/sfinae32a.C @@ -0,0 +1,24 @@ +// PR c++/101239 +// { dg-do compile { target c++11 } } + +template<class T, int N> auto f(T* p) -> decltype(p[N]); +template<class T, int N> auto f(T* p) -> decltype(p[-N]); +template<class T, int N> auto f(T* p) -> decltype(N[p]); +template<class T, int N> void f(T* p); + +template<class T> auto g(T* p, int n) -> decltype(p[n]); +template<class T> auto g(T* p, int n) -> decltype(p[-n]); +template<class T> auto g(T* p, int n) -> decltype(n[p]); +template<class T> void g(T* p, int n); + +struct Incomplete; + +int main() { + f<Incomplete, 0>(nullptr); + f<Incomplete, 1>(nullptr); + f<Incomplete, -1>(nullptr); + f<Incomplete, 7>(nullptr); + f<Incomplete, -7>(nullptr); + + g<Incomplete>(nullptr, 0); +} |