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 2582e13..6fff4b1 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -5565,6 +5565,9 @@
       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 2699b25..b2c2aaf 100644
--- a/test/Sema/invalid-decl.c
+++ b/test/Sema/invalid-decl.c
@@ -29,3 +29,12 @@
 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;
+}