Skip to content
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
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,7 @@ Bug Fixes to C++ Support
- Fix a bug where private access specifier of overloaded function not respected. (#GH107629)
- Correctly handles calling an explicit object member function template overload set
through its address (``(&Foo::bar<baz>)()``).
- Fix a crash when using an explicit object parameter in a non-member function. (#GH113185)
- Fix a crash when forming an invalid call to an operator with an explicit object member. (#GH147121)
- Correctly handle allocations in the condition of a ``if constexpr``.(#GH120197) (#GH134820)
- Fixed a crash when handling invalid member using-declaration in C++20+ mode. (#GH63254)
Expand Down
4 changes: 3 additions & 1 deletion clang/lib/Sema/SemaType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4860,7 +4860,9 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
S.Diag(First->getBeginLoc(),
diag::err_explicit_object_parameter_invalid)
<< First->getSourceRange();

// Do let non-member function have explicit parameters
// to not break assumptions elsewhere in the code.
First->setExplicitObjectParameterLoc(SourceLocation());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize this is invalid and will get diagnosed as so but don't we have the source location?

D.setInvalidType();
AreDeclaratorChunksValid = false;
}
Expand Down
10 changes: 10 additions & 0 deletions clang/test/SemaCXX/cxx2b-deducing-this.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1347,3 +1347,13 @@ int main() {
// expected-note@#S3-f-cand2 {{candidate function not viable: no known conversion from 'S3' to 'int' for object argument}}
}
}

namespace GH113185 {

void Bar(this int) { // expected-note {{candidate function}}
// expected-error@-1 {{an explicit object parameter cannot appear in a non-member function}}
Bar(0);
Bar(); // expected-error {{no matching function for call to 'Bar'}}
}

}
Loading