Index: lib/Sema/SemaDecl.cpp =================================================================== --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -5041,8 +5041,8 @@ // If this has an identifier and is not an invalid redeclaration or // function template specialization, add it to the scope stack. - if (New->getDeclName() && AddToScope && - !(D.isRedeclaration() && New->isInvalidDecl())) { + if (New->getDeclName() && AddToScope && !(D.isRedeclaration() + && New->isInvalidDecl() && !D.isFunctionDefinition())) { // Only make a locally-scoped extern declaration visible if it is the first // declaration of this entity. Qualified lookup for such an entity should // only find this declaration if there is no visible declaration of it. Index: test/Misc/ast-dump-invalid.cpp =================================================================== --- test/Misc/ast-dump-invalid.cpp +++ test/Misc/ast-dump-invalid.cpp @@ -41,3 +41,24 @@ // CHECK-NEXT: `-ImplicitCastExpr {{.*}} 'int' // CHECK-NEXT: `-DeclRefExpr {{.*}} 'int' lvalue ParmVar {{.*}} 'i' 'int' + +namespace TestInvalidFunctionDecl { +struct Str { + double foo1(double, invalid_type); +}; +double Str::foo1(double, invalid_type) +{ return 45; } +} +// CHECK: NamespaceDecl {{.*}} <{{.*}}> {{.*}} TestInvalidFunctionDecl +// CHECK-NEXT: |-CXXRecordDecl {{.*}} line:46:8 struct Str definition +// CHECK-NEXT: | |-CXXRecordDecl {{.*}} col:8 implicit struct Str +// CHECK-NEXT: | `-CXXMethodDecl {{.*}} col:11 invalid foo1 'double (double, int)' +// CHECK-NEXT: | |-ParmVarDecl {{.*}} col:22 'double' +// CHECK-NEXT: | `-ParmVarDecl {{.*}} > col:36 invalid 'int' +// CHECK-NEXT: `-CXXMethodDecl {{.*}} parent {{.*}} line:49:13 invalid foo1 'double (double, int)' +// CHECK-NEXT: |-ParmVarDecl {{.*}} col:24 'double' +// CHECK-NEXT: |-ParmVarDecl {{.*}} > col:38 invalid 'int' +// CHECK-NEXT: `-CompoundStmt {{.*}} +// CHECK-NEXT: `-ReturnStmt {{.*}} +// CHECK-NEXT: `-ImplicitCastExpr {{.*}} 'double' +// CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 45