mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-27 05:36:06 +00:00

Clang currently crashes on class C { C() = default; C() = delete; }; My cunning plan for fixing this was to change the `if (!FnD)` in Parser::ParseCXXInlineMethodDef() to `if (!FnD || FnD->isInvalidDecl)` – but alas, the second constructor decl wasn't marked as invalid. This lets Sema::MergeFunctionDecl() return true on function redeclarations, which leads to them being marked invalid. This also improves error messages when functions are redeclared. llvm-svn: 226365
39 lines
1.5 KiB
C++
39 lines
1.5 KiB
C++
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
|
void f();
|
|
void f(int);
|
|
void f(int, float);
|
|
void f(int, int);
|
|
void f(int, ...);
|
|
|
|
typedef float Float;
|
|
void f(int, Float); // expected-note {{previous declaration is here}}
|
|
|
|
int f(int, Float); // expected-error {{functions that differ only in their return type cannot be overloaded}}
|
|
|
|
void g(void); // expected-note {{previous declaration is here}}
|
|
int g(); // expected-error {{functions that differ only in their return type cannot be overloaded}}
|
|
|
|
typedef int INT;
|
|
|
|
class X {
|
|
void f();
|
|
void f(int); // expected-note {{previous declaration is here}}
|
|
void f() const;
|
|
|
|
void f(INT); // expected-error{{cannot be redeclared}}
|
|
|
|
void g(int); // expected-note {{previous declaration is here}}
|
|
void g(int, float); // expected-note {{previous declaration is here}}
|
|
int g(int, Float); // expected-error {{functions that differ only in their return type cannot be overloaded}}
|
|
|
|
static void g(float); // expected-note {{previous declaration is here}}
|
|
static void g(int); // expected-error {{static and non-static member functions with the same parameter types cannot be overloaded}}
|
|
static void g(float); // expected-error {{class member cannot be redeclared}}
|
|
|
|
void h(); // expected-note {{previous declaration is here}}
|
|
void h() __restrict; // expected-error {{class member cannot be redeclared}}
|
|
};
|
|
|
|
int main() {} // expected-note {{previous definition is here}}
|
|
int main(int,char**) {} // expected-error {{conflicting types for 'main'}}
|