[clang] [clang][MSExtentions] Fix invalid overload failure about the loss of `__unaligned` qualifier (PR #65248)
Takuya Shimizu via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 4 01:12:20 PDT 2023
https://github.com/hazohelet created https://github.com/llvm/llvm-project/pull/65248:
Loss of `__unaligned` qualifier does not invalidate overload candidates.
This fixes a regression reported in https://reviews.llvm.org/D153690
>From eee4c3aee9350be51c9333f284810ffebd9d1663 Mon Sep 17 00:00:00 2001
From: Takuya Shimizu <shimizu2486 at gmail.com>
Date: Mon, 4 Sep 2023 16:23:00 +0900
Subject: [PATCH] [clang][MSExtentions] Fix invalid overload failure about the
loss of `__unaligned` qualifier
Loss of `__unaligned` qualifier does not invalidate overload
candidates.
This fixes a regression reported in https://reviews.llvm.org/D153690
---
clang/lib/Sema/SemaOverload.cpp | 8 +++++---
clang/test/SemaCXX/MicrosoftExtensions.cpp | 11 +++++++++++
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 5d0299dfa752f92..9833d0d312186b6 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -5557,9 +5557,11 @@ TryObjectArgumentInitialization(Sema &S, SourceLocation Loc, QualType FromType,
// First check the qualifiers.
QualType FromTypeCanon = S.Context.getCanonicalType(FromType);
- if (ImplicitParamType.getCVRQualifiers()
- != FromTypeCanon.getLocalCVRQualifiers() &&
- !ImplicitParamType.isAtLeastAsQualifiedAs(FromTypeCanon)) {
+ // MSVC ignores __unaligned qualifier for overload candidates; do the same.
+ if (ImplicitParamType.getCVRQualifiers() !=
+ FromTypeCanon.getLocalCVRQualifiers() &&
+ !ImplicitParamType.isAtLeastAsQualifiedAs(
+ withoutUnaligned(S.Context, FromTypeCanon))) {
ICS.setBad(BadConversionSequence::bad_qualifiers,
FromType, ImplicitParamType);
return ICS;
diff --git a/clang/test/SemaCXX/MicrosoftExtensions.cpp b/clang/test/SemaCXX/MicrosoftExtensions.cpp
index 960030d44f0c155..71618048014cc74 100644
--- a/clang/test/SemaCXX/MicrosoftExtensions.cpp
+++ b/clang/test/SemaCXX/MicrosoftExtensions.cpp
@@ -589,6 +589,17 @@ namespace PR42089 {
__attribute__((nothrow)) void S::Bar(){}
}
+namespace UnalignedConv {
+struct S {
+ bool operator==(int) const;
+};
+
+int func() {
+ S __unaligned s;
+ return s == 42;
+}
+}
+
#elif TEST2
// Check that __unaligned is not recognized if MS extensions are not enabled
More information about the cfe-commits
mailing list