From: Chris Lattner Date: Sun, 12 Apr 2009 22:15:02 +0000 (+0000) Subject: fix another case that assumed that GetTypeForDeclarator would never return null. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6491f47670661c7c9e546cbc3ca7bae2f9850f21;p=clang fix another case that assumed that GetTypeForDeclarator would never return null. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68918 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 6c2440ff68..7d27617891 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3623,10 +3623,8 @@ FieldDecl *Sema::HandleField(Scope *S, RecordDecl *Record, if (II) Loc = D.getIdentifierLoc(); QualType T = GetTypeForDeclarator(D, S); - - if (getLangOptions().CPlusPlus) { + if (getLangOptions().CPlusPlus) CheckExtraCXXDefaultArguments(D); - } DiagnoseFunctionSpecifiers(D); @@ -3774,8 +3772,11 @@ Sema::DeclPtrTy Sema::ActOnIvar(Scope *S, // example, unnamed unions inject all members into the struct namespace! QualType T = GetTypeForDeclarator(D, S); - assert(!T.isNull() && "GetTypeForDeclarator() returned null type"); bool InvalidDecl = false; + if (T.isNull()) { + InvalidDecl = true; + T = Context.IntTy; + } if (BitWidth) { // 6.7.2.1p3, 6.7.2.1p4 diff --git a/test/Parser/declarators.c b/test/Parser/declarators.c index d8cd5b6586..a4b2aad09d 100644 --- a/test/Parser/declarators.c +++ b/test/Parser/declarators.c @@ -64,4 +64,3 @@ static f; // expected-warning {{type specifier missing, defaults to 'int'}} static g = 4; // expected-warning {{type specifier missing, defaults to 'int'}} static h // expected-warning {{type specifier missing, defaults to 'int'}} __asm__("foo"); // expected-warning {{extension used}} -