From 916ec36d0a3ef3fe44c1657746922a5f18b60326 Mon Sep 17 00:00:00 2001 From: Patrick Palka Date: Mon, 27 Dec 2021 10:01:42 -0500 Subject: [PATCH] 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. --- gcc/testsuite/g++.dg/template/sfinae32a.C | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 gcc/testsuite/g++.dg/template/sfinae32a.C 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 auto f(T* p) -> decltype(p[N]); +template auto f(T* p) -> decltype(p[-N]); +template auto f(T* p) -> decltype(N[p]); +template void f(T* p); + +template auto g(T* p, int n) -> decltype(p[n]); +template auto g(T* p, int n) -> decltype(p[-n]); +template auto g(T* p, int n) -> decltype(n[p]); +template void g(T* p, int n); + +struct Incomplete; + +int main() { + f(nullptr); + f(nullptr); + f(nullptr); + f(nullptr); + f(nullptr); + + g(nullptr, 0); +} -- 2.7.4