* support/cpp2/cpphash.h, support/cpp2/cpplex.c: fixed bug #982435
authorborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 20 Dec 2006 22:43:09 +0000 (22:43 +0000)
committerborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 20 Dec 2006 22:43:09 +0000 (22:43 +0000)
* support/regression/tests/bug-1351710.c: renamed from bug-1351710.c,
  added regression test for bug #982435

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4520 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
support/cpp2/cpphash.h
support/cpp2/cpplex.c
support/regression/tests/bug-1351710.c [deleted file]
support/regression/tests/preproc.c [new file with mode: 0644]

index 30655baf3270e2de5e49b2c47730e00ec4bcc42d..45ae76dc0ac95f1561d933e028f216ab6ff9c1cc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-12-20 Borut Razem <borut.razem AT siol.net>
+
+       * support/cpp2/cpphash.h, support/cpp2/cpplex.c: fixed bug #982435
+       * support/regression/tests/bug-1351710.c: renamed from bug-1351710.c,
+         added regression test for bug #982435
+
 2006-12-18 Borut Razem <borut.razem AT siol.net>
 
        * src/SDCCutil.c: fixed a bug in (get_pragma_token)
index 0643f93bd7a138f51b21c21757ff01faca9e56da..d619fcbf02faff64d3cb5ef4319cc1fcc354c941 100644 (file)
@@ -43,6 +43,10 @@ typedef unsigned char uchar;
     || (((prevc) == 'p' || (prevc) == 'P') \
         && CPP_OPTION (pfile, extended_numbers))))
 
+/* Test if a X or x is valid within a preprocessing number.  */
+#define VALID_HEX(c, prevc) \
+  (((c) == 'X' || (c) == 'x') && (prevc) == '0')
+
 #define CPP_OPTION(PFILE, OPTION) ((PFILE)->opts.OPTION)
 #define CPP_BUFFER(PFILE) ((PFILE)->buffer)
 #define CPP_BUF_COLUMN(BUF, CUR) ((CUR) - (BUF)->line_base + (BUF)->col_adjust)
index b5b8ba723c6f1610d65ab15203b898c91093521c..b802ed60cf4bcf52b76fe7363ffcb1afd84cebd5 100644 (file)
@@ -577,26 +577,42 @@ parse_slow (pfile, cur, number_p, plen)
       if (c == '?' || c == '\\')
        c = skip_escaped_newlines (pfile);
 
-      if (!is_idchar (c))
-       {
-         if (!number_p)
-           break;
-         if (c != '.' && !VALID_SIGN (c, prevc))
+      if (number_p)
+        {
+          if (!ISXDIGIT (c) && c != '.' && !VALID_SIGN (c, prevc) && !VALID_HEX (c, prevc))
            break;
-       }
 
-      /* Handle normal identifier characters in this loop.  */
-      do
-       {
-         prevc = c;
-         obstack_1grow (stack, c);
+            obstack_1grow (stack, c);
 
-         if (c == '$')
-           saw_dollar++;
+            base = cur = buffer->cur;
+            while (ISXDIGIT (*cur))
+              ++cur;
 
-         c = *buffer->cur++;
-       }
-      while (is_idchar (c));
+            if (cur != base)
+              obstack_grow (stack, base, cur - base);
+
+            prevc = cur[-1];
+            c = *cur++;
+            buffer->cur = cur;
+        }
+      else
+        {
+          if (!is_idchar (c))
+            break;
+
+          /* Handle normal identifier characters in this loop.  */
+          do
+           {
+             prevc = c;
+             obstack_1grow (stack, c);
+
+             if (c == '$')
+               saw_dollar++;
+
+             c = *buffer->cur++;
+           }
+          while (is_idchar (c));
+        }
     }
 
   /* Step back over the unwanted char.  */
@@ -628,7 +644,8 @@ parse_number (pfile, number, leading_period)
   /* Fast-path loop.  Skim over a normal number.
      N.B. ISIDNUM does not include $.  */
   cur = pfile->buffer->cur;
-  while (ISIDNUM (*cur) || *cur == '.' || VALID_SIGN (*cur, cur[-1]))
+
+  while (ISXDIGIT (*cur) || *cur == '.' || VALID_SIGN (*cur, cur[-1]) || VALID_HEX (*cur, cur[-1]))
     cur++;
 
   /* Check for slow-path cases.  */
diff --git a/support/regression/tests/bug-1351710.c b/support/regression/tests/bug-1351710.c
deleted file mode 100644 (file)
index 20147a5..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
-   bug-1351710.c
-*/
-
-#include <testfwk.h>
-
-const char *
-const_str(void)
-{
-return "A"
-
-
-
-/* just for testing, actually nop */
-#pragma save
-
-
-
-
-
-"B";
-#pragma restore
-}
-
-void
-testBug(void)
-{
-  const char *str = const_str();
-}
diff --git a/support/regression/tests/preproc.c b/support/regression/tests/preproc.c
new file mode 100644 (file)
index 0000000..110a69f
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+   preproc.c
+*/
+
+#include <testfwk.h>
+
+/*
+ * test for bug 135170
+ */
+const char *
+const_str(void)
+{
+return "A"
+
+
+
+/* just for testing, actually nop */
+#pragma save
+
+
+
+
+
+"B";
+#pragma restore
+}
+
+/*
+ * test for bug 982435
+ */
+#if !defined (__GNUC__) && !defined (_MSC_VER)
+/* since this fails on GCC cpp and MSVC cl -E... */
+#define LO_B(x) ((x) & 0xff)
+
+unsigned char
+hexeminus(void)
+{
+unsigned char a=0x\
+fe\
+-\
+LO_B(3);
+return a;
+}
+#endif