Roland Scheidegger <[email protected]> writes: > This seems to have broken compilation with some gcc versions (with scons > build): > > In file included from src/compiler/glsl/ast_array_index.cpp:24:0: > src/compiler/glsl/ast.h:648:16: error: member > ‘ast_type_qualifier::bitset_t ast_type_qualifier::flags::i’ with > constructor not allowed in union > bitset_t i; > ^
Oops... And the only reason bitset_t has a default constructor was... to avoid using another C++11 feature (defaulted member functions). Does the attached patch fix the build failure for you? The cleaner alternative would be to define the default constructor of the bitset object like 'T() = default', but that would imply dropping support for GCC 4.2-4.3 which don't implement the feature... > src/compiler/glsl/ast.h:648:16: note: unrestricted unions only available > with -std=c++11 or -std=gnu++11 > scons: *** [build/linux-x86_64-checked/compiler/glsl/ast_array_index.os] > Error 1 > src/gallium/tests/unit/u_format_test.c: In function ‘main’: > src/gallium/tests/unit/u_format_test.c:649:44: warning: array subscript > is above array bounds [-Warray-bounds] > unpacked[i][j] = test->unpacked[i][j][1]; > ^ > In file included from src/compiler/glsl/ast_expr.cpp:24:0: > src/compiler/glsl/ast.h:648:16: error: member > ‘ast_type_qualifier::bitset_t ast_type_qualifier::flags::i’ with > constructor not allowed in union > bitset_t i; > ^ > src/compiler/glsl/ast.h:648:16: note: unrestricted unions only available > with -std=c++11 or -std=gnu++11 > > Roland > > [...]
From e2b849f7bb167f7083dea09a421d69e922b09f9c Mon Sep 17 00:00:00 2001 From: Francisco Jerez <[email protected]> Date: Sat, 24 Feb 2018 18:37:34 -0800 Subject: [PATCH] util/bitset: Make C++ wrapper trivially constructible. --- src/compiler/glsl/ast.h | 2 -- src/compiler/glsl/glsl_parser.yy | 1 - src/util/bitset.h | 37 ++++++++++++++++++++----------------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h index e5e4b572fff..a1ec0d566f4 100644 --- a/src/compiler/glsl/ast.h +++ b/src/compiler/glsl/ast.h @@ -477,8 +477,6 @@ struct ast_type_qualifier { DECLARE_BITSET_T(bitset_t, 128); union flags { - flags() : i(0) {} - struct { unsigned invariant:1; unsigned precise:1; diff --git a/src/compiler/glsl/glsl_parser.yy b/src/compiler/glsl/glsl_parser.yy index f1986ed0a8a..e5ea41d4dff 100644 --- a/src/compiler/glsl/glsl_parser.yy +++ b/src/compiler/glsl/glsl_parser.yy @@ -96,7 +96,6 @@ static bool match_layout_qualifier(const char *s1, const char *s2, %parse-param {struct _mesa_glsl_parse_state *state} %union { - YYSTYPE() {} int n; int64_t n64; float real; diff --git a/src/util/bitset.h b/src/util/bitset.h index 7bb5f3c83cf..fee6a13a796 100644 --- a/src/util/bitset.h +++ b/src/util/bitset.h @@ -142,23 +142,6 @@ __bitset_next_set(unsigned i, BITSET_WORD *tmp, * it as, and N is the number of bits in the bitset. */ #define DECLARE_BITSET_T(T, N) struct T { \ - /* XXX - Replace this with an implicitly-defined \ - * constructor when support for C++11 defaulted \ - * constructors can be assumed (available on GCC 4.4 and \ - * later) in order to make the object trivially \ - * constructible like a fundamental integer type for \ - * convenience. \ - */ \ - T() \ - { \ - } \ - \ - T(BITSET_WORD x) \ - { \ - for (unsigned i = 0; i < BITSET_WORDS(N); i++, x = 0) \ - words[i] = x; \ - } \ - \ EXPLICIT_CONVERSION \ operator bool() const \ { \ @@ -168,6 +151,13 @@ __bitset_next_set(unsigned i, BITSET_WORD *tmp, return false; \ } \ \ + T & \ + operator=(BITSET_WORD x) \ + { \ + const T c = {{ x }}; \ + return *this = c; \ + } \ + \ friend bool \ operator==(const T &b, const T &c) \ { \ @@ -180,6 +170,19 @@ __bitset_next_set(unsigned i, BITSET_WORD *tmp, return !(b == c); \ } \ \ + friend bool \ + operator==(const T &b, BITSET_WORD x) \ + { \ + const T c = {{ x }}; \ + return b == c; \ + } \ + \ + friend bool \ + operator!=(const T &b, BITSET_WORD x) \ + { \ + return !(b == x); \ + } \ + \ friend T \ operator~(const T &b) \ { \ -- 2.16.1
signature.asc
Description: PGP signature
_______________________________________________ mesa-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-dev
