public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Marek Polacek <mpolacek@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-44] c++: Add fixed test [PR78244]
Date: Fri, 29 Apr 2022 13:39:52 +0000 (GMT)	[thread overview]
Message-ID: <20220429133952.DD78D389EC58@sourceware.org> (raw)

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; }


                 reply	other threads:[~2022-04-29 13:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220429133952.DD78D389EC58@sourceware.org \
    --to=mpolacek@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).