Comments (4)
I believe it's skipping past newlines after an include, so e.g.
#include "foo.h"
foo
would end up as
#line 1 "foo.h"
#line 4 "root.c"
foo
instead of
#line 1 "foo.h"
#line 2 "root.c"
foo
In looking into this more, though, I'm confused about whether or not this is actually true:
arocc/src/aro/Preprocessor.zig
Lines 3133 to 3134 in e382265
In printing out the tokens, the line numbers all seem to actually be 1-indexed. The only 0-based tokens I see are the inserted include_start
tokens. So, I think that's the bug here--the line number is not actually 0-indexed, and the start tokens are incorrectly being added with 0-indexed line numbers instead of 1-indexed like all the rest of the tokens.
from arocc.
This patch fixes this particular case:
diff --git a/src/aro/Preprocessor.zig b/src/aro/Preprocessor.zig
index a70c739..e850c62 100644
--- a/src/aro/Preprocessor.zig
+++ b/src/aro/Preprocessor.zig
@@ -2966,7 +2966,7 @@ fn include(pp: *Preprocessor, tokenizer: *Tokenizer, which: Compilation.WhichInc
if (next.id != .nl) break;
tokenizer.* = tmp;
}
- try pp.addIncludeResume(next.source, next.end, next.line);
+ try pp.addIncludeResume(next.source, next.end, first.line);
}
/// tokens that are part of a pragma directive can happen in 3 ways:
but it's pretty clearly a hack. @ehaas could you provide some insight on what the intention of next
in this code is?
arocc/src/aro/Preprocessor.zig
Lines 2962 to 2969 in e382265
from arocc.
Another manifestation of this problem without #include
:
test.c
:
this is line 1
this is line 10
$ arocc -E -fuse-line-directives test.c
#line 1 "test.c"
#line 1 "<builtin>"
#line 294 "<builtin>"
#line 1 "<command line>"
#line 1 "test.c"
this is line 1
#line 11 "test.c"
this is line 10
(the #line 11 "test.c"
should be #line 10 "test.c"
)
from arocc.
I'm not totally sure what next
is doing there - seems like all the tests still pass if that is removed (and just use first
for everything in the addIncludeResume
call), and it fixes the .rc
test you provided.
from arocc.
Related Issues (20)
- Crash: bitwise XOR
- Crash: assign boolean or result to float HOT 1
- Crash: address of invalid type
- Crash: concatenate different char-size strings with improper encoding
- Crash: assign imaginary float to unsigned
- Crash: record with oversize array HOT 1
- Crash: assign to pointer to incomplete enum
- Enums types with fixed underlying type should compare equal to underlying type
- Fixed-underlying-type enums should enforce non-enum integral underlying type
- Crash: non-evaluated floating point comparison in boolean `or`
- Preprocessor allows extraneous tokens in preprocessor expression
- Integer literal promotion rules should emulate chosen compiler
- Incorrect sizeof for typeof incomplete array HOT 1
- Memory leak in preprocessor - indirect invocation of macro with incorrect number of arguments
- Print _BitInt size in diagnostics
- Warn if implicit integer conversion truncates value HOT 1
- Crash: redefining variable as `__auto_type` and assigning to self
- Crash: array subscript with string
- Crash: initializing pointer to typeof-invalid
- `__TIMESTAMP__` macro has incorrect value
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arocc.