[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] RISC-V: Rename conflicting variables in gen-riscv-ext-texi.cc
Jeff Law
law@gcc.gnu.org
Sat Nov 1 18:31:47 GMT 2025
https://gcc.gnu.org/g:595a41d522156b080a03bf7e2386ac82f4dda99a
commit 595a41d522156b080a03bf7e2386ac82f4dda99a
Author: zhusonghe <zhusonghe@eswincomputing.com>
Date: Mon May 19 10:43:48 2025 +0800
RISC-V: Rename conflicting variables in gen-riscv-ext-texi.cc
The variables `major` and `minor` in `gen-riscv-ext-texi.cc`
conflict with the macros of the same name defined in `<sys/sysmacros.h>`,
which are exposed when building with newer versions of GCC on older
Linux distributions (e.g., Ubuntu 18.04). To resolve this, we rename them
to `major_version` and `minor_version` respectively. This aligns with the
GCC community's recommended practice [1] and improves code clarity.
[1] https://gcc.gnu.org/pipermail/gcc-patches/2025-May/683881.html
gcc/ChangeLog:
* config/riscv/gen-riscv-ext-texi.cc (struct version_t):rename
major/minor to major_version/minor_version.
Signed-off-by: Songhe Zhu <zhusonghe@eswincomputing.com>
(cherry picked from commit 11936041970a45e5cf9a75110f365398451be6b5)
Diff:
---
gcc/config/riscv/gen-riscv-ext-texi.cc | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/gcc/config/riscv/gen-riscv-ext-texi.cc b/gcc/config/riscv/gen-riscv-ext-texi.cc
index e15fdbf36f6e..c29a375d56c4 100644
--- a/gcc/config/riscv/gen-riscv-ext-texi.cc
+++ b/gcc/config/riscv/gen-riscv-ext-texi.cc
@@ -6,22 +6,22 @@
struct version_t
{
- int major;
- int minor;
+ int major_version;
+ int minor_version;
version_t (int major, int minor,
enum riscv_isa_spec_class spec = ISA_SPEC_CLASS_NONE)
- : major (major), minor (minor)
+ : major_version (major), minor_version (minor)
{}
bool operator<(const version_t &other) const
{
- if (major != other.major)
- return major < other.major;
- return minor < other.minor;
+ if (major_version != other.major_version)
+ return major_version < other.major_version;
+ return minor_version < other.minor_version;
}
bool operator== (const version_t &other) const
{
- return major == other.major && minor == other.minor;
+ return major_version == other.major_version && minor_version == other.minor_version;
}
};
@@ -39,7 +39,7 @@ print_ext_doc_entry (const std::string &ext_name, const std::string &full_name,
printf ("@tab");
for (const auto &version : unique_versions)
{
- printf (" %d.%d", version.major, version.minor);
+ printf (" %d.%d", version.major_version, version.minor_version);
}
printf ("\n");
printf ("@tab %s", full_name.c_str ());
More information about the Gcc-cvs
mailing list