diff --git a/.github/workflows/issue-write.yml b/.github/workflows/issue-write.yml index eebaf89e027be..d9ce8fa94e4d5 100644 --- a/.github/workflows/issue-write.yml +++ b/.github/workflows/issue-write.yml @@ -162,4 +162,4 @@ jobs: if: >- always() && steps.download-artifact.outputs.artifact-ids != '' - run: cat comments + run: cat comments* diff --git a/clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp index d11c41c33d2be..21f481a718219 100644 --- a/clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp @@ -9,6 +9,7 @@ #include "RedundantCastingCheck.h" #include "../utils/FixItHintUtils.h" #include "clang/AST/ASTContext.h" +#include "clang/AST/TypeBase.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/Lex/Lexer.h" @@ -29,7 +30,7 @@ static bool areTypesEqual(QualType S, QualType D) { const QualType PtrD = D->getPointeeType(); if (!PtrS.isNull() && !PtrD.isNull()) - return areTypesEqual(PtrS, PtrD); + return areTypesEqual(PtrS.IgnoreParens(), PtrD.IgnoreParens()); const DeducedType *DT = S->getContainedDeducedType(); if (DT && DT->isDeduced()) diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 225ddaeedc10d..fdc866d8255bb 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -567,6 +567,10 @@ Changes in existing checks ` check by adding the option `IgnoreAliasing`, that allows not looking at underlying types of type aliases. +- Improved :doc:`readability-redundant-casting + ` check by fixing false + negatives when explicitly cast from function pointer. + - Improved :doc:`readability-uppercase-literal-suffix ` check to recognize literal suffixes added in C++23 and C23. diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-casting.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-casting.cpp index fa91995c5615f..3e723b8b61d1d 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-casting.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-casting.cpp @@ -235,3 +235,13 @@ void testRedundantDependentNTTPCasting() { // CHECK-MESSAGES: :[[@LINE-4]]:25: note: source type originates from referencing this non-type template parameter // CHECK-FIXES: T a = V; } + +namespace gh170476 { +int f(void); +int g1() { + int (*fp)() = (int(*)(void))&f; + // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: redundant explicit casting to the same type 'int (*)()' as the sub-expression, remove this casting [readability-redundant-casting] + // CHECK-FIXES: int (*fp)() = (&f); + return fp(); +} +} // namespace gh170476 diff --git a/flang-rt/test/Driver/exec.f90 b/flang-rt/test/Driver/exec.f90 index 5a81a1e4c3e45..d220174994979 100644 --- a/flang-rt/test/Driver/exec.f90 +++ b/flang-rt/test/Driver/exec.f90 @@ -1,4 +1,3 @@ -! REQUIRES: flang-rt ! UNSUPPORTED: offload-cuda ! Verify that flang can correctly build executables. diff --git a/flang/include/flang/Parser/openmp-utils.h b/flang/include/flang/Parser/openmp-utils.h index b7d990c9e75d6..e164f63aa189b 100644 --- a/flang/include/flang/Parser/openmp-utils.h +++ b/flang/include/flang/Parser/openmp-utils.h @@ -14,6 +14,7 @@ #define FORTRAN_PARSER_OPENMP_UTILS_H #include "flang/Common/indirection.h" +#include "flang/Common/template.h" #include "flang/Parser/parse-tree.h" #include "llvm/Frontend/OpenMP/OMP.h" @@ -127,7 +128,88 @@ template struct IsStatement> { std::optional