[PATCH] D151753: [Clang][Sema] Do not try to analyze dependent alignment during -Wcast-align
serge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 27 01:29:28 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdc6f5c9b588a: [Clang][Sema] Do not try to analyze dependent alignment during -Wcast-align (authored by serge-sans-paille).
Changed prior to commit:
https://reviews.llvm.org/D151753?vs=528999&id=534869#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151753/new/
https://reviews.llvm.org/D151753
Files:
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaChecking.cpp
clang/test/SemaCXX/warn-cast-align.cpp
Index: clang/test/SemaCXX/warn-cast-align.cpp
===================================================================
--- clang/test/SemaCXX/warn-cast-align.cpp
+++ clang/test/SemaCXX/warn-cast-align.cpp
@@ -44,6 +44,11 @@
c = IntPtr(P);
}
+template <class A> void DependentAlign() {
+ alignas(A) int lut[]{};
+ (long *)lut; // expected-warning {{cast from 'int *' to 'long *'}}
+}
+
struct __attribute__((aligned(16))) AlignedS {
char m[16];
};
Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -16351,8 +16351,12 @@
if (auto *VD = dyn_cast<VarDecl>(cast<DeclRefExpr>(E)->getDecl())) {
// FIXME: If VD is captured by copy or is an escaping __block variable,
// use the alignment of VD's type.
- if (!VD->getType()->isReferenceType())
+ if (!VD->getType()->isReferenceType()) {
+ // Dependent alignment cannot be resolved -> bail out.
+ if (VD->hasDependentAlignment())
+ break;
return std::make_pair(Ctx.getDeclAlign(VD), CharUnits::Zero());
+ }
if (VD->hasInit())
return getBaseAlignmentAndOffsetFromLValue(VD->getInit(), Ctx);
}
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -370,6 +370,7 @@
- Clang now diagnoses unexpected tokens after a
``#pragma clang|GCC diagnostic push|pop`` directive.
(`#13920: <https://github.com/llvm/llvm-project/issues/13920>`_)
+- Clang now does not try to analyze cast validity on variables with dependent alignment (`#63007: <https://github.com/llvm/llvm-project/issues/63007>`_).
Bug Fixes in This Version
-------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151753.534869.patch
Type: text/x-patch
Size: 1831 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230627/73a8434e/attachment.bin>
More information about the cfe-commits
mailing list