llvm-project/clang/test/FixIt/member-mismatch.cpp
c8ef 8282c58d9b
[Clang] Emit a diagnostic note at the class declaration when the method definition does not match any declaration. (#110638)
Fixes #110558.

In this patch, we will emit a diagnostic note pointing to the class
declaration when a method definition does not match any declaration.
This approach, similar to what GCC does, makes the diagnostic more
user-friendly.

---------

Co-authored-by: Vlad Serebrennikov <serebrennikov.vladislav@gmail.com>
2024-10-02 16:40:06 +02:00

15 lines
705 B
C++

// RUN: %clang_cc1 -verify %s
// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
class Foo { // #defined-here
int get() const; // expected-note {{because it is const qualified}}
void set(int); // expected-note {{because it is not const qualified}}
};
// CHECK: fix-it:"{{.*}}":{[[@LINE+1]]:15-[[@LINE+1]]:15}:" const"
int Foo::get() {} // expected-error {{does not match any declaration}}
// expected-note@#defined-here {{defined here}}
// CHECK: fix-it:"{{.*}}":{[[@LINE+1]]:20-[[@LINE+1]]:26}:""
void Foo::set(int) const {} // expected-error {{does not match any declaration}}
// expected-note@#defined-here {{defined here}}