From: Douglas Gregor Date: Fri, 5 Nov 2010 22:21:31 +0000 (+0000) Subject: Check for an invalid field earlier in a constructor's initialization X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=464b2f0ab31f6de8761f76f6754809f9746f4584;p=clang Check for an invalid field earlier in a constructor's initialization of that field. Otherwise, we can end up building and later trying to instantiate a dependent member initializer that will fail at instantiation time. Unfortunately, I've only managed to trigger this bug with very large sources, so there's no test case :( git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118306 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index f1daef0ee7..b33261e4ea 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -1252,6 +1252,9 @@ Sema::BuildMemberInitializer(FieldDecl *Member, Expr **Args, unsigned NumArgs, SourceLocation IdLoc, SourceLocation LParenLoc, SourceLocation RParenLoc) { + if (Member->isInvalidDecl()) + return true; + // Diagnose value-uses of fields to initialize themselves, e.g. // foo(foo) // where foo is not also a parameter to the constructor. @@ -1294,9 +1297,6 @@ Sema::BuildMemberInitializer(FieldDecl *Member, Expr **Args, } - if (Member->isInvalidDecl()) - return true; - // Initialize the member. InitializedEntity MemberEntity = InitializedEntity::InitializeMember(Member, 0);