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

llvm-svn: 163224
This commit is contained in:
Fariborz Jahanian 2012-09-05 17:52:12 +00:00
parent 6d92188ff7
commit aaf376b4dd
2 changed files with 12 additions and 0 deletions

View File

@ -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");

View File

@ -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;
}