Fix a few bugs of previous commit.
authorMario de Sousa <msousa@fe.up.pt>
Wed, 06 Jun 2012 12:39:32 +0100
changeset 565 8acbddf75333
parent 564 dabffc3086dc
child 566 5688fa07f89a
Fix a few bugs of previous commit.
absyntax/absyntax.hh
absyntax_utils/absyntax_utils.cc
stage3/Makefile.in
stage3/constant_folding.cc
--- 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 <stdio.h> // required for NULL
 #include <vector>
 #include <string>
+#include <stdint.h>  // required for uint64_t, etc...
 
 /* Forward declaration of the visitor interface
  * declared in the visitor.hh file
--- 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<hex_integer_c *>(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<hex_integer_c *>(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;
 }
 
 
--- 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@
--- 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 <typeinfo>
 #include <limits>
 #include <math.h> /* required for pow function */
+#include <stdlib.h> /* 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))