|
0 |
From f4e880b934a2ddcb7f65a68185a84043f2f152a7 Mon Sep 17 00:00:00 2001
|
|
1 |
From: Felix Yan <felixonmars@archlinux.org>
|
|
2 |
Date: Fri, 14 May 2021 21:28:55 +0800
|
|
3 |
Subject: [PATCH] CLexer: allow zeros as line numbers in preprocessed
|
|
4 |
directives
|
|
5 |
|
|
6 |
Starting from `gcc-11` initial line numbers not related to
|
|
7 |
actual files are marked as zeros. See the "preprocessor:
|
|
8 |
Better line info for <builtin> & <command-line>"
|
|
9 |
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=6bf2ff0d52a9
|
|
10 |
|
|
11 |
language-c's grammar did not allow it (by accident)
|
|
12 |
|
|
13 |
```
|
|
14 |
Prelude> Language.C.parseC (Data.ByteString.Char8.pack "# 0 \"/dev/null\"\n") Language.C.nopos
|
|
15 |
Left <no file>:: [ERROR] >>> Syntax Error !
|
|
16 |
Lexical error !
|
|
17 |
The character '#' does not fit here.
|
|
18 |
```
|
|
19 |
|
|
20 |
The change allows '0' in line numbers as well.
|
|
21 |
|
|
22 |
Backported from https://github.com/visq/language-c/commit/8133e1526750ab74ca4d5180fb140a7e172d473f
|
|
23 |
---
|
|
24 |
c2hs/c/CLexer.x | 2 +-
|
|
25 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
26 |
|
|
27 |
diff --git a/c2hs/c/CLexer.x b/c2hs/c/CLexer.x
|
|
28 |
index 0099af5c..9ed0bfba 100644
|
|
29 |
--- a/c2hs/c/CLexer.x
|
|
30 |
+++ b/c2hs/c/CLexer.x
|
|
31 |
@@ -130,7 +130,7 @@ $white+ ;
|
|
32 |
-- * allows further ints after the file name a la GCC; as the GCC CPP docu
|
|
33 |
-- doesn't say how many ints there can be, we allow an unbound number
|
|
34 |
--
|
|
35 |
-\#$space*@int$space*(\"($infname|@charesc)*\"$space*)?(@int$space*)*$eol
|
|
36 |
+\#$space*@digits$space*(\"($infname|@charesc)*\"$space*)?(@int$space*)*$eol
|
|
37 |
{ \pos len str -> setPos (adjustPos (take len str) pos) >> lexToken }
|
|
38 |
|
|
39 |
-- #pragma directive (K&R A12.8)
|