From 19c62569ccf20d2744b63482a470474391d28c02 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Fri, 29 Apr 2022 09:38:40 -0400 Subject: [PATCH] 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. --- gcc/testsuite/g++.dg/cpp0x/Wnarrowing20.C | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/Wnarrowing20.C diff --git a/gcc/testsuite/g++.dg/cpp0x/Wnarrowing20.C b/gcc/testsuite/g++.dg/cpp0x/Wnarrowing20.C new file mode 100644 index 0000000..17a6001 --- /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 +auto f1() -> decltype(S{2.0}, void()) { } // { dg-error "narrowing conversion" } + +template +auto f2() -> decltype(S{2.0}, 1) { return 1; } // { dg-error "narrowing conversion" } + +template +auto f3() -> decltype(void(), S{2.0}, 1) { return 1; } // { dg-error "narrowing conversion" } + +template +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 +auto f5(double v) -> decltype((S{id(v)}, 1)) { return 1; } // { dg-error "narrowing conversion" } + +template +auto f6(int v) -> decltype((S{id(v)}, 1)) { return 1; } -- 2.7.4