public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/redhat/heads/gcc-8-branch)] c++: Bogus error with alignof [PR90736]
@ 2020-09-17 17:00 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2020-09-17 17:00 UTC (permalink / raw)
To: gcc-cvs
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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-17 17:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 17:00 [gcc(refs/vendors/redhat/heads/gcc-8-branch)] c++: Bogus error with alignof [PR90736] Jakub Jelinek
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).