[Libreoffice-commits] core.git: compilerplugins/clang configure.ac include/tools
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jan 21 06:58:45 UTC 2021
compilerplugins/clang/test/doubleconvert.cxx | 2 +-
configure.ac | 10 +++++++++-
include/tools/color.hxx | 10 ++++++++--
3 files changed, 18 insertions(+), 4 deletions(-)
New commits:
commit af34108d90bbbce90cf00c4b23961787599c7fa5
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Wed Jan 20 11:29:18 2021 +0100
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Thu Jan 21 07:58:02 2021 +0100
Use C++20 consteval for the Color(sal_uInt32) ctor
...to make it more obvious that, since 63a68064bb33f180b8a231f7524d99405d910226
"make the Color constructors explicitly specify transparency", it should only be
called when the argument is known at compile-time to have no transparency/alpha
channel.
(This revealed a GCC bug causing bogus
> xmloff/source/chart/ColorPropertySet.cxx: In constructor ‘xmloff::chart::ColorPropertySet::ColorPropertySet(Color)’:
> xmloff/source/chart/ColorPropertySet.cxx:81:9: error: ‘this’ is not a constant expression
> 81 | m_nDefaultColor( 0x0099ccff ) // blue 8
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
so in configure.ac suppress HAVE_CPP_CONSTEVAL when the compiler is found
broken.)
Change-Id: I68df7bd5fbd9b2dcf2243b5a4bde4064d3d665fd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109697
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/compilerplugins/clang/test/doubleconvert.cxx b/compilerplugins/clang/test/doubleconvert.cxx
index 17bd49aa4f6f..12763d966c21 100644
--- a/compilerplugins/clang/test/doubleconvert.cxx
+++ b/compilerplugins/clang/test/doubleconvert.cxx
@@ -12,7 +12,7 @@
int main()
{
- Color col1;
+ constexpr Color col1;
Color col2;
col2 = sal_Int32(
col1); // expected-error at -1 {{redundant double conversion [loplugin:doubleconvert]}}
diff --git a/configure.ac b/configure.ac
index 458a4857b378..f60c1ae5a199 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7189,7 +7189,9 @@ AC_SUBST([HAVE_GCC_FNO_SIZED_DEALLOCATION])
AC_MSG_CHECKING([whether $CXX_BASE supports a working C++20 consteval])
dnl ...that does not suffer from <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96994> "Missing code
-dnl from consteval constructor initializing const variable":
+dnl from consteval constructor initializing const variable" or
+dnl <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98752> "wrong 'error: ‘this’ is not a constant
+dnl expression' with consteval constructor":
AC_LANG_PUSH([C++])
save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
@@ -7199,6 +7201,12 @@ AC_RUN_IFELSE([AC_LANG_PROGRAM([
int i = 0;
};
S const s;
+
+ struct S1 { consteval S1(int) {} };
+ struct S2 {
+ S1 x;
+ S2(): x(0) {}
+ };
], [
return (s.i == 1) ? 0 : 1;
])], [
diff --git a/include/tools/color.hxx b/include/tools/color.hxx
index 209ed34169a8..cd472fd472ee 100644
--- a/include/tools/color.hxx
+++ b/include/tools/color.hxx
@@ -22,6 +22,7 @@
#include <sal/types.h>
#include <tools/toolsdllapi.h>
#include <com/sun/star/uno/Any.hxx>
+#include <config_global.h>
#include <basegfx/color/bcolor.hxx>
#include <osl/endian.h>
@@ -72,7 +73,12 @@ public:
: mValue(0) // black
{}
- constexpr Color(const sal_uInt32 nColor)
+#if HAVE_CPP_CONSTEVAL
+ consteval
+#else
+ constexpr
+#endif
+ Color(const sal_uInt32 nColor)
: mValue(nColor)
{
assert(nColor <= 0xffffff && "don't pass transparency to this constructor, use the Color(ColorTransparencyTag,...) or Color(ColorAlphaTag,...) constructor to make it explicit");
@@ -211,7 +217,7 @@ public:
*/
Color GetRGBColor() const
{
- return mValue & 0x00FFFFFF;
+ return {R, G, B};
}
/* Comparison and operators */
More information about the Libreoffice-commits
mailing list