tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks


From: grischka
Subject: Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks
Date: Wed, 13 Jul 2022 12:01:57 +0200
User-agent: Mozilla/5.0 (Windows NT 6.0; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

On 13.07.2022 09:35, Ziyao wrote:

 "Fix wrong handling of strings which do not end properly at the end of line"

I think this conclusion is just as wrong as the initial assumption made
in the thread subject "Bug that TinyCC Analyses Strings inside #if 0 blocks".

There was no bug here in tcc,  it was/is just different behavior, fully
intentional and even documented with a test case.

(actually the behavior is as in gcc-2.95.3 which IIRC as the final release
of the 2.xx line was very good and quasi state-of-the-art at the time when
tcc was written first.)

Is it necessary or a good idea to remove that behavior/feature now from tcc?
I've seen no arguments.

--- grischka


Ziyao

---

diff --git a/tccpp.c b/tccpp.c
index 25654b2..f070640 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -944,19 +944,16 @@ static uint8_t *parse_pp_string(uint8_t *p,
                  }
              }
          } else if (c == '\n') {
-            file->line_num++;
-            goto add_char;
+            tcc_error("missing terminating %c character",sep);
          } else if (c == '\r') {
              PEEKC_EOB(c, p);
              if (c != '\n') {
                  if (str)
                      cstr_ccat(str, '\r');
              } else {
-                file->line_num++;
-                goto add_char;
+                tcc_error("missing terminating %c character",sep);
              }
          } else {
-        add_char:
              if (str)
                  cstr_ccat(str, c);
              p++;
diff --git a/tests/tcctest.c b/tests/tcctest.c
index e969c76..f7fbd65 100644
--- a/tests/tcctest.c
+++ b/tests/tcctest.c
@@ -4253,11 +4253,6 @@ void func_arg_test(void)
  /* gcc 2.95.3 does not handle correctly CR in strings or after strays */
  #define CORRECT_CR_HANDLING

-/* deprecated and no longer supported in gcc 3.3 */
-#ifdef __TINYC__
-# define ACCEPT_CR_IN_STRINGS
-#endif
-
  /* keep this as the last test because GCC messes up line-numbers
     with the ^L^K^M characters below */
  void whitespace_test(void)
@@ -4279,20 +4274,6 @@ ntf("aaa=%d\n", 3);
  \
  ntf("min=%d\n", 4);

-#ifdef ACCEPT_CR_IN_STRINGS
-    printf("len1=%d\n", strlen("
-"));
-#ifdef CORRECT_CR_HANDLING
-    str = "
-";
-    printf("len1=%d str[0]=%d\n", strlen(str), str[0]);
-#endif
-    printf("len1=%d\n", strlen("
a
-"));
-#else
-    printf("len1=1\nlen1=1 str[0]=10\nlen1=3\n");
-#endif /* ACCEPT_CR_IN_STRINGS */
-
  #ifdef __LINE__
      printf("__LINE__ defined\n");
  #endif


_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel





reply via email to

[Prev in Thread] Current Thread [Next in Thread]