Skip to content

Conversation

@Fznamznon
Copy link
Contributor

SYCL deferred diagnostics couldn't catch the case like:

template <typename T>
class randomType {
 public:
  randomType() {}
  T val;
};

template <typename T>
const randomType<T> Var;

SYCL_EXTERNAL void foo() {
  (void)Var<int>;
}

And CodeGen was crashing due to attempt to emit invalid cast.
That happened because use of Var should be diagnosed. The diagnostic
wasn'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 and finalizeSYCLDelayedAnalysis
routines, i.e. emit immediate diagnostic when post-parsing of AST for
deferred diagnostics happens.

SYCL deferred diagnostics couldn't catch the case like:
```
template <typename T>
class randomType {
 public:
  randomType() {}
  T val;
};

template <typename T>
const randomType<T> Var;

SYCL_EXTERNAL void foo() {
  (void)Var<int>;
}
```
And CodeGen was crashing due to attempt to emit invalid cast.
That happened because use of `Var` should be diagnosed. The diagnostic
wasn'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` and `finalizeSYCLDelayedAnalysis`
routines, i.e. emit immediate diagnostic when post-parsing of AST for
deferred diagnostics happens.
Copy link
Contributor

@smanna12 smanna12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants