Skip to content

Warn of unused const variables. #2668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

Rot127
Copy link
Collaborator

@Rot127 Rot127 commented Mar 29, 2025

Your checklist for this pull request

  • I've documented or updated the documentation of every API function and struct this PR changes.
  • I've added tests that prove my fix is effective or that my feature works (if possible)

Detailed description

This might indicate a table in the inc files is not in use. And could prevent fixes like #2665

Test plan

All green

Closing issues

...

This might indicate a table in the inc files is not in use.
@jiegec
Copy link
Collaborator

jiegec commented Jun 15, 2025

Quite a lot errors generated in *.inc:

[17/212] Building C object CMakeFiles/cap.../AArch64/AArch64DisassemblerExtension.c.o
FAILED: CMakeFiles/capstone.dir/arch/AArch64/AArch64DisassemblerExtension.c.o 
/usr/bin/cc -DCAPSTONE_AARCH64_SUPPORT -DCAPSTONE_ALPHA_SUPPORT -DCAPSTONE_ARC_SUPPORT -DCAPSTONE_ARM_SUPPORT -DCAPSTONE_BPF_SUPPORT -DCAPSTONE_DEBUG -DCAPSTONE_EVM_SUPPORT -DCAPSTONE_HAS_AARCH64 -DCAPSTONE_HAS_ALPHA -DCAPSTONE_HAS_ARC -DCAPSTONE_HAS_ARM -DCAPSTONE_HAS_BPF -DCAPSTONE_HAS_EVM -DCAPSTONE_HAS_HPPA -DCAPSTONE_HAS_LOONGARCH -DCAPSTONE_HAS_M680X -DCAPSTONE_HAS_M68K -DCAPSTONE_HAS_MIPS -DCAPSTONE_HAS_MOS65XX -DCAPSTONE_HAS_POWERPC -DCAPSTONE_HAS_RISCV -DCAPSTONE_HAS_SH -DCAPSTONE_HAS_SPARC -DCAPSTONE_HAS_SYSTEMZ -DCAPSTONE_HAS_TMS320C64X -DCAPSTONE_HAS_TRICORE -DCAPSTONE_HAS_WASM -DCAPSTONE_HAS_X86 -DCAPSTONE_HAS_XCORE -DCAPSTONE_HAS_XTENSA -DCAPSTONE_HPPA_SUPPORT -DCAPSTONE_LOONGARCH_SUPPORT -DCAPSTONE_M680X_SUPPORT -DCAPSTONE_M68K_SUPPORT -DCAPSTONE_MIPS_SUPPORT -DCAPSTONE_MOS65XX_SUPPORT -DCAPSTONE_PPC_SUPPORT -DCAPSTONE_RISCV_SUPPORT -DCAPSTONE_SH_SUPPORT -DCAPSTONE_SPARC_SUPPORT -DCAPSTONE_SYSTEMZ_SUPPORT -DCAPSTONE_TMS320C64X_SUPPORT -DCAPSTONE_TRICORE_SUPPORT -DCAPSTONE_USE_SYS_DYN_MEM -DCAPSTONE_WASM_SUPPORT -DCAPSTONE_X86_SUPPORT -DCAPSTONE_XCORE_SUPPORT -DCAPSTONE_XTENSA_SUPPORT -I/home/jiegec/capstone/include -g -Werror -Wall -Warray-bounds -Wshift-negative-value -Wreturn-type -Wformat -Wmissing-braces -Wunused-function -Wunused-variable -Wparentheses -Wint-in-bool-context -Wmisleading-indentation -Wunused-const-variable -Wno-maybe-uninitialized -Wshadow=local -std=gnu99 -MD -MT CMakeFiles/capstone.dir/arch/AArch64/AArch64DisassemblerExtension.c.o -MF CMakeFiles/capstone.dir/arch/AArch64/AArch64DisassemblerExtension.c.o.d -o CMakeFiles/capstone.dir/arch/AArch64/AArch64DisassemblerExtension.c.o -c /home/jiegec/capstone/arch/AArch64/AArch64DisassemblerExtension.c
In file included from /home/jiegec/capstone/arch/AArch64/AArch64DisassemblerExtension.c:6:
/home/jiegec/capstone/arch/AArch64/AArch64BaseInfo.h:979:23: error: ‘SVEMaxBitsPerVector’ defined but not used [-Werror=unused-const-variable=]
  979 | static const unsigned SVEMaxBitsPerVector = 2048;
      |                       ^~~~~~~~~~~~~~~~~~~
/home/jiegec/capstone/arch/AArch64/AArch64BaseInfo.h:977:23: error: ‘SVEBitsPerBlock’ defined but not used [-Werror=unused-const-variable=]
  977 | static const unsigned SVEBitsPerBlock = 128;
      |                       ^~~~~~~~~~~~~~~
