Commit e4f5d55
authored
[SYCL] Emit a warning for floating-point size changes after implicit conversions (#6323)
Prior to this changes, we had the following 2 warnings for floating-point precision change:
```
-Wimplicit-float-conversion : (example) implicit conversion loses floating-point precision: 'double' to 'float'
-Wdouble-promotion : (example) implicit conversion increases floating-point precision: 'float' to 'double'
```
Both the above warnings were turned off by default and only enabled when the corresponding warning flags were passed.
Also, both the warnings were only specific to Clang and were not enabled for SYCL (meaning device code).
If the floating point values remained the same on both the source and target semantics after the cast, no warning was emitted.
Example:
```
float PrecisionLoss = 1.1; // implicit conversion loses floating-point precision: 'double' to 'float'
float SizeChange = 3.0; // In this case, though we have assigned a double value to a 'float' variable, there is techncally no loss of precision and we don't get any warning here.
But there is still a change in floating-point-rank (size) here ( from 'double' to 'float')
```
This PR identifies a floating-point size change after an implicit cast and triggers a warning when the -Wimplicit-float-size-conversion flag is passed. It is turned off by default.
This warning is enabled for both Clang and SYCL(i.e both host and device code)
The only other case this addresses is, if there is a precision loss and `-Wimplicit-float-size-conversion` is passed but `-Wimplicit-float-conversion` is not, we make sure to emit at least a size warning.1 parent 2ad29fc commit e4f5d55
File tree
8 files changed
+85
-12
lines changed- clang
- include/clang/Basic
- lib/Sema
- test
- SemaSYCL
- Sema
- sycl/test/basic_tests
8 files changed
+85
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
| 113 | + | |
112 | 114 | | |
113 | 115 | | |
114 | | - | |
| 116 | + | |
115 | 117 | | |
116 | 118 | | |
117 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
128 | 131 | | |
129 | 132 | | |
130 | 133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13879 | 13879 | | |
13880 | 13880 | | |
13881 | 13881 | | |
13882 | | - | |
13883 | | - | |
13884 | | - | |
| 13882 | + | |
| 13883 | + | |
| 13884 | + | |
| 13885 | + | |
| 13886 | + | |
| 13887 | + | |
| 13888 | + | |
| 13889 | + | |
| 13890 | + | |
13885 | 13891 | | |
| 13892 | + | |
13886 | 13893 | | |
13887 | 13894 | | |
13888 | 13895 | | |
13889 | 13896 | | |
13890 | | - | |
| 13897 | + | |
| 13898 | + | |
| 13899 | + | |
| 13900 | + | |
| 13901 | + | |
| 13902 | + | |
| 13903 | + | |
| 13904 | + | |
| 13905 | + | |
| 13906 | + | |
13891 | 13907 | | |
13892 | 13908 | | |
13893 | 13909 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
291 | | - | |
| 291 | + | |
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
| |||
430 | 430 | | |
431 | 431 | | |
432 | 432 | | |
433 | | - | |
434 | 433 | | |
435 | 434 | | |
436 | 435 | | |
| |||
448 | 447 | | |
449 | 448 | | |
450 | 449 | | |
| 450 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
0 commit comments