Skip to content

Commit 4a3f7e7

Browse files
authored
[ELF] Internalize enum
g++ -flto has a diagnostic `-Wodr` about mismatched redeclarations, which even apply to `enum`. Fix #83529 Reviewers: thesamesam Reviewed By: thesamesam Pull Request: #83604
1 parent af00945 commit 4a3f7e7

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

lld/ELF/Arch/LoongArch.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class LoongArch final : public TargetInfo {
4141
};
4242
} // end anonymous namespace
4343

44+
namespace {
4445
enum Op {
4546
SUB_W = 0x00110000,
4647
SUB_D = 0x00118000,
@@ -65,6 +66,7 @@ enum Reg {
6566
R_T2 = 14,
6667
R_T3 = 15,
6768
};
69+
} // namespace
6870

6971
// Mask out the input's lowest 12 bits for use with `pcalau12i`, in sequences
7072
// like `pcalau12i + addi.[wd]` or `pcalau12i + {ld,st}.*` where the `pcalau12i`

lld/ELF/Arch/PPC64.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ using namespace lld::elf;
2626
constexpr uint64_t ppc64TocOffset = 0x8000;
2727
constexpr uint64_t dynamicThreadPointerOffset = 0x8000;
2828

29+
namespace {
2930
// The instruction encoding of bits 21-30 from the ISA for the Xform and Dform
3031
// instructions that can be used as part of the initial exec TLS sequence.
3132
enum XFormOpcd {
@@ -139,6 +140,7 @@ enum class PPCPrefixedInsn : uint64_t {
139140
PSTXV = PREFIX_8LS | 0xd8000000,
140141
PSTXVP = PREFIX_8LS | 0xf8000000
141142
};
143+
142144
static bool checkPPCLegacyInsn(uint32_t encoding) {
143145
PPCLegacyInsn insn = static_cast<PPCLegacyInsn>(encoding);
144146
if (insn == PPCLegacyInsn::NOINSN)
@@ -164,7 +166,6 @@ enum class LegacyToPrefixMask : uint64_t {
164166
0x8000000003e00000, // S/T (6-10) - The [S/T]X bit moves from 28 to 5.
165167
};
166168

167-
namespace {
168169
class PPC64 final : public TargetInfo {
169170
public:
170171
PPC64();

lld/ELF/Arch/RISCV.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class RISCV final : public TargetInfo {
5757

5858
const uint64_t dtpOffset = 0x800;
5959

60+
namespace {
6061
enum Op {
6162
ADDI = 0x13,
6263
AUIPC = 0x17,
@@ -78,6 +79,7 @@ enum Reg {
7879
X_A0 = 10,
7980
X_T3 = 28,
8081
};
82+
} // namespace
8183

8284
static uint32_t hi20(uint32_t val) { return (val + 0x800) >> 12; }
8385
static uint32_t lo12(uint32_t val) { return val & 4095; }

0 commit comments

Comments
 (0)