Skip to content

Commit cf51876

Browse files
authored
[clang][MSExtentions] Fix invalid overload failure about the loss of __unaligned qualifier (#65248)
Loss of `__unaligned` qualifier does not invalidate overload candidates. This fixes a regression reported in https://reviews.llvm.org/D153690 Reviewed By: cor3ntin, AaronBallman PR: #65248
1 parent 872aa45 commit cf51876

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ Bug Fixes in This Version
216216
local structs.
217217
- Correctly parse non-ascii identifiers that appear immediately after a line splicing
218218
(`#65156 <https://github.com/llvm/llvm-project/issues/65156>`_`)
219+
- Clang no longer considers the loss of ``__unaligned`` qualifier from objects as
220+
an invalid conversion during method function overload resolution.
219221

220222
Bug Fixes to Compiler Builtins
221223
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaOverload.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5556,9 +5556,11 @@ TryObjectArgumentInitialization(Sema &S, SourceLocation Loc, QualType FromType,
55565556

55575557
// First check the qualifiers.
55585558
QualType FromTypeCanon = S.Context.getCanonicalType(FromType);
5559-
if (ImplicitParamType.getCVRQualifiers()
5560-
!= FromTypeCanon.getLocalCVRQualifiers() &&
5561-
!ImplicitParamType.isAtLeastAsQualifiedAs(FromTypeCanon)) {
5559+
// MSVC ignores __unaligned qualifier for overload candidates; do the same.
5560+
if (ImplicitParamType.getCVRQualifiers() !=
5561+
FromTypeCanon.getLocalCVRQualifiers() &&
5562+
!ImplicitParamType.isAtLeastAsQualifiedAs(
5563+
withoutUnaligned(S.Context, FromTypeCanon))) {
55625564
ICS.setBad(BadConversionSequence::bad_qualifiers,
55635565
FromType, ImplicitParamType);
55645566
return ICS;

clang/test/SemaCXX/MicrosoftExtensions.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,18 @@ namespace PR42089 {
589589
__attribute__((nothrow)) void S::Bar(){}
590590
}
591591

592+
namespace UnalignedConv {
593+
struct S {
594+
bool operator==(int) const;
595+
};
596+
597+
int func() {
598+
S __unaligned s;
599+
return s == 42;
600+
}
601+
}
602+
603+
592604
#elif TEST2
593605

594606
// Check that __unaligned is not recognized if MS extensions are not enabled

0 commit comments

Comments
 (0)