Don't remove the init expression from the initializer list if it had a semantic error.

We already flag the error with InitListChecker's hadError and we mess up the AST unnecessarily.
Fixes rdar://8605381.

llvm-svn: 117760
This commit is contained in:
Argyrios Kyrtzidis
2010-10-30 01:06:26 +00:00
parent b5488f45db
commit 93513155e7
2 changed files with 15 additions and 1 deletions

View File

@@ -723,7 +723,6 @@ void InitListChecker::CheckSubElementType(const InitializedEntity &Entity,
// PerformCopyInitialization produce the appropriate diagnostic.
SemaRef.PerformCopyInitialization(Entity, SourceLocation(),
SemaRef.Owned(expr));
IList->setInit(Index, 0);
hadError = true;
++Index;
++StructuredIndex;

View File

@@ -26,3 +26,18 @@ template<typename T> struct a : T {
int aa() { return p; } // expected-error{{use of undeclared identifier 'p'}}
};
};
// rdar://8605381
namespace rdar8605381 {
struct X {};
struct Y { // expected-note{{candidate}}
Y();
};
struct {
Y obj;
} objs[] = {
new Y // expected-error{{no viable conversion}}
};
}