From f3ab0ff41b88523ca647a4b74bf3a033997193f4 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sat, 6 Feb 2016 21:19:05 -0600 Subject: [PATCH] Fix VC++'s problems with re2c 0.16 - I'm surprised GCC didn't complain about all the struct/class mismatches. - INFINITY is a macro in VC++ land, so rename it to INFINITI. --- tools/re2c/CMakeLists.txt | 5 +++++ tools/re2c/src/codegen/bitmap.h | 4 ++-- tools/re2c/src/codegen/emit_dfa.cc | 2 +- tools/re2c/src/codegen/go.h | 2 +- tools/re2c/src/ir/adfa/action.h | 2 +- tools/re2c/src/ir/dfa/fillpoints.cc | 10 +++++----- tools/re2c/src/ir/nfa/nfa.h | 6 +++--- 7 files changed, 18 insertions(+), 13 deletions(-) diff --git a/tools/re2c/CMakeLists.txt b/tools/re2c/CMakeLists.txt index 78742ef99b..fb3198ba74 100644 --- a/tools/re2c/CMakeLists.txt +++ b/tools/re2c/CMakeLists.txt @@ -5,6 +5,11 @@ if( NOT CMAKE_CROSSCOMPILING ) include( CheckFunctionExists ) include( CheckTypeSize ) +if( MSVC ) + # Runtime type information is required + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR" ) +endif() + set( PACKAGE_NAME re2c ) set( PACKAGE_TARNAME re2c ) set( PACKAGE_VERSION 0.16 ) diff --git a/tools/re2c/src/codegen/bitmap.h b/tools/re2c/src/codegen/bitmap.h index 3c0cc1be62..17d7a852b0 100644 --- a/tools/re2c/src/codegen/bitmap.h +++ b/tools/re2c/src/codegen/bitmap.h @@ -10,8 +10,8 @@ namespace re2c struct Go; struct Span; -class State; -class OutputFile; +struct State; +struct OutputFile; class BitMap { diff --git a/tools/re2c/src/codegen/emit_dfa.cc b/tools/re2c/src/codegen/emit_dfa.cc index 2ec642647b..ce826d310b 100644 --- a/tools/re2c/src/codegen/emit_dfa.cc +++ b/tools/re2c/src/codegen/emit_dfa.cc @@ -106,7 +106,7 @@ void DFA::emit_body (OutputFile & o, uint32_t& ind, const std::set & us for (State * s = head; s; s = s->next) { bool readCh = false; - emit_state (o, ind, s, used_labels.count (s->label)); + emit_state (o, ind, s, used_labels.count (s->label) != 0); emit_action (s->action, o, ind, readCh, s, cond, skeleton, used_labels, save_yyaccept); s->go.emit(o, ind, readCh); } diff --git a/tools/re2c/src/codegen/go.h b/tools/re2c/src/codegen/go.h index 57c29e8bc6..21f1be979f 100644 --- a/tools/re2c/src/codegen/go.h +++ b/tools/re2c/src/codegen/go.h @@ -13,7 +13,7 @@ namespace re2c { class BitMap; -class State; +struct State; struct If; struct Span diff --git a/tools/re2c/src/ir/adfa/action.h b/tools/re2c/src/ir/adfa/action.h index abc2d99079..3fe01ed784 100644 --- a/tools/re2c/src/ir/adfa/action.h +++ b/tools/re2c/src/ir/adfa/action.h @@ -12,7 +12,7 @@ namespace re2c struct OutputFile; class RuleOp; -class State; +struct State; struct Initial { diff --git a/tools/re2c/src/ir/dfa/fillpoints.cc b/tools/re2c/src/ir/dfa/fillpoints.cc index f4488ea75b..a27402d4d8 100644 --- a/tools/re2c/src/ir/dfa/fillpoints.cc +++ b/tools/re2c/src/ir/dfa/fillpoints.cc @@ -7,8 +7,8 @@ namespace re2c { -static const size_t INFINITY = std::numeric_limits::max(); -static const size_t UNDEFINED = INFINITY - 1; +static const size_t INFINITI = std::numeric_limits::max(); +static const size_t UNDEFINED = INFINITI - 1; static bool loopback(size_t node, size_t narcs, const size_t *arcs) { @@ -38,12 +38,12 @@ static bool loopback(size_t node, size_t narcs, const size_t *arcs) * - values in range [0 .. stack size] mean that this node is on stack * (link to a node with the smallest index reachable from this one) * - UNDEFINED means that this node has not been visited yet - * - INFINITY means that this node has already been popped off stack + * - INFINITI means that this node has already been popped off stack * * We use stack size (rather than topological sort index) as unique index * of a node on stack. This is safe because indices of nodes on stack are * still unique and less than indices of nodes that have been popped off - * stack (INFINITY). + * stack (INFINITI). * */ static void scc( @@ -87,7 +87,7 @@ static void scc( { j = stack.top(); stack.pop(); - lowlink[j] = INFINITY; + lowlink[j] = INFINITI; } while (j != i); } diff --git a/tools/re2c/src/ir/nfa/nfa.h b/tools/re2c/src/ir/nfa/nfa.h index 28587f415d..535348babe 100644 --- a/tools/re2c/src/ir/nfa/nfa.h +++ b/tools/re2c/src/ir/nfa/nfa.h @@ -8,9 +8,9 @@ namespace re2c { -struct Range; -struct RegExp; -struct RuleOp; +class Range; +class RegExp; +class RuleOp; struct nfa_state_t {