In file included from /home/jiegec/capstone/arch/AArch64/AArch64BaseInfo.h:50:
/home/jiegec/capstone/arch/AArch64/AArch64GenRegisterInfo.inc:5461:23: error: ‘AArch64RegEncodingTable’ defined but not used [-Werror=unused-const-variable=]
 5461 | static const uint16_t AArch64RegEncodingTable[] = {
      |                       ^~~~~~~~~~~~~~~~~~~~~~~
/home/jiegec/capstone/arch/AArch64/AArch64GenRegisterInfo.inc:5156:30: error: ‘AArch64MCRegisterClasses’ defined but not used [-Werror=unused-const-variable=]
 5156 | static const MCRegisterClass AArch64MCRegisterClasses[] = {
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~
/home/jiegec/capstone/arch/AArch64/AArch64GenRegisterInfo.inc:1430:29: error: ‘AArch64RegDesc’ defined but not used [-Werror=unused-const-variable=]
 1430 | static const MCRegisterDesc AArch64RegDesc[] = { // Descriptors
      |                             ^~~~~~~~~~~~~~
/home/jiegec/capstone/arch/AArch64/AArch64GenRegisterInfo.inc:1405:23: error: ‘AArch64SubRegIdxLists’ defined but not used [-Werror=unused-const-variable=]
 1405 | static const uint16_t AArch64SubRegIdxLists[] = {
      |                       ^~~~~~~~~~~~~~~~~~~~~
/home/jiegec/capstone/arch/AArch64/AArch64GenRegisterInfo.inc:1205:24: error: ‘AArch64RegDiffLists’ defined but not used [-Werror=unused-const-variable=]
 1205 | static const MCPhysReg AArch64RegDiffLists[] = {
      |                        ^~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
[18/212] Building C object CMakeFiles/capstone.dir/arch/PowerPC/PPCInstPrinter.c.o
FAILED: CMakeFiles/capstone.dir/arch/PowerPC/PPCInstPrinter.c.o 
/usr/bin/cc -DCAPSTONE_AARCH64_SUPPORT -DCAPSTONE_ALPHA_SUPPORT -DCAPSTONE_ARC_SUPPORT -DCAPSTONE_ARM_SUPPORT -DCAPSTONE_BPF_SUPPORT -DCAPSTONE_DEBUG -DCAPSTONE_EVM_SUPPORT -DCAPSTONE_HAS_AARCH64 -DCAPSTONE_HAS_ALPHA -DCAPSTONE_HAS_ARC -DCAPSTONE_HAS_ARM -DCAPSTONE_HAS_BPF -DCAPSTONE_HAS_EVM -DCAPSTONE_HAS_HPPA -DCAPSTONE_HAS_LOONGARCH -DCAPSTONE_HAS_M680X -DCAPSTONE_HAS_M68K -DCAPSTONE_HAS_MIPS -DCAPSTONE_HAS_MOS65XX -DCAPSTONE_HAS_POWERPC -DCAPSTONE_HAS_RISCV -DCAPSTONE_HAS_SH -DCAPSTONE_HAS_SPARC -DCAPSTONE_HAS_SYSTEMZ -DCAPSTONE_HAS_TMS320C64X -DCAPSTONE_HAS_TRICORE -DCAPSTONE_HAS_WASM -DCAPSTONE_HAS_X86 -DCAPSTONE_HAS_XCORE -DCAPSTONE_HAS_XTENSA -DCAPSTONE_HPPA_SUPPORT -DCAPSTONE_LOONGARCH_SUPPORT -DCAPSTONE_M680X_SUPPORT -DCAPSTONE_M68K_SUPPORT -DCAPSTONE_MIPS_SUPPORT -DCAPSTONE_MOS65XX_SUPPORT -DCAPSTONE_PPC_SUPPORT -DCAPSTONE_RISCV_SUPPORT -DCAPSTONE_SH_SUPPORT -DCAPSTONE_SPARC_SUPPORT -DCAPSTONE_SYSTEMZ_SUPPORT -DCAPSTONE_TMS320C64X_SUPPORT -DCAPSTONE_TRICORE_SUPPORT -DCAPSTONE_USE_SYS_DYN_MEM -DCAPSTONE_WASM_SUPPORT -DCAPSTONE_X86_SUPPORT -DCAPSTONE_XCORE_SUPPORT -DCAPSTONE_XTENSA_SUPPORT -I/home/jiegec/capstone/include -g -Werror -Wall -Warray-bounds -Wshift-negative-value -Wreturn-type -Wformat -Wmissing-braces -Wunused-function -Wunused-variable -Wparentheses -Wint-in-bool-context -Wmisleading-indentation -Wunused-const-variable -Wno-maybe-uninitialized -Wshadow=local -std=gnu99 -MD -MT CMakeFiles/capstone.dir/arch/PowerPC/PPCInstPrinter.c.o -MF CMakeFiles/capstone.dir/arch/PowerPC/PPCInstPrinter.c.o.d -o CMakeFiles/capstone.dir/arch/PowerPC/PPCInstPrinter.c.o -c /home/jiegec/capstone/arch/PowerPC/PPCInstPrinter.c
In file included from /home/jiegec/capstone/arch/PowerPC/PPCInstrInfo.h:7,
                 from /home/jiegec/capstone/arch/PowerPC/PPCInstPrinter.c:39:
/home/jiegec/capstone/arch/PowerPC/PPCMCTargetDesc.h:203:24: error: ‘QFRegs’ defined but not used [-Werror=unused-const-variable=]
  203 | static const MCPhysReg QFRegs[] = {
      |                        ^~~~~~
In file included from /home/jiegec/capstone/arch/PowerPC/PPCMCTargetDesc.h:120:
/home/jiegec/capstone/arch/PowerPC/PPCGenInstrInfo.inc:3059:23: error: ‘PPCImpOpBase’ defined but not used [-Werror=unused-const-variable=]
 3059 | static const unsigned PPCImpOpBase = sizeof(MCOperandInfo) / (sizeof(MCPhysReg));
      |                       ^~~~~~~~~~~~
cc1: all warnings being treated as errors

@Rot127
Copy link
Collaborator Author

Rot127 commented Jun 15, 2025

Yeah, these clean up tasks have to be done before the Beta as well.

@Rot127 Rot127 added this to the v6 - Beta milestone Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants