[all-commits] [llvm/llvm-project] 3efaf9: [Clang][Sema] Fix crash when diagnosing near-match...

Krystian Stasiowski via All-commits all-commits at lists.llvm.org
Mon May 20 09:04:30 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3efaf9caa56393597839b796d34f92459c711605
      https://github.com/llvm/llvm-project/commit/3efaf9caa56393597839b796d34f92459c711605
  Author: Krystian Stasiowski <sdkrystian at gmail.com>
  Date:   2024-05-20 (Mon, 20 May 2024)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/lib/Sema/SemaDecl.cpp
    M clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp

  Log Message:
  -----------
  [Clang][Sema] Fix crash when diagnosing near-match for 'constexpr' redeclaration in C++11 (#92452)

Clang crashes when diagnosing the following invalid redeclaration in
C++11:
```
struct A {
  void f();
};

constexpr void A::f() { } // crash here
```
This happens because `DiagnoseInvalidRedeclaration` tries to create a
fix-it to remove `const` from the out-of-line declaration of `f`, but
there is no `SourceLocation` for the `const` qualifier (it's implicitly
`const` due to `constexpr`) and an assert in
`FunctionTypeInfo::getConstQualifierLoc` fails.

This patch changes `DiagnoseInvalidRedeclaration` to only suggest the removal of the
`const` qualifier when it was explicitly specified in the _cv-qualifier-seq_ of the declaration.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list