diff options
author | Kristina Bessonova <kbessonova@accesssoftek.com> | 2023-09-05 12:43:52 +0200 |
---|---|---|
committer | Kristina Bessonova <kbessonova@accesssoftek.com> | 2023-09-05 12:48:38 +0200 |
commit | 2fbd1323e7bf6ec204867774db8aa9b7dc976da5 (patch) | |
tree | 344f17013735a5a39a4de7110b0ba4baa652f15e /clang/lib/Sema/SemaCast.cpp | |
parent | 50598f0ff44f3a4e75706f8c53f3380fe7faa896 (diff) | |
download | llvm-2fbd1323e7bf6ec204867774db8aa9b7dc976da5.zip llvm-2fbd1323e7bf6ec204867774db8aa9b7dc976da5.tar.gz llvm-2fbd1323e7bf6ec204867774db8aa9b7dc976da5.tar.bz2 |
[Sema] Make C++ functional-style cast warn about dropped qualifiers (-Wcast-qual)
Functional-style cast (i.e. a simple-type-specifier or typename-specifier
followed by a parenthesize single expression [expr.type.conv]) is equivalent
to the C-style cast, so that makes sense they have identical behavior
including warnings.
This also matches GCC https://godbolt.org/z/b8Ma9Thjb.
Reviewed By: rnk, aaron.ballman
Differential Revision: https://reviews.llvm.org/D159133
Diffstat (limited to 'clang/lib/Sema/SemaCast.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCast.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp index d4648b2..98b5879 100644 --- a/clang/lib/Sema/SemaCast.cpp +++ b/clang/lib/Sema/SemaCast.cpp @@ -3374,6 +3374,9 @@ ExprResult Sema::BuildCXXFunctionalCastExpr(TypeSourceInfo *CastTypeInfo, if (auto *ConstructExpr = dyn_cast<CXXConstructExpr>(SubExpr)) ConstructExpr->setParenOrBraceRange(SourceRange(LPLoc, RPLoc)); + // -Wcast-qual + DiagnoseCastQual(Op.Self, Op.SrcExpr, Op.DestType); + return Op.complete(CXXFunctionalCastExpr::Create( Context, Op.ResultType, Op.ValueKind, CastTypeInfo, Op.Kind, Op.SrcExpr.get(), &Op.BasePath, CurFPFeatureOverrides(), LPLoc, RPLoc)); |