Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 571ca73

Browse files
committedFeb 1, 2024
[Clang][Sema] Fix crash with const qualified member operator new
We should diagnose a const qualified member operator new but we fail to do so and this leads to crash during debug info generation. The fix is to diagnose this as ill-formed in the front-end. Fixes: #79748
1 parent 46068f5 commit 571ca73

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed
 

‎clang/lib/Sema/SemaType.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5914,8 +5914,10 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
59145914
//
59155915
// ... for instance.
59165916
if (IsQualifiedFunction &&
5917-
!(Kind == Member && !D.isExplicitObjectMemberFunction() &&
5918-
D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_static) &&
5917+
(Kind != Member || D.isExplicitObjectMemberFunction() ||
5918+
D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_static ||
5919+
(D.getContext() == clang::DeclaratorContext::Member &&
5920+
D.isStaticMember())) &&
59195921
!IsTypedefName && D.getContext() != DeclaratorContext::TemplateArg &&
59205922
D.getContext() != DeclaratorContext::TemplateTypeArg) {
59215923
SourceLocation Loc = D.getBeginLoc();

‎clang/test/SemaCXX/function-type-qual.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,9 @@ void instantiateArrayDecay() {
3737
int a[1];
3838
arrayDecay(a);
3939
}
40+
41+
namespace GH79748 {
42+
struct A {
43+
void* operator new(unsigned long bytes) const; //expected-error {{static member function cannot have 'const' qualifier}}
44+
};
45+
}

0 commit comments

Comments
 (0)
Please sign in to comment.