Build fix: old gcc does not recognize hidden/shadowed enumeration as valid
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 15 Jun 2022 20:09:05 +0000 (16:09 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 16 Jun 2022 16:37:06 +0000 (12:37 -0400)
The build fails on GCC < 6 with:

ust-registry.hpp: In constructor 'lttng::sessiond::ust::registry_typed_enum<MappingIntegerType>::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 <jeremie.galarneau@efficios.com>
Change-Id: Id0f2f98a147be589b9c70740660c7fb911dfc22c

src/bin/lttng-sessiond/field.cpp
src/bin/lttng-sessiond/field.hpp
src/bin/lttng-sessiond/stream-class.cpp
src/bin/lttng-sessiond/stream-class.hpp
src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp
src/bin/lttng-sessiond/ust-app.cpp

index 66087cfae2316b977324a9952b63c1919f55e7d0..df2808841e6c2dfb324a635c0aa85ec1e520fd64 100644 (file)
@@ -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<decltype(*this)&>(base_other);
 
-       return this->encoding == other.encoding;
+       return this->encoding_ == other.encoding_;
 }
 
 lst::static_length_string_type::static_length_string_type(
index 23c67b04ce1ebe705172523624af6b3ff34dcf2d..f66fdbe7f440dc3c51a237c58fa75977002d84c6 100644 (file)
@@ -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;
index b2092f5538810b2a153f0127f8382e292cae4956..c087facbaa8cc1c4f820be892d38929caf010f2f 100644 (file)
@@ -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}
 {
 }
 
index 636d0b136690ed82dd9ef2edf987be90fb66bbd7..08555f3071e55362f1ce4f20fae3d4ca7ab59a12 100644 (file)
@@ -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);
index 733c05a457701b51cc96834c2475d4f10e324e53..115d579763ff355330eef93379484a04fbc6c730 100644 (file)
@@ -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<lst::static_length_array_type>(
-                               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<lst::dynamic_length_array_type>(
-                               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"));
 
index 0246501a53a31c69bc1ea3a9cddbaec75c67f6d4..1cfb08f917e4ce304fdaeef705d50ee95b73b7ce 100644 (file)
@@ -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);
This page took 0.03004 seconds and 4 git commands to generate.