Skip to content

[Clang] [Sema] friend functions that are incorrectly redefined as deleted are not diagnosed #135680

@Sirraide

Description

@Sirraide

We currently accept this code (https://godbolt.org/z/e9vzx5M6x) even though we shouldn’t (GCC, MSVC, and EDG all reject this):

struct S {
    friend int f() { return 3; }
    friend int f() = delete;
};

(We also crash on this at the moment, but #135679 fixes the crash, though it still accepts this unfortunately.)

Interestingly, we do diagnose this (https://godbolt.org/z/3b5qG979r):

struct S {
    friend int f() = delete;
    friend int f() { return 3; }
};

I think we have to do something to diagnose the above in ParseCXXInlineMethodDef() after we parse the = default/= delete because we currently just return. It doesn’t seem to be as simple as just calling CheckForFunctionRedefinition() as that breaks a bunch of tests (mostly around defaulted operator== from what I could tell).

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second party

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions