]> granicus.if.org Git - clang/commitdiff
Check for an invalid field earlier in a constructor's initialization
authorDouglas Gregor <dgregor@apple.com>
Fri, 5 Nov 2010 22:21:31 +0000 (22:21 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 5 Nov 2010 22:21:31 +0000 (22:21 +0000)
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

lib/Sema/SemaDeclCXX.cpp

index f1daef0ee7929f15e564a1cf1e67947257d100d6..b33261e4ea1e3b4b877790710e27fb5de97f8554 100644 (file)
@@ -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);