From 65cd3c0cfa205aa6f67ff974f561882d5eafdd89 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 15 Jun 2022 16:09:05 -0400 Subject: [PATCH] Build fix: old gcc does not recognize hidden/shadowed enumeration as valid MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The build fails on GCC < 6 with: ust-registry.hpp: In constructor 'lttng::sessiond::ust::registry_typed_enum::registry_typed_enum(const char*, const lttng_ust_ctl_enum_entry*, size_t)': ust-registry.hpp:111:45: error: 'lttng::sessiond::trace::integer_type::signedness' is not a class, namespace, or enumeration lttng::sessiond::trace::integer_type::signedness::SIGNED : The same error occurs for stream_class::header_type. This is due to a bug fixed in gcc 6: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60994 In both cases, the member is suffixed to disambiguate the reference to the inner-enumeration. Signed-off-by: Jérémie Galarneau Change-Id: Id0f2f98a147be589b9c70740660c7fb911dfc22c --- src/bin/lttng-sessiond/field.cpp | 12 ++++++------ src/bin/lttng-sessiond/field.hpp | 16 +++++++++++++--- src/bin/lttng-sessiond/stream-class.cpp | 2 +- src/bin/lttng-sessiond/stream-class.hpp | 7 ++++++- .../lttng-sessiond/tsdl-trace-class-visitor.cpp | 16 ++++++++-------- src/bin/lttng-sessiond/ust-app.cpp | 2 +- 6 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/bin/lttng-sessiond/field.cpp b/src/bin/lttng-sessiond/field.cpp index 66087cfae..df2808841 100644 --- a/src/bin/lttng-sessiond/field.cpp +++ b/src/bin/lttng-sessiond/field.cpp @@ -74,8 +74,8 @@ lst::integer_type::integer_type(unsigned int in_alignment, type(in_alignment), byte_order{in_byte_order}, size{in_size}, - signedness{in_signedness}, - base{in_base} + signedness_{in_signedness}, + base_{in_base} { } @@ -85,8 +85,8 @@ bool lst::integer_type::_is_equal(const type &base_other) const noexcept return this->byte_order == other.byte_order && this->size == other.size && - this->signedness == other.signedness && - this->base == other.base; + this->signedness_ == other.signedness_ && + this->base_ == other.base_; } void lst::integer_type::accept(type_visitor& visitor) const @@ -219,7 +219,7 @@ void lst::dynamic_length_array_type::accept(type_visitor& visitor) const } lst::string_type::string_type(unsigned int in_alignment, enum encoding in_encoding) : - type(in_alignment), encoding{in_encoding} + type(in_alignment), encoding_{in_encoding} { } @@ -227,7 +227,7 @@ bool lst::string_type::_is_equal(const type& base_other) const noexcept { const auto& other = static_cast(base_other); - return this->encoding == other.encoding; + return this->encoding_ == other.encoding_; } lst::static_length_string_type::static_length_string_type( diff --git a/src/bin/lttng-sessiond/field.hpp b/src/bin/lttng-sessiond/field.hpp index 23c67b04c..f66fdbe7f 100644 --- a/src/bin/lttng-sessiond/field.hpp +++ b/src/bin/lttng-sessiond/field.hpp @@ -86,8 +86,13 @@ public: const enum byte_order byte_order; const unsigned int size; - const signedness signedness; - const base base; + /* + * signedness and base are suffixed with '_' to work-around a bug in older + * GCCs (before 6) that do not recognize hidden/shadowed enumeration as valid + * nested-name-specifiers. + */ + const signedness signedness_; + const base base_; protected: virtual bool _is_equal(const type& other) const noexcept override; @@ -264,7 +269,12 @@ public: string_type(unsigned int alignment, enum encoding encoding); - const encoding encoding; + /* + * encoding is suffixed with '_' to work-around a bug in older + * GCCs (before 6) that do not recognize hidden/shadowed enumeration as valid + * nested-name-specifiers. + */ + const encoding encoding_; protected: virtual bool _is_equal(const type& base_other) const noexcept override; diff --git a/src/bin/lttng-sessiond/stream-class.cpp b/src/bin/lttng-sessiond/stream-class.cpp index b2092f553..c087facba 100644 --- a/src/bin/lttng-sessiond/stream-class.cpp +++ b/src/bin/lttng-sessiond/stream-class.cpp @@ -12,7 +12,7 @@ namespace lst = lttng::sessiond::trace; lttng::sessiond::trace::stream_class::stream_class( unsigned int in_id, enum header_type in_header_type) : - id{in_id}, header_type{in_header_type} + id{in_id}, header_type_{in_header_type} { } diff --git a/src/bin/lttng-sessiond/stream-class.hpp b/src/bin/lttng-sessiond/stream-class.hpp index 636d0b136..08555f307 100644 --- a/src/bin/lttng-sessiond/stream-class.hpp +++ b/src/bin/lttng-sessiond/stream-class.hpp @@ -32,7 +32,12 @@ public: virtual const lttng::sessiond::trace::type& get_context() const; const unsigned int id; - const header_type header_type; + /* + * header_type is suffixed with '_' to work-around a bug in older + * GCCs (before 6) that do not recognize hidden/shadowed enumeration as valid + * nested-name-specifiers. + */ + const header_type header_type_; protected: stream_class(unsigned int id, enum header_type header_type); diff --git a/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp b/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp index 733c05a45..115d57976 100644 --- a/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp +++ b/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp @@ -134,15 +134,15 @@ private: fmt::arg("alignment", type.alignment)); /* Defaults to unsigned. */ - if (type.signedness == lst::integer_type::signedness::SIGNED) { + if (type.signedness_ == lst::integer_type::signedness::SIGNED) { _description += " signed = true;"; } /* Defaults to 10. */ - if (type.base != lst::integer_type::base::DECIMAL) { + if (type.base_ != lst::integer_type::base::DECIMAL) { unsigned int base; - switch (type.base) { + switch (type.base_) { case lst::integer_type::base::BINARY: base = 2; break; @@ -155,7 +155,7 @@ private: default: LTTNG_THROW_ERROR(fmt::format( "Unexpected base encountered while serializing integer type to TSDL: base = {}", - (int) type.base)); + (int) type.base_)); } _description += fmt::format(" base = {};", base); @@ -303,7 +303,7 @@ private: virtual void visit(const lst::null_terminated_string_type& type) override final { /* Defaults to UTF-8. */ - if (type.encoding == lst::null_terminated_string_type::encoding::ASCII) { + if (type.encoding_ == lst::null_terminated_string_type::encoding::ASCII) { _description += "string { encoding = ASCII }"; } else { _description += "string"; @@ -376,7 +376,7 @@ private: * an encoding specified. */ const auto char_array = lttng::make_unique( - type.alignment, create_character_type(type.encoding), type.length); + type.alignment, create_character_type(type.encoding_), type.length); visit(*char_array); } @@ -388,7 +388,7 @@ private: * an encoding specified. */ const auto char_sequence = lttng::make_unique( - type.alignment, create_character_type(type.encoding), + type.alignment, create_character_type(type.encoding_), type.length_field_name); visit(*char_sequence); @@ -556,7 +556,7 @@ void tsdl::trace_class_visitor::visit(const lttng::sessiond::trace::stream_class " event.header := {header_type};\n" " packet.context := struct packet_context;\n", fmt::arg("id", stream_class.id), - fmt::arg("header_type", stream_class.header_type == lst::stream_class::header_type::COMPACT ? + fmt::arg("header_type", stream_class.header_type_ == lst::stream_class::header_type::COMPACT ? "struct event_header_compact" : "struct event_header_large")); diff --git a/src/bin/lttng-sessiond/ust-app.cpp b/src/bin/lttng-sessiond/ust-app.cpp index 0246501a5..1cfb08f91 100644 --- a/src/bin/lttng-sessiond/ust-app.cpp +++ b/src/bin/lttng-sessiond/ust-app.cpp @@ -6468,7 +6468,7 @@ reply: ret_code); ret = lttng_ust_ctl_reply_register_channel(sock, chan_id, - ust_reg_chan.header_type == lst::stream_class::header_type::COMPACT ? + ust_reg_chan.header_type_ == lst::stream_class::header_type::COMPACT ? LTTNG_UST_CTL_CHANNEL_HEADER_COMPACT : LTTNG_UST_CTL_CHANNEL_HEADER_LARGE, ret_code); -- 2.34.1