]> git.ipfire.org Git - thirdparty/gcc.git/commit
LoongArch: Fix an ODR violation
authorXi Ruoyao <xry111@xry111.site>
Thu, 1 Feb 2024 21:37:38 +0000 (05:37 +0800)
committerXi Ruoyao <xry111@xry111.site>
Sat, 3 Feb 2024 10:28:15 +0000 (18:28 +0800)
commit854b8555bd49ad97c336b8df7098e725dc196e4f
tree0098069ad61c9392ee784b322ba34cc3a1298062
parent1149588836ed426c6ac44a6c200f60a75dfea11d
LoongArch: Fix an ODR violation

When bootstrapping GCC 14 with --with-build-config=bootstrap-lto, an ODR
violation is detected:

    ../../gcc/config/loongarch/loongarch-opts.cc:57: warning:
    'abi_minimal_isa' violates the C++ One Definition Rule [-Wodr]
    57 | abi_minimal_isa[N_ABI_BASE_TYPES][N_ABI_EXT_TYPES];
    ../../gcc/config/loongarch/loongarch-def.cc:186: note:
    'abi_minimal_isa' was previously declared here
    186 |   abi_minimal_isa = array<array<loongarch_isa, N_ABI_EXT_TYPES>,
    ../../gcc/config/loongarch/loongarch-def.cc:186: note:
    code may be misoptimized unless '-fno-strict-aliasing' is used

Fix it by adding a proper declaration of abi_minimal_isa into
loongarch-def.h and remove the ODR-violating local declaration in
loongarch-opts.cc.

gcc/ChangeLog:

* config/loongarch/loongarch-def.h (abi_minimal_isa): Declare.
* config/loongarch/loongarch-opts.cc (abi_minimal_isa): Remove
the ODR-violating locale declaration.
gcc/config/loongarch/loongarch-def.h
gcc/config/loongarch/loongarch-opts.cc