aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2021-12-27 10:01:42 -0500
committerPatrick Palka <ppalka@redhat.com>2021-12-27 10:01:42 -0500
commit916ec36d0a3ef3fe44c1657746922a5f18b60326 (patch)
treeac70f29d20a40cf5f28ec81242c8e0d6fdefb6e2 /gcc
parent88cdcb5c18d73bfc9960d774c678f0e8103b8031 (diff)
downloadgcc-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.C24
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);
+}