Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit a warning for floating-point size changes after implicit conversions #6323

Merged
merged 34 commits into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c570dad
[SYCL] Emit a warning if double precision arithmetic is used in devic…
srividya-sundaram Jun 17, 2022
289bbaa
Add warning to warning-flags.c
srividya-sundaram Jun 17, 2022
be0b892
Fix warnings
srividya-sundaram Jun 25, 2022
dc02117
Add test cases for builtins and default arg promo
srividya-sundaram Jun 27, 2022
5754157
Add new line at the end of file
srividya-sundaram Jun 27, 2022
0bcd3f4
Fix failing tests
srividya-sundaram Jun 30, 2022
762d50a
Fix failing tests
srividya-sundaram Jul 1, 2022
3217c76
Fix warnings-flag.c
srividya-sundaram Jul 1, 2022
374e9a2
Address review comments.
srividya-sundaram Jul 5, 2022
35ee34c
Fix review comments
srividya-sundaram Jul 5, 2022
6041fb9
WIP - Experimental changes.
srividya-sundaram Jul 13, 2022
c3b98d3
fix lint
srividya-sundaram Jul 13, 2022
50f903b
fix tests
srividya-sundaram Jul 13, 2022
5dec41a
fix test
srividya-sundaram Jul 13, 2022
e2c2358
Merge branch 'sycl' into warn-double-precision
srividya-sundaram Jul 13, 2022
c40235f
lint fix
srividya-sundaram Jul 13, 2022
1d978d6
Merge branch 'warn-double-precision' of https://github.com/srividya-s…
srividya-sundaram Jul 13, 2022
459aa08
Ignore warning by default
srividya-sundaram Jul 14, 2022
43c632a
Fix test
srividya-sundaram Jul 14, 2022
568512f
fix test
srividya-sundaram Jul 14, 2022
67c3190
Rename file
srividya-sundaram Jul 14, 2022
12a5286
test changes
srividya-sundaram Jul 17, 2022
1dad8e8
Update logic
srividya-sundaram Jul 18, 2022
7780205
Fix review comments
srividya-sundaram Jul 18, 2022
d6cad3c
Fix tests
srividya-sundaram Jul 18, 2022
78445c3
Update test
srividya-sundaram Jul 19, 2022
23e73be
Add new test to check conversion warnings
srividya-sundaram Jul 29, 2022
41c2560
Update clang/include/clang/Basic/DiagnosticSemaKinds.td
srividya-sundaram Aug 1, 2022
1e00605
Update clang/lib/Sema/SemaChecking.cpp
srividya-sundaram Aug 1, 2022
c09926f
Update clang/lib/Sema/SemaChecking.cpp
srividya-sundaram Aug 2, 2022
192099e
Add custom prefixes
srividya-sundaram Aug 5, 2022
6e2964c
Address review comments
srividya-sundaram Aug 5, 2022
96b9aac
Fix test
srividya-sundaram Aug 8, 2022
b2f59ce
Fix extra space
srividya-sundaram Aug 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/DiagnosticGroups.td
Original file line number Diff line number Diff line change
Expand Up @@ -1387,3 +1387,6 @@ def BranchProtection : DiagGroup<"branch-protection">;
// HLSL diagnostic groups
// Warnings for HLSL Clang extensions
def HLSLExtension : DiagGroup<"hlsl-extensions">;

// Warnings about double precision arithmetic in device code
def DoubleInDevice : DiagGroup<"double-in-device">;
AaronBallman marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ def warn_float_compare_literal : Warning<
def warn_double_const_requires_fp64 : Warning<
"double precision constant requires %select{cl_khr_fp64|cl_khr_fp64 and __opencl_c_fp64}0, "
"casting to single precision">;
def warn_on_double_precision_use : Warning<
"double precision arithmetic used in device code. may cause reduced performance on GPU.">,
srividya-sundaram marked this conversation as resolved.
Show resolved Hide resolved
InGroup<DoubleInDevice>;
AaronBallman marked this conversation as resolved.
Show resolved Hide resolved
def err_half_const_requires_fp16 : Error<
"half precision constant requires cl_khr_fp16">;

Expand Down
6 changes: 6 additions & 0 deletions clang/lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4019,10 +4019,16 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
}
} else if (getLangOpts().OpenCL && !getOpenCLOptions().isAvailableOption(
"cl_khr_fp64", getLangOpts())) {

srividya-sundaram marked this conversation as resolved.
Show resolved Hide resolved
// Impose single-precision float type when cl_khr_fp64 is not enabled.
Diag(Tok.getLocation(), diag::warn_double_const_requires_fp64)
<< (getLangOpts().getOpenCLCompatibleVersion() >= 300);
Res = ImpCastExprToType(Res, Context.FloatTy, CK_FloatingCast).get();
} else if (getLangOpts().SYCLIsDevice) {
/* Emit a warning if double precision arithmetic is used in device
* kernel code */
srividya-sundaram marked this conversation as resolved.
Show resolved Hide resolved
SYCLDiagIfDeviceCode(Tok.getLocation(),
diag::warn_on_double_precision_use);
}
}
} else if (!Literal.isIntegerLiteral()) {
Expand Down
Loading