From 6ac524b7c3428c9449db281a4d851351f8ec4dff Mon Sep 17 00:00:00 2001 From: Argiris Kirtzidis Date: Sat, 30 Oct 2010 01:06:26 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117760 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaInit.cpp | 1 - test/SemaCXX/crashes.cpp | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 4e4558479..616b2a0bf 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -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; diff --git a/test/SemaCXX/crashes.cpp b/test/SemaCXX/crashes.cpp index 9da0b82ba..53eecb6c1 100644 --- a/test/SemaCXX/crashes.cpp +++ b/test/SemaCXX/crashes.cpp @@ -26,3 +26,18 @@ template 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}} +}; +} -- 2.11.4.GIT