The clang behavior was poor before this patch:
```
void B::foo() override {}
// Before: clang emited "expcted function body after function
// declarator", and skiped all contents until it hits a ";", the
// following function f() is discarded.
// VS
// Now "override is not allowed" with a remove fixit, and following f()
// is retained.
void f();
```
Differential Revision: https://reviews.llvm.org/D111883
20 lines
613 B
C++
20 lines
613 B
C++
// RUN: %clang_cc1 -fsyntax-only -verify -fdiagnostics-parseable-fixits %s
|
|
|
|
class A {
|
|
virtual void foo();
|
|
};
|
|
class B : public A {
|
|
void foo() override;
|
|
};
|
|
|
|
void B::foo() override {} // expected-error {{'override' specifier is not allowed outside a class definition}}
|
|
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:15-[[@LINE-1]]:24}:""
|
|
|
|
void f1() override; // expected-error {{'override' specifier is not allowed}}
|
|
|
|
void f2() override {} // expected-error {{'override' specifier is not allowed}}
|
|
|
|
void test() {
|
|
void f() override; // expected-error {{'override' specifier is not allowed}}
|
|
}
|