Patch tcc to ignore static inside array.

This commit is contained in:
Andrius Štikonas 2021-03-28 00:18:30 +00:00
parent 246cc10ab5
commit aa31fbc95b
11 changed files with 72 additions and 117 deletions

View file

@ -1,2 +1,2 @@
9819c29a2c8259883b4a97d6b57f2fdac87b9807ba9594f7c063601a7fe84af9 /after/bin/tcc-musl
6a14de323f7c1e7ae473107a607231f89cf60064c09e83a02362369917a1f483 /after/bin/tcc-musl
dd2f569a10a5bce7a8d264a9a04a86be9c3c1293df64c907370a8d5088c21e65 /after/lib/musl/tcc/libtcc1.a

View file

@ -1,2 +1,2 @@
0075b156a9dc64b63150b3cc020692f2242e1b4fffebccc743651e0bda4b5ca4 /after/bin/tcc-musl
c65633cb875609df7aab2225a24334b5853a0b3e097bdb3ba8a0ae80c1bf5bf0 /after/bin/tcc-musl
a650b13efc65073fb851e9db89728089d8845c401f85faaa09801874ab058089 /after/lib/tcc/libtcc1.a

View file

@ -1,2 +1,2 @@
fd8fdc967f227f3a8ef4f51226ac8a45b6be78eb0b127d2cdf0a9df0e19451b0 /after/bin/tcc-musl
068384be93b6654d6ad555881eaf24d221cc3edf229465f050fec30c30648047 /after/bin/tcc-musl
a650b13efc65073fb851e9db89728089d8845c401f85faaa09801874ab058089 /after/lib/tcc/libtcc1.a

View file

@ -1 +1 @@
d9dd8e605c8dfd584216e94df4759b1aeb894bdd3d99937bf0eba28cf875e25a /after/bin/tcc
0bd8c89f8eee4b8e185b404308a79b3cd315a2143f864d7c250a8f088ae1149d /after/bin/tcc

View file

@ -0,0 +1,59 @@
SPDX-FileCopyrightText: 2018 Petr Skocik <pskocik@gmail.com>
SPDX-License-Identifier: LGPL-2.0-or-later
From ef668aae1ee2b8bc904c50a13bf58df613b2f0b0 Mon Sep 17 00:00:00 2001
From: Petr Skocik <pskocik@gmail.com>
Date: Fri, 23 Mar 2018 13:19:58 +0100
Subject: [PATCH 1/1] Don't fail on const/restrict/static/* inside []
This patch makes tcc ignore them.
Normally (as per the C standard), They should
be only applicable inside parameter arrays
and affect (const/restrict) the pointer the
array gets converted to.
[matz: fix formatting, add volatile handling, add testcase,
add comment about above deficiency]
---
tccgen.c | 19 +++++++++++++++++--
tests/tests2/100_c99array-decls.c | 34 ++++++++++++++++++++++++++++++++++
tests/tests2/100_c99array-decls.expect | 0
3 files changed, 51 insertions(+), 2 deletions(-)
create mode 100644 tests/tests2/100_c99array-decls.c
create mode 100644 tests/tests2/100_c99array-decls.expect
diff --git tccgen.c tccgen.c
index 7ed89ac..6ef40e4 100644
--- tccgen.c
+++ tccgen.c
@@ -4335,8 +4335,23 @@ static int post_type(CType *type, AttributeDef *ad, int storage, int td)
int saved_nocode_wanted = nocode_wanted;
/* array definition */
next();
- if (tok == TOK_RESTRICT1)
- next();
+ while (1) {
+ /* XXX The optional type-quals and static should only be accepted
+ in parameter decls. The '*' as well, and then even only
+ in prototypes (not function defs). */
+ switch (tok) {
+ case TOK_RESTRICT1: case TOK_RESTRICT2: case TOK_RESTRICT3:
+ case TOK_CONST1:
+ case TOK_VOLATILE1:
+ case TOK_STATIC:
+ case '*':
+ next();
+ continue;
+ default:
+ break;
+ }
+ break;
+ }
n = -1;
t1 = 0;
if (tok != ']') {
--
2.11.4.GIT

View file

@ -7,6 +7,8 @@ src_unpack() {
}
src_prepare() {
# Note that tcc includes static-link and ignore-static-inside-array patches
# since we do not build from clean checkout.
patch -Np0 -i ../../patches/ignore-duplicate-symbols.patch
}

View file

@ -8,6 +8,9 @@ src_unpack() {
}
src_prepare() {
# Note that tcc includes static-link and ignore-static-inside-array patches
# since we do not build from clean checkout.
patch -Np0 -i ../../patches/ignore-duplicate-symbols.patch
}

View file

@ -8,6 +8,9 @@ src_unpack() {
}
src_prepare() {
# Note that tcc includes static-link and ignore-static-inside-array patches
# since we do not build from clean checkout.
:
}

View file

@ -11,6 +11,7 @@ cd src/tcc-0.9.27
# Patch
patch -Np0 -i ../../patches/static-link.patch
patch -Np0 -i ../../patches/ignore-static-inside-array.patch
# Compile
## We have to use 0.9.26 to recompile 0.9.27, 0.9.27 is not self-hosting for