public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-6124] c++: Add testcase for SFINAE w/ p[N] and incomplete type [PR101239]
@ 2021-12-27 15:01 Patrick Palka
0 siblings, 0 replies; only message in thread
From: Patrick Palka @ 2021-12-27 15:01 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:916ec36d0a3ef3fe44c1657746922a5f18b60326
commit r12-6124-g916ec36d0a3ef3fe44c1657746922a5f18b60326
Author: Patrick Palka <ppalka@redhat.com>
Date: Mon Dec 27 10:01:42 2021 -0500
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.
Diff:
---
gcc/testsuite/g++.dg/template/sfinae32a.C | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/gcc/testsuite/g++.dg/template/sfinae32a.C b/gcc/testsuite/g++.dg/template/sfinae32a.C
new file mode 100644
index 00000000000..e9dbe88be4f
--- /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);
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-12-27 15:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-27 15:01 [gcc r12-6124] c++: Add testcase for SFINAE w/ p[N] and incomplete type [PR101239] Patrick Palka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).