forked from CTSRD-CHERI/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Sema] cast to CXXRecordDecl correctly when diag a default comparison…
… method Fixed: llvm/llvm-project#62791 Fixed: llvm/llvm-project#62102 in c++20, default comparison is supported. `getLexicalDeclContext` maybe cannot get the `CXXRecord` if default comparison defined out of `CXXRecord`. This patch want to get these information from the first function argument. Reviewed By: #clang-language-wg, erichkeane Differential Revision: https://reviews.llvm.org/D151365
- Loading branch information
Showing
4 changed files
with
26 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// RUN: %clang_cc1 %s -std=c++23 -verify -Wfloat-equal | ||
|
||
struct Foo { | ||
float val; | ||
bool operator==(const Foo &) const; | ||
friend bool operator==(const Foo &, const Foo &); | ||
friend bool operator==(Foo, Foo ); | ||
}; | ||
|
||
// Declare the defaulted comparison function as a member function. | ||
bool Foo::operator==(const Foo &) const = default; // expected-warning {{comparing floating point with == or != is unsafe}} expected-note {{in defaulted equality comparison operator for 'Foo' first required here}} | ||
|
||
// Declare the defaulted comparison function as a non-member function. | ||
bool operator==(const Foo &, const Foo &) = default; // expected-warning {{comparing floating point with == or != is unsafe}} expected-note {{in defaulted equality comparison operator for 'Foo' first required here}} | ||
|
||
// Declare the defaulted comparison function as a non-member function. Arguments are passed by value. | ||
bool operator==(Foo, Foo) = default; // expected-warning {{comparing floating point with == or != is unsafe}} expected-note {{in defaulted equality comparison operator for 'Foo' first required here}} |