ispc / ispc/ispc

Malformed warning message under macro expansion

Open
#2,516 0 comments 0 reactions 0 assignees View on GitHub
Frontend / Parser Quality of Life
Dominant language
C++
Stars
3k
Forks
352
PR merge metrics
No merged PRs in 30d

Description

```c
int foo(varying int a, int c) {
return a |= c;
}
enum E {
E1 = 10,
E2 = 20,
};
#define M(x) x = foo(x, (int)E2);

int warn2(varying int a) {
return M(a);
}
```

Warning message contains only unexpanded source code whereas carets point to expanded columns. In case of nested or big macros, it is hard to understand what is really going wrong especially when only types (not variable names) are printed.

```bash
:11:23: Warning: Typecasting to type "/*unbound*/ int32"
(variability not specified) from "uniform" type "const uniform enum E"
results in "uniform" variability.
In the context of function argument it may lead to unexpected
behavior. Casting to "uniform int32" is recommended.
return M(a);
^^^^^^^

Compiler returned: 0
```

compiler explorer: https://godbolt.org/z/zahEzYo9s

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.