Unverified Commit 3efaf9ca authored by Krystian Stasiowski's avatar Krystian Stasiowski Committed by GitHub
Browse files

[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.
parent e33db249
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment