-
Notifications
You must be signed in to change notification settings - Fork 837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error in combination with preprocessor directives can obfuscate error location. #3544
Comments
Yeah, I think ultimately the way to deal with this is to keep track of the start of the unterminated statement. Part of the issue is that |
@arcady-lunarg good to hear you concur with my line of thought. Do you have any highlevel pointers in terms of 'glslang.y', it's hard to understand thirdparty code at face value, so I'm wondering what generally would work best. What I had in mind:
Would this be a solid approach, keeping in mind, I'd like to refrain from seriously affecting other errors. Do you have an alternative/better suggestion? |
I recommend reading up on how bison generated grammars work, but the key glslang-specific pieces you want to look at here is the |
@arcady-lunarg I have prepared a pull request of the initial changes I drafted, it'd be great if you could have a look to see if you had any comments on it: #3559 |
I'd like to address an issue with error handeling specifically in combination with common preprocessor directives like #include #line. I'll give you a short summary of the problem and how these system interact, and the situation of the problem.
Results in an "ERROR: frag.glsl:500: unexpected LAYOUT, expecting COMMA or SEMICOLON.". Strictly spoken the error message is correct. However it highlight an important issue, preprocessor directives can cause unterminated statements easily transfer accross natural file boundaries (e.g. #include directives) which makes these source of these statements near impossible to locate, especially in larger code bases where reusabiliity is imminent this class of errors are easilly obfuscated.
In the above scenario, the origional statement occurs in "a" but the factual error is only detected in "b". I'd propose that unterminated statements could report the location where the statement begins, and the specific token or (sub-)statement location reported as detail(s).
I have some past expierence in compilers and language(s) generation but haven't used yacc before so I'd be happy just get a few pointers. I believe this error is presently automatically generated from the grammer (glslang.y) and isn't explictly generated/handled inline. I suspect the location (simple_statement) needs to propegate so that they can be used during error handling.
The text was updated successfully, but these errors were encountered: