From: Marek Polacek Date: Wed, 12 Jun 2019 21:12:00 +0000 (+0000) Subject: PR c++/90736 - bogus error with alignof. X-Git-Tag: releases/gcc-9.2.0~252 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cac965a90839a00be784adb67471a7aaadab3ff9;p=thirdparty%2Fgcc.git PR c++/90736 - bogus error with alignof. * constexpr.c (adjust_temp_type): Use cv_unqualified type. * g++.dg/cpp0x/alignof5.C: New test. From-SVN: r272219 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8e33634f7a01..af8a3ccbe1d3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-06-12 Marek Polacek + + PR c++/90736 - bogus error with alignof. + * constexpr.c (adjust_temp_type): Use cv_unqualified type. + 2019-06-11 Jakub Jelinek PR c++/90810 diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 9c13f0d5f320..96558b839ab2 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -1337,7 +1337,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 000000000000..09354d3e1d01 --- /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;