[SYCL] Error out instead of crash when templated global var used #5195
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SYCL deferred diagnostics couldn't catch the case like:
And CodeGen was crashing due to attempt to emit invalid cast.
That happened because use of
Var
should be diagnosed. The diagnosticwasn't emitted because at the places where deferred diagnostic is issued
for this case, templated variable doesn't yet has initializer, or it has
it but current lexical context is out of device code (in this particular
case it will be a translation unit). This patch follows the logic
invented by
finalizeOpenMPDelayedAnalysis
andfinalizeSYCLDelayedAnalysis
routines, i.e. emit immediate diagnostic when post-parsing of AST for
deferred diagnostics happens.