[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: |
Ziyao |
Subject: |
Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks |
Date: |
Wed, 13 Jul 2022 15:35:37 +0800 |
On Tue, Jul 12, 2022 at 03:17:09PM +0200, Vincent Lefevre wrote:
> First, this breaks the ISO C syntax rules, thus a diagnostic is
> required by the standard. Moreover, a multiline #define like that
> (without backslash + newline) is unintuitive. So I would say that
> the code should be rejected.
I have made a simple patch and pushed it towards the git repository.
It will throw an error if there is no terminating character of a string at
the end of line.A part of tcctest3 related to this issue is deleted.
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] Bug that TinyCC Analyses Strings inside #if 0 blocks, Ziyao, 2022/07/11
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, Domingo Alvarez Duarte, 2022/07/11
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, Vincent Lefevre, 2022/07/11
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, Ziyao, 2022/07/11
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, Vincent Lefevre, 2022/07/11
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, Ziyao, 2022/07/11
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, Vincent Lefevre, 2022/07/11
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, Vincent Lefevre, 2022/07/12
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks,
Ziyao <=
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, grischka, 2022/07/13
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, Ziyao, 2022/07/13
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, grischka, 2022/07/15
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, Vincent Lefevre, 2022/07/13
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, grischka, 2022/07/13
- Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, Vincent Lefevre, 2022/07/13
Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, Ziyao, 2022/07/11
Re: [Tinycc-devel] Bug that TinyCC Analyses Strings inside #if 0 blocks, Vincent Lefevre, 2022/07/12