Pass -Wdangling-alias to Bison 3.5 or newer

`bison -Wall` enables all diagnostics except `-Wcounterexamples`
(added in 3.7; we already pass it), `-Wyacc` (which we do not need),
and `-Wdangling-alias` (added in 3.5).
This commit is contained in:
Rangi
2026-03-06 22:01:37 -05:00
parent af0505b4cd
commit 48d58ba095
2 changed files with 7 additions and 4 deletions

View File

@@ -14,15 +14,18 @@ set(common_src
find_package(BISON 3.0.0 REQUIRED) find_package(BISON 3.0.0 REQUIRED)
set(BISON_FLAGS "-Wall -Dlr.type=ielr") set(BISON_FLAGS "-Wall -Dlr.type=ielr")
# Set some optimization flags on versions that support them # Set some flags on versions that support them
if(BISON_VERSION VERSION_GREATER_EQUAL "3.5") if(BISON_VERSION VERSION_GREATER_EQUAL "3.5")
set(BISON_FLAGS "${BISON_FLAGS} -Dparse.lac=full -Dapi.token.raw=true") set(BISON_FLAGS "${BISON_FLAGS} -Dparse.lac=full -Dapi.token.raw=true -Wdangling-alias")
endif() endif()
if(BISON_VERSION VERSION_GREATER_EQUAL "3.6") if(BISON_VERSION VERSION_GREATER_EQUAL "3.6")
set(BISON_FLAGS "${BISON_FLAGS} -Dparse.error=detailed") set(BISON_FLAGS "${BISON_FLAGS} -Dparse.error=detailed")
else() else()
set(BISON_FLAGS "${BISON_FLAGS} -Dparse.error=verbose") set(BISON_FLAGS "${BISON_FLAGS} -Dparse.error=verbose")
endif() endif()
if(BISON_VERSION VERSION_GREATER_EQUAL "3.7")
set(BISON_FLAGS "${BISON_FLAGS} -Wcounterexamples")
endif()
BISON_TARGET(ASM_PARSER "asm/parser.y" BISON_TARGET(ASM_PARSER "asm/parser.y"
"${PROJECT_SOURCE_DIR}/src/asm/parser.cpp" "${PROJECT_SOURCE_DIR}/src/asm/parser.cpp"

View File

@@ -14,9 +14,9 @@ fi
BISON_FLAGS="-Wall -Dlr.type=ielr" BISON_FLAGS="-Wall -Dlr.type=ielr"
# Set some optimization flags on versions that support them # Set some flags on versions that support them
if [ "$BISON_MAJOR" -ge 4 ] || [ "$BISON_MAJOR" -eq 3 ] && [ "$BISON_MINOR" -ge 5 ]; then if [ "$BISON_MAJOR" -ge 4 ] || [ "$BISON_MAJOR" -eq 3 ] && [ "$BISON_MINOR" -ge 5 ]; then
BISON_FLAGS="$BISON_FLAGS -Dparse.lac=full -Dapi.token.raw=true" BISON_FLAGS="$BISON_FLAGS -Dparse.lac=full -Dapi.token.raw=true -Wdangling-alias"
fi fi
if [ "$BISON_MAJOR" -ge 4 ] || [ "$BISON_MAJOR" -eq 3 ] && [ "$BISON_MINOR" -ge 6 ]; then if [ "$BISON_MAJOR" -ge 4 ] || [ "$BISON_MAJOR" -eq 3 ] && [ "$BISON_MINOR" -ge 6 ]; then
BISON_FLAGS="$BISON_FLAGS -Dparse.error=detailed" BISON_FLAGS="$BISON_FLAGS -Dparse.error=detailed"