# HG changeset patch # User Mario de Sousa # Date 1338982772 -3600 # Node ID 8acbddf753330c5deaf8a745243e3b953769a16e # Parent dabffc3086dce81eb0209e96dbc06b14ebb50d36 Fix a few bugs of previous commit. diff -r dabffc3086dc -r 8acbddf75333 absyntax/absyntax.hh --- a/absyntax/absyntax.hh Tue Jun 05 19:17:29 2012 +0200 +++ b/absyntax/absyntax.hh Wed Jun 06 12:39:32 2012 +0100 @@ -49,6 +49,7 @@ #include // required for NULL #include #include +#include // required for uint64_t, etc... /* Forward declaration of the visitor interface * declared in the visitor.hh file diff -r dabffc3086dc -r 8acbddf75333 absyntax_utils/absyntax_utils.cc --- a/absyntax_utils/absyntax_utils.cc Tue Jun 05 19:17:29 2012 +0200 +++ b/absyntax_utils/absyntax_utils.cc Wed Jun 06 12:39:32 2012 +0100 @@ -117,19 +117,19 @@ } uint64_t extract_hex_value(symbol_c *sym) { - std::string str = ""; - char *endptr; - hex_integer_c * hex_integer; - uint64_t ret; - - if ((hex_integer = dynamic_cast(sym)) == NULL) ERROR; - for(unsigned int i = 3; i < strlen(hex_integer->value); i++) - if (hex_integer->value[i] != '_') str += hex_integer->value[i]; - errno = 0; /* To distinguish success/failure after call */ - ret = strtol(str.c_str(), &endptr, 16); - if (errno != 0) ERROR; - - return ret; + std::string str = ""; + char *endptr; + hex_integer_c * hex_integer; + uint64_t ret; + + if ((hex_integer = dynamic_cast(sym)) == NULL) ERROR; + for(unsigned int i = 3; i < strlen(hex_integer->value); i++) + if (hex_integer->value[i] != '_') str += hex_integer->value[i]; + errno = 0; /* To distinguish success/failure after call */ + ret = strtoull(str.c_str(), &endptr, 16); + if (errno != 0) ERROR; + + return ret; } diff -r dabffc3086dc -r 8acbddf75333 stage3/Makefile.in --- a/stage3/Makefile.in Tue Jun 05 19:17:29 2012 +0200 +++ b/stage3/Makefile.in Wed Jun 06 12:39:32 2012 +0100 @@ -75,7 +75,8 @@ fill_candidate_datatypes.$(OBJEXT) \ narrow_candidate_datatypes.$(OBJEXT) \ print_datatypes_error.$(OBJEXT) datatype_functions.$(OBJEXT) \ - lvalue_check.$(OBJEXT) array_range_check.$(OBJEXT) + lvalue_check.$(OBJEXT) array_range_check.$(OBJEXT) \ + constant_folding.$(OBJEXT) libstage3_a_OBJECTS = $(am_libstage3_a_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/config depcomp = $(SHELL) $(top_srcdir)/config/depcomp @@ -198,7 +199,8 @@ print_datatypes_error.cc \ datatype_functions.cc \ lvalue_check.cc \ - array_range_check.cc + array_range_check.cc \ + constant_folding.cc all: all-am @@ -278,6 +280,7 @@ -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/array_range_check.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/constant_folding.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/datatype_functions.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fill_candidate_datatypes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flow_control_analysis.Po@am__quote@ diff -r dabffc3086dc -r 8acbddf75333 stage3/constant_folding.cc --- a/stage3/constant_folding.cc Tue Jun 05 19:17:29 2012 +0200 +++ b/stage3/constant_folding.cc Wed Jun 06 12:39:32 2012 +0100 @@ -44,6 +44,7 @@ #include #include #include /* required for pow function */ +#include /* required for malloc() */ #define FIRST_(symbol1, symbol2) (((symbol1)->first_order < (symbol2)->first_order) ? (symbol1) : (symbol2)) #define LAST_(symbol1, symbol2) (((symbol1)->last_order > (symbol2)->last_order) ? (symbol1) : (symbol2))