public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/redhat/heads/gcc-8-branch)] c++: Bogus error with alignof [PR90736] Date: Thu, 17 Sep 2020 17:00:38 +0000 (GMT) [thread overview] Message-ID: <20200917170038.20B6F3945C25@sourceware.org> (raw) https://gcc.gnu.org/g:4dc2d0cabe9b3986078cb62bd1d2f71707f4156a commit 4dc2d0cabe9b3986078cb62bd1d2f71707f4156a Author: Marek Polacek <polacek@redhat.com> Date: Mon May 4 13:25:42 2020 -0400 c++: Bogus error with alignof [PR90736] PR c++/90736 - bogus error with alignof. * constexpr.c (adjust_temp_type): Use cv_unqualified type. Diff: --- gcc/cp/ChangeLog | 8 ++++++++ gcc/cp/constexpr.c | 4 +++- gcc/testsuite/g++.dg/cpp0x/alignof5.C | 6 ++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d1d829a8bca..ebebbe29e38 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2020-05-04 Marek Polacek <polacek@redhat.com> + + Backported from mainline + 2019-06-12 Marek Polacek <polacek@redhat.com> + + PR c++/90736 - bogus error with alignof. + * constexpr.c (adjust_temp_type): Use cv_unqualified type. + 2020-04-04 Jason Merrill <jason@redhat.com> PR c++/91377 diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index bebe72e4db9..f68ad758a14 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -1255,7 +1255,9 @@ adjust_temp_type (tree type, tree temp) if (TREE_CODE (temp) == EMPTY_CLASS_EXPR) return build0 (EMPTY_CLASS_EXPR, type); gcc_assert (scalarish_type_p (type)); - return cp_fold_convert (type, temp); + /* Now we know we're dealing with a scalar, and a prvalue of non-class + type is cv-unqualified. */ + return cp_fold_convert (cv_unqualified (type), temp); } /* Callback for walk_tree used by unshare_constructor. */ diff --git a/gcc/testsuite/g++.dg/cpp0x/alignof5.C b/gcc/testsuite/g++.dg/cpp0x/alignof5.C new file mode 100644 index 00000000000..09354d3e1d0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alignof5.C @@ -0,0 +1,6 @@ +// PR c++/90736 - bogus error with alignof. +// { dg-do compile { target c++11 } } + +constexpr int fn(const int b) { return b; } +constexpr int c = fn(alignof(int)); +alignas(c) char d;
reply other threads:[~2020-09-17 17:00 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=20200917170038.20B6F3945C25@sourceware.org \ --to=jakub@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: linkBe 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).