Skip to content

[clang][MSExtentions] Fix invalid overload failure about the loss of __unaligned qualifier #65248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ Bug Fixes in This Version
local structs.
- Correctly parse non-ascii identifiers that appear immediately after a line splicing
(`#65156 <https://github.com/llvm/llvm-project/issues/65156>`_`)
- Clang no longer considers the loss of ``__unaligned`` qualifier from objects as
an invalid conversion during method function overload resolution.

Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
8 changes: 5 additions & 3 deletions clang/lib/Sema/SemaOverload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5556,9 +5556,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;
Expand Down
12 changes: 12 additions & 0 deletions clang/test/SemaCXX/MicrosoftExtensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,18 @@ 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
Expand Down