Skip to content

Commit 998c03d

Browse files
committed
sed the generated enum yytokentype
to avoid LTO -Wodr warnings. yacc doesnt support this yet
1 parent 060bd05 commit 998c03d

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ else()
245245
message(STATUS "IPO / LTO not supported: <${error}>")
246246
endif()
247247

248+
find_program(SED sed gsed)
249+
248250
add_subdirectory(src)
249251
add_subdirectory(regression)
250252
add_subdirectory(unit)

src/CMakeLists.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,15 @@ macro(generic_bison name)
3939
COMPILE_FLAGS "${bison_warnings_as_errors} -pyy${name}"
4040
)
4141
set(renamed_parser_header "${CMAKE_CURRENT_BINARY_DIR}/${bison_header}")
42-
add_custom_command(OUTPUT "${renamed_parser_header}"
43-
COMMAND "${CMAKE_COMMAND}" -E copy "${BISON_parser_OUTPUT_HEADER}" "${renamed_parser_header}"
44-
MAIN_DEPENDENCY "${BISON_parser_OUTPUT_HEADER}"
45-
)
42+
if(${SED} STREQUAL "SED-NOTFOUND")
43+
add_custom_command(OUTPUT "${renamed_parser_header}"
44+
COMMAND "${CMAKE_COMMAND}" -E copy "${BISON_parser_OUTPUT_HEADER}" "${renamed_parser_header}"
45+
MAIN_DEPENDENCY "${BISON_parser_OUTPUT_HEADER}")
46+
else()
47+
add_custom_command(OUTPUT "${renamed_parser_header}"
48+
COMMAND ${SED} -e "s,enum yytokentype,enum yytokentype_${name}," <${BISON_parser_OUTPUT_HEADER} >${renamed_parser_header}
49+
MAIN_DEPENDENCY "${BISON_parser_OUTPUT_HEADER}")
50+
endif()
4651
list(REMOVE_ITEM BISON_parser_OUTPUTS "${BISON_parser_OUTPUT_HEADER}")
4752
list(APPEND BISON_parser_OUTPUTS "${renamed_parser_header}")
4853
endmacro(generic_bison)

src/ansi-c/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ all: ansi-c$(LIBEXT)
104104

105105
ansi_c_y.tab.cpp: parser.y
106106
$(YACC) $(YFLAGS) -pyyansi_c parser.y --defines=ansi_c_y.tab.h -o $@
107+
$(SED) -e's,enum yytokentype,enum yytokentype_ansi,' \
108+
<ansi_c_y.tab.h >ansi_c_y.tab.h.tmp && \
109+
mv ansi_c_y.tab.h.tmp ansi_c_y.tab.h
107110

108111
ansi_c_y.tab.h: ansi_c_y.tab.cpp
109112

src/common

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ endif
9898
ifeq ($(origin LEX),default)
9999
LEX = flex
100100
endif
101+
ifeq ($(origin SED),default)
102+
SED = sed
103+
endif
101104

102105
else ifeq ($(BUILD_ENV_),Cygwin)
103106
# use these for Cygwin:
@@ -130,6 +133,9 @@ endif
130133
ifeq ($(origin LEX),default)
131134
LEX = flex
132135
endif
136+
ifeq ($(origin SED),default)
137+
SED = sed
138+
endif
133139

134140

135141
else ifeq ($(BUILD_ENV_),MSVC)
@@ -158,6 +164,10 @@ endif
158164
ifeq ($(origin LEX),default)
159165
LEX = win_flex
160166
endif
167+
ifeq ($(origin SED),default)
168+
# on MSVC there is no lto
169+
SED = rem
170+
endif
161171

162172

163173
else

src/statement-list/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ all: statement-list$(LIBEXT)
3131

3232
statement_list_y.tab.cpp: parser.y
3333
$(YACC) $(YFLAGS) -pyystatement_list parser.y --defines=statement_list_y.tab.h -o $@
34+
$(SED) -e's,enum yytokentype,enum yytokentype_stmt,' \
35+
<statement_list_y.tab.h >statement_list_y.tab.h.tmp && \
36+
mv statement_list_y.tab.h.tmp statement_list_y.tab.h
3437

3538
statement_list_y.tab.h: statement_list_y.tab.cpp
3639

0 commit comments

Comments
 (0)