Author: Aaron Ballman Date: 2023-04-21T13:33:39-04:00 New Revision: 7f00ecd029213aee9baf297554b0cb25a5ffbd0f
URL: https://github.com/llvm/llvm-project/commit/7f00ecd029213aee9baf297554b0cb25a5ffbd0f DIFF: https://github.com/llvm/llvm-project/commit/7f00ecd029213aee9baf297554b0cb25a5ffbd0f.diff LOG: Revert "[clang] trigger -Wcast-qual on functional casts" This reverts commit 7c0021923503a9a5fe1ba1f0b778b5b83c42aa43. It broke post-commit buildbots: https://lab.llvm.org/buildbot/#/builders/37/builds/21631 Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaCast.cpp clang/test/SemaCXX/warn-cast-qual.cpp Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 9cc3936745ac6..7beae03247796 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -231,8 +231,6 @@ Improvements to Clang's diagnostics - ``-Wformat`` now recognizes ``%lb`` for the ``printf``/``scanf`` family of functions. (`#62247: <https://github.com/llvm/llvm-project/issues/62247>`_). -- ``-Wcast-qual`` now triggers on function-style casts. - (`#62083 <https://github.com/llvm/llvm-project/issues/62083>`_) Bug Fixes in This Version ------------------------- diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp index be30d36a4f9a4..cd71288476345 100644 --- a/clang/lib/Sema/SemaCast.cpp +++ b/clang/lib/Sema/SemaCast.cpp @@ -3332,9 +3332,6 @@ 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)); diff --git a/clang/test/SemaCXX/warn-cast-qual.cpp b/clang/test/SemaCXX/warn-cast-qual.cpp index 4fe8de9ae59c8..d1f0cc73a63d4 100644 --- a/clang/test/SemaCXX/warn-cast-qual.cpp +++ b/clang/test/SemaCXX/warn-cast-qual.cpp @@ -34,17 +34,6 @@ void foo_0() { const int &a6 = (int &)((int &)a); // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}} const int &a7 = (int &)((const int &)a); // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}} const int &a8 = (const int &)((int &)a); // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}} - - using T = int&; - using T2 = const int&; - const int &a11 =T2(a); // no warning - int a22 = T(a); // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}} - const int &a33 = T(a); // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}} - int &a44 = T(T2(a)); // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}} - int &a55 = T(T(a)); // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}} - const int &a66 = T(T(a)); // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}} - int &a77 = T(T2(a)); // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}} - const int &a88 = T2(T(a)); // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}} } void foo_1() { @@ -60,17 +49,6 @@ void foo_1() { volatile int &a6 = (int &)((int &)a); // expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}} volatile int &a7 = (int &)((volatile int &)a); // expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}} volatile int &a8 = (volatile int &)((int &)a); // expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}} - - using T = int&; - using T2 = volatile int&; - volatile int &a11 =T2(a); // no warning - int a22 = T(a); // expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}} - volatile int &a33 = T(a); // expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}} - int &a44 = T(T2(a)); // expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}} - int &a55 = T(T(a)); // expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}} - volatile int &a66 = T(T(a)); // expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}} - int &a77 = T(T2(a)); // expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}} - volatile int &a88 = T2(T(a)); // expected-warning {{cast from 'volatile int' to 'int &' drops volatile qualifier}} } void foo_2() { @@ -86,17 +64,6 @@ void foo_2() { const volatile int &a6 = (int &)((int &)a); // expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}} const volatile int &a7 = (int &)((const volatile int &)a); // expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}} const volatile int &a8 = (const volatile int &)((int &)a); // expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}} - - using T = int&; - using T2 = const volatile int&; - const volatile int &a11 =T2(a); // no warning - int a22 = T(a); // expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}} - const volatile int &a33 = T(a); // expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}} - int &a44 = T(T2(a)); // expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}} - int &a55 = T(T(a)); // expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}} - const volatile int &a66 = T(T(a)); // expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}} - const volatile int &a77 = T(T2(a)); // expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}} - const volatile int &a88 = T2(T(a)); // expected-warning {{cast from 'const volatile int' to 'int &' drops const and volatile qualifiers}} } void bar_0() { @@ -111,16 +78,6 @@ void bar_0() { const int **a4 = (const int **)((int **)a); // expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}} expected-warning {{cast from 'int **' to 'const int **' must have all intermediate pointers const qualified to be safe}} const int **a5 = (const int **)((const int **)a); // no warning - - using T = int**; - using T2 = const int**; - - int **a00 = T(T2(a)) ; // expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}} - int **a11 = T(T(a)); // expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}} - - const int **a44 = T2(T(a)); // expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}} expected-warning {{cast from 'T' (aka 'int **') to 'T2' (aka 'const int **') must have all intermediate pointers const qualified to be safe}} - const int **a55 = T2(T2(a)); // no warning - } void bar_1() { @@ -135,15 +92,6 @@ void bar_1() { const int *&a4 = (const int *&)((int *&)a); // expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}} expected-warning {{cast from 'int *' to 'const int *&' must have all intermediate pointers const qualified to be safe}} const int *&a5 = (const int *&)((const int *&)a); // no warning - - using T = int*&; - using T2 = const int*&; - - int *&a00 = T(T2(a)); // expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}} - int *&a11 = T(T(a)); // expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}} - - const int *&a44 = T2(T(a)); // expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}} expected-warning {{cast from 'int *' to 'T2' (aka 'const int *&') must have all intermediate pointers const qualified to be safe}} - const int *&a55 = T2(T2(a)); // no warning } void baz_0() { @@ -160,14 +108,6 @@ void baz_0() { ((C *)&S)->B(); // expected-warning {{cast from 'const C *' to 'C *' drops const qualifier}} ((C *)&S)->A(); // expected-warning {{cast from 'const C *' to 'C *' drops const qualifier}} - - using T = C&; - using T2 = C*; - T(S).B(); // expected-warning {{cast from 'const C' to 'C &' drops const qualifier}} - T(S).A(); // expected-warning {{cast from 'const C' to 'C &' drops const qualifier}} - - T2(&S)->B(); // expected-warning {{cast from 'const C *' to 'C *' drops const qualifier}} - T2(&S)->A(); // expected-warning {{cast from 'const C *' to 'C *' drops const qualifier}} } void baz_1() { @@ -187,14 +127,6 @@ void baz_1() { *(int *)(&S.a) = 0; // expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}} *(int *)(&S.b) = 0; // no warning - - using T = int&; - using T2 = int*; - T(S.a) = 0; // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}} - T(S.b) = 0; // no warning - - *T2(&S.a) = 0; // expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}} - *T2(&S.b) = 0; // no warning } { const C S; @@ -204,39 +136,5 @@ void baz_1() { *(int *)(&S.a) = 0; // expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}} *(int *)(&S.b) = 0; // expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}} - - using T = int&; - using T2 = int*; - T(S.a) = 0; // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}} - T(S.b) = 0; // expected-warning {{cast from 'const int' to 'int &' drops const qualifier}} - - *T2(&S.a) = 0; // expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}} - *T2(&S.b) = 0; // expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}} } } - -void qux_0() { - const auto i = 42; - using T = int*; - auto p = T(&i); // expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}} - - const auto i2 = 42; - using T2 = const int*; - auto p2 = T2(&i2); - - volatile auto i3 = 42; - using T3= int*; - auto p3 = T3(&i3); // expected-warning {{cast from 'volatile int *' to 'int *' drops volatile qualifier}} - - volatile auto i4 = 42; - using T4 = volatile int*; - auto p4 = T4(&i4); - - const volatile auto i5 = 42; - using T5= int*; - auto p5 = T5(&i5); // expected-warning {{cast from 'const volatile int *' to 'int *' drops const and volatile qualifiers}} - - const volatile auto i6 = 42; - using T6= const volatile int*; - auto p6 = T6(&i6); -} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits