aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaExprMember.cpp
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2025-05-15 12:24:12 -0400
committerGitHub <noreply@github.com>2025-05-15 12:24:12 -0400
commit0eb4bd27d1ab15ea6b078ac386be01ae13d261a9 (patch)
tree42db64c9f959b325272eb4eb5861530faef209e6 /clang/lib/Sema/SemaExprMember.cpp
parent5defe490c9b1356916245e1832859c361ac8d812 (diff)
downloadllvm-0eb4bd27d1ab15ea6b078ac386be01ae13d261a9.zip
llvm-0eb4bd27d1ab15ea6b078ac386be01ae13d261a9.tar.gz
llvm-0eb4bd27d1ab15ea6b078ac386be01ae13d261a9.tar.bz2
[C] Silence unreachable -Watomic-access diagnostics (#140064)
Accessing the member of a structure or union which is _Atomic-qualified is undefined behavior in C. We currently diagnose that with a warning that defaults to an error. In turn, this means we reject a valid program if the access it not reachable because of the error. e.g., if (0) SomeAtomicStruct.Member = 12; // Was diagnosed This silences the diagnostic if the member access is not reachable.
Diffstat (limited to 'clang/lib/Sema/SemaExprMember.cpp')
-rw-r--r--clang/lib/Sema/SemaExprMember.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExprMember.cpp b/clang/lib/Sema/SemaExprMember.cpp
index 053414f..39c162c 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -1385,7 +1385,7 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult &R,
// lvalue. Because this is inherently unsafe as an atomic operation, the
// warning defaults to an error.
if (const auto *ATy = BaseType->getAs<AtomicType>()) {
- S.DiagRuntimeBehavior(OpLoc, nullptr,
+ S.DiagRuntimeBehavior(OpLoc, BaseExpr.get(),
S.PDiag(diag::warn_atomic_member_access));
BaseType = ATy->getValueType().getUnqualifiedType();
BaseExpr = ImplicitCastExpr::Create(