Skip to content

Commit ab9dff4

Browse files
committed
add additional test cases
1 parent 3efff6c commit ab9dff4

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

clang/lib/Parse/ParseCXXInlineMethods.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,12 @@ NamedDecl *Parser::ParseCXXInlineMethodDef(
142142
SkipUntil(tok::semi);
143143
}
144144

145-
Decl *PrevDecl = FnD->getPreviousDecl();
146-
if (isa_and_present<FunctionDecl>(PrevDecl) &&
147-
PrevDecl->getLexicalDeclContext() == FnD->getLexicalDeclContext()) {
148-
Actions.CheckForFunctionRedefinition(FnD->getAsFunction(),
149-
cast<FunctionDecl>(PrevDecl));
145+
if (FunctionDecl *FD =
146+
dyn_cast_if_present<FunctionDecl>(FnD->getPreviousDecl())) {
147+
if (isa<CXXRecordDecl>(FD->getLexicalDeclContext()) ||
148+
Actions.getDefaultedFunctionKind(FD).asComparison() ==
149+
Sema::DefaultedComparisonKind::None)
150+
Actions.CheckForFunctionRedefinition(FnD->getAsFunction(), FD);
150151
}
151152

152153
return FnD;

clang/test/SemaCXX/cxx2c-delete-with-message.cpp

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -273,27 +273,34 @@ void operators() {
273273
};
274274

275275
namespace gh135506 {
276-
struct a {
277-
friend consteval int f() { return 3; } // expected-note {{previous definition is here}}
278-
friend consteval int f() = delete("foo"); // expected-error {{redefinition of 'f'}}
276+
struct s1 {
277+
friend consteval int a() { return 3; } // expected-note {{previous definition is here}}
278+
friend consteval int a() = delete("foo"); // expected-error {{redefinition of 'a'}}
279279

280-
friend consteval int g() { return 3; } // expected-note {{previous definition is here}}
281-
friend consteval int g() = delete; // expected-error {{redefinition of 'g'}}
280+
friend consteval int b() { return 3; } // expected-note {{previous definition is here}}
281+
friend consteval int b() = delete; // expected-error {{redefinition of 'b'}}
282282

283-
friend int h() { return 3; } // expected-note {{previous definition is here}}
284-
friend int h() = delete; // expected-error {{redefinition of 'h'}}
283+
friend int c() { return 3; } // expected-note {{previous definition is here}}
284+
friend int c() = delete; // expected-error {{redefinition of 'c'}}
285285

286-
friend consteval int i() = delete; // expected-note {{previous definition is here}}
287-
friend consteval int i() { return 3; } // expected-error {{redefinition of 'i'}}
286+
friend consteval int d() = delete; // expected-note {{previous definition is here}}
287+
friend consteval int d() { return 3; } // expected-error {{redefinition of 'd'}}
288288
};
289289

290-
struct b {
291-
friend consteval bool operator==(b, b) { return true; } // expected-note {{previous definition is here}}
292-
friend consteval bool operator==(b, b) = default; // expected-error {{redefinition of 'operator=='}}
290+
struct s2 {
291+
friend consteval bool operator==(s2, s2) { return true; } // expected-note {{previous definition is here}}
292+
friend consteval bool operator==(s2, s2) = default; // expected-error {{redefinition of 'operator=='}}
293293
};
294294

295-
struct c {
296-
friend consteval bool operator==(c, c) = default; // expected-note {{previous definition is here}}
297-
friend consteval bool operator==(c, c) { return true; } // expected-error {{redefinition of 'operator=='}}
295+
struct s3 {
296+
friend consteval bool operator==(s3, s3) = default; // expected-note {{previous definition is here}}
297+
friend consteval bool operator==(s3, s3) { return true; } // expected-error {{redefinition of 'operator=='}}
298298
};
299+
300+
void e() {} // expected-note {{previous definition is here}}
301+
struct s4 { friend void e() = delete; }; // expected-error {{redefinition of 'e'}}
302+
303+
struct s5 { friend void f() {} }; // expected-note {{previous definition is here}}
304+
struct s6 { friend void f() = delete; }; // expected-error {{redefinition of 'f'}}
305+
299306
}

0 commit comments

Comments
 (0)