mirror of
https://github.com/RPCS3/glslang.git
synced 2024-12-03 16:41:30 +00:00
PP: Fix #1694: Rationalize errors on partially expanded macro argument.
This commit is contained in:
parent
da1be9a322
commit
6fee94460f
@ -1,6 +1,7 @@
|
||||
cppBad2.vert
|
||||
ERROR: 0:3: 'macro expansion' : End of input in macro b
|
||||
ERROR: 1 compilation errors. No code generated.
|
||||
ERROR: 0:3: '' : compilation terminated
|
||||
ERROR: 2 compilation errors. No code generated.
|
||||
|
||||
|
||||
Shader version: 100
|
||||
|
@ -1,6 +1,7 @@
|
||||
cppBad3.vert
|
||||
ERROR: 0:3: 'macro expansion' : End of input in macro y
|
||||
ERROR: 1 compilation errors. No code generated.
|
||||
ERROR: 0:3: '' : compilation terminated
|
||||
ERROR: 2 compilation errors. No code generated.
|
||||
|
||||
|
||||
Shader version: 100
|
||||
|
19
Test/baseResults/cppBad4.vert.out
Executable file
19
Test/baseResults/cppBad4.vert.out
Executable file
@ -0,0 +1,19 @@
|
||||
cppBad4.vert
|
||||
ERROR: 0:4: 'macro expansion' : unexpected '#' g
|
||||
ERROR: 0:5: '' : syntax error, unexpected SEMICOLON, expecting LEFT_PAREN
|
||||
ERROR: 2 compilation errors. No code generated.
|
||||
|
||||
|
||||
Shader version: 100
|
||||
ERROR: node is still EOpNull!
|
||||
0:? Linker Objects
|
||||
|
||||
|
||||
Linked vertex stage:
|
||||
|
||||
ERROR: Linking vertex stage: Missing entry point: Each stage requires one entry point
|
||||
|
||||
Shader version: 100
|
||||
ERROR: node is still EOpNull!
|
||||
0:? Linker Objects
|
||||
|
19
Test/baseResults/cppBad5.vert.out
Executable file
19
Test/baseResults/cppBad5.vert.out
Executable file
@ -0,0 +1,19 @@
|
||||
cppBad5.vert
|
||||
ERROR: 0:4: 'macro expansion' : End of input in macro g
|
||||
ERROR: 0:5: '' : compilation terminated
|
||||
ERROR: 2 compilation errors. No code generated.
|
||||
|
||||
|
||||
Shader version: 100
|
||||
ERROR: node is still EOpNull!
|
||||
0:? Linker Objects
|
||||
|
||||
|
||||
Linked vertex stage:
|
||||
|
||||
ERROR: Linking vertex stage: Missing entry point: Each stage requires one entry point
|
||||
|
||||
Shader version: 100
|
||||
ERROR: node is still EOpNull!
|
||||
0:? Linker Objects
|
||||
|
4
Test/cppBad4.vert
Executable file
4
Test/cppBad4.vert
Executable file
@ -0,0 +1,4 @@
|
||||
int,i=
|
||||
#define f g(#g(y
|
||||
#define g(m)
|
||||
g(f)
|
4
Test/cppBad5.vert
Executable file
4
Test/cppBad5.vert
Executable file
@ -0,0 +1,4 @@
|
||||
int,i=
|
||||
#define f g($g(y
|
||||
#define g(m)
|
||||
g(f)
|
@ -1027,7 +1027,9 @@ TPpContext::TokenStream* TPpContext::PrescanMacroArg(TokenStream& arg, TPpToken*
|
||||
case MacroExpandNotStarted:
|
||||
break;
|
||||
case MacroExpandError:
|
||||
token = EndOfInput;
|
||||
// toss the rest of the pushed-input argument by scanning until tMarkerInput
|
||||
while ((token = scanToken(ppToken)) != tMarkerInput::marker && token != EndOfInput)
|
||||
;
|
||||
break;
|
||||
case MacroExpandStarted:
|
||||
case MacroExpandUndef:
|
||||
@ -1039,13 +1041,10 @@ TPpContext::TokenStream* TPpContext::PrescanMacroArg(TokenStream& arg, TPpToken*
|
||||
expandedArg->putToken(token, ppToken);
|
||||
}
|
||||
|
||||
if (token == EndOfInput) {
|
||||
if (token != tMarkerInput::marker) {
|
||||
// Error, or MacroExpand ate the marker, so had bad input, recover
|
||||
delete expandedArg;
|
||||
expandedArg = nullptr;
|
||||
} else {
|
||||
// remove the marker
|
||||
popInput();
|
||||
}
|
||||
|
||||
return expandedArg;
|
||||
@ -1262,7 +1261,7 @@ MacroExpandResult TPpContext::MacroExpand(TPpToken* ppToken, bool expandUndef, b
|
||||
|
||||
if (token == ')') {
|
||||
// closing paren of call
|
||||
if (in->mac->args.size() == 1 && tokenRecorded == 0)
|
||||
if (in->mac->args.size() == 1 && !tokenRecorded)
|
||||
break;
|
||||
arg++;
|
||||
break;
|
||||
|
@ -1056,7 +1056,7 @@ int TPpContext::tokenize(TPpToken& ppToken)
|
||||
// Handle token-pasting logic
|
||||
token = tokenPaste(token, ppToken);
|
||||
|
||||
if (token == EndOfInput || token == tMarkerInput::marker) {
|
||||
if (token == EndOfInput) {
|
||||
missingEndifCheck();
|
||||
return EndOfInput;
|
||||
}
|
||||
|
@ -97,6 +97,8 @@ INSTANTIATE_TEST_CASE_P(
|
||||
"cppBad.vert",
|
||||
"cppBad2.vert",
|
||||
"cppBad3.vert",
|
||||
"cppBad4.vert",
|
||||
"cppBad5.vert",
|
||||
"cppComplexExpr.vert",
|
||||
"cppDeepNest.frag",
|
||||
"cppPassMacroName.frag",
|
||||
|
Loading…
Reference in New Issue
Block a user