From: Fariborz Jahanian Date: Wed, 5 Sep 2012 17:52:12 +0000 (+0000) Subject: c error recovery. treat an invalid redeclaration X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=37c765a5ccf69fb9a467c8499675ae568811afe3;p=clang c error recovery. treat an invalid redeclaration of a c-function for what it is. Otherwise, this func is treated as an overloadable c-function resulting in a crash much later. // rdar://11743706 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163224 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 2582e13248..6fff4b15a4 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -5565,6 +5565,9 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, D.setRedeclaration(CheckFunctionDeclaration(S, NewFD, Previous, isExplicitSpecialization)); } + // Make graceful recovery from an invalid redeclaration. + else if (!Previous.empty()) + D.setRedeclaration(true); assert((NewFD->isInvalidDecl() || !D.isRedeclaration() || Previous.getResultKind() != LookupResult::FoundOverloaded) && "previous declaration set still overloaded"); diff --git a/test/Sema/invalid-decl.c b/test/Sema/invalid-decl.c index 2699b25492..b2c2aaf1a0 100644 --- a/test/Sema/invalid-decl.c +++ b/test/Sema/invalid-decl.c @@ -29,3 +29,12 @@ typedef struct { void f(StructType *buf) { buf->fun = 0; } + +// rdar://11743706 +static void bar(hid_t, char); // expected-error {{expected identifier}} + +static void bar(hid_t p, char); // expected-error {{unknown type name 'hid_t'}} + +void foo() { + (void)bar; +}