Index: lib/Sema/SemaDecl.cpp =================================================================== --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -12568,12 +12568,12 @@ SourceLocation()); D.SetIdentifier(&II, Loc); - // Insert this function into translation-unit scope. + // Insert this function into the current scope. DeclContext *PrevDC = CurContext; CurContext = Context.getTranslationUnitDecl(); - FunctionDecl *FD = cast(ActOnDeclarator(TUScope, D)); + FunctionDecl *FD = cast(ActOnDeclarator(S, D)); FD->setImplicit(); CurContext = PrevDC; Index: test/Sema/implicit-decl-c90.c =================================================================== --- /dev/null +++ test/Sema/implicit-decl-c90.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 %s -std=c90 -verify -fsyntax-only +int f() { + return g() + 1; +} + +int (*p)() = g; /* expected-error {{use of undeclared identifier 'g'}} */ + +float g(); /* not expecting conflicting types diagnostics here */ Index: test/Sema/implicit-decl.c =================================================================== --- test/Sema/implicit-decl.c +++ test/Sema/implicit-decl.c @@ -9,8 +9,7 @@ int32_t *vector[16]; const char compDesc[16 + 1]; int32_t compCount = 0; - if (_CFCalendarDecomposeAbsoluteTimeV(compDesc, vector, compCount)) { // expected-note {{previous implicit declaration is here}} \ - expected-error {{implicit declaration of function '_CFCalendarDecomposeAbsoluteTimeV' is invalid in C99}} + if (_CFCalendarDecomposeAbsoluteTimeV(compDesc, vector, compCount)) { // expected-error {{implicit declaration of function '_CFCalendarDecomposeAbsoluteTimeV' is invalid in C99}} } printg("Hello, World!\n"); // expected-error{{implicit declaration of function 'printg' is invalid in C99}} \ @@ -18,7 +17,7 @@ __builtin_is_les(1, 3); // expected-error{{use of unknown builtin '__builtin_is_les'}} } -Boolean _CFCalendarDecomposeAbsoluteTimeV(const char *componentDesc, int32_t **vector, int32_t count) { // expected-error{{conflicting types for '_CFCalendarDecomposeAbsoluteTimeV'}} +Boolean _CFCalendarDecomposeAbsoluteTimeV(const char *componentDesc, int32_t **vector, int32_t count) { return 0; }