public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-44] c++: Add fixed test [PR78244]
@ 2022-04-29 13:39 Marek Polacek
  0 siblings, 0 replies; only message in thread
From: Marek Polacek @ 2022-04-29 13:39 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:19c62569ccf20d2744b63482a470474391d28c02

commit r13-44-g19c62569ccf20d2744b63482a470474391d28c02
Author: Marek Polacek <polacek@redhat.com>
Date:   Fri Apr 29 09:38:40 2022 -0400

    c++: Add fixed test [PR78244]
    
    This was finally fixed for GCC 11 by r11-434.
    
            PR c++/78244
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp0x/Wnarrowing20.C: New test.

Diff:
---
 gcc/testsuite/g++.dg/cpp0x/Wnarrowing20.C | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/gcc/testsuite/g++.dg/cpp0x/Wnarrowing20.C b/gcc/testsuite/g++.dg/cpp0x/Wnarrowing20.C
new file mode 100644
index 00000000000..17a6001266d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/Wnarrowing20.C
@@ -0,0 +1,26 @@
+// PR c++/78244
+// { dg-do compile { target c++11 } }
+
+struct S { S(int); int d; };
+
+template <typename T>
+auto f1() -> decltype(S{2.0}, void()) { } // { dg-error "narrowing conversion" }
+
+template <typename T>
+auto f2() -> decltype(S{2.0}, 1) { return 1; } // { dg-error "narrowing conversion" }
+
+template <typename T>
+auto f3() -> decltype(void(), S{2.0}, 1) { return 1; } // { dg-error "narrowing conversion" }
+
+template <typename T>
+auto f4() -> decltype((S{2.0}, 1)) { return 1; } // { dg-error "narrowing conversion" }
+
+// Test OVERLOAD in a template.
+int id(int v) { return v; }
+double id(double v) { return v; }
+
+template <typename T>
+auto f5(double v) -> decltype((S{id(v)}, 1)) { return 1; } // { dg-error "narrowing conversion" }
+
+template <typename T>
+auto f6(int v) -> decltype((S{id(v)}, 1)) { return 1; }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-29 13:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-29 13:39 [gcc r13-44] c++: Add fixed test [PR78244] Marek Polacek

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).