logo

live-bootstrap

Mirror of <https://github.com/fosslinux/live-bootstrap>

ignore-static-inside-array.patch (1849B)


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