diff options
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 15 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 7 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 15 | ||||
-rw-r--r-- | test/Sema/function.c | 6 | ||||
-rw-r--r-- | test/Sema/nested-redef.c | 3 | ||||
-rw-r--r-- | test/SemaObjC/ivar-sem-check-1.m | 3 |
6 files changed, 16 insertions, 33 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index fd6cf525b9..914e304557 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1361,13 +1361,6 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, bool IsFunctionDefinition) { NamedDecl *New; QualType R = GetTypeForDeclarator(D, S); - if (R.isNull()) { - D.setInvalidType(); - R = Context.IntTy; - if (IsFunctionDefinition) // int(...) - R = Context.getFunctionType(R, 0, 0, true, 0); - - } // See if this is a redefinition of a variable in the same scope. if (D.getCXXScopeSpec().isInvalid()) { @@ -2798,10 +2791,6 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { CheckExtraCXXDefaultArguments(D); QualType parmDeclType = GetTypeForDeclarator(D, S); - if (parmDeclType.isNull()) { - D.setInvalidType(true); - parmDeclType = Context.IntTy; - } // TODO: CHECK FOR CONFLICTS, multiple decls with same name in one scope. // Can this happen for params? We already checked that they don't conflict @@ -3816,10 +3805,6 @@ Sema::DeclPtrTy Sema::ActOnIvar(Scope *S, // example, unnamed unions inject all members into the struct namespace! QualType T = GetTypeForDeclarator(D, S); - if (T.isNull()) { - D.setInvalidType(); - T = Context.IntTy; - } if (BitWidth) { // 6.7.2.1p3, 6.7.2.1p4 diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 781c64c22c..fc5b678f21 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -4703,10 +4703,6 @@ void Sema::ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) { || ParamInfo.getTypeObject(0).Kind != DeclaratorChunk::Function) { QualType T = GetTypeForDeclarator(ParamInfo, CurScope); - // The type is entirely optional as well, if none, use DependentTy. - if (T.isNull()) - T = Context.DependentTy; - // The parameter list is optional, if there was none, assume (). if (!T->isFunctionType()) T = Context.getFunctionType(T, NULL, 0, 0, 0); @@ -4722,9 +4718,6 @@ void Sema::ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) { diag::err_object_cannot_be_passed_returned_by_value) << 0 << RetTy; return; } - - if (!RetTy->isDependentType()) - CurBlock->ReturnType = RetTy.getTypePtr(); return; } diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 7519aff630..883cf221fb 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -47,8 +47,8 @@ QualType Sema::adjustParameterType(QualType T) { /// object. /// \param DS the declaration specifiers /// \param DeclLoc The location of the declarator identifier or invalid if none. -/// \returns The type described by the declaration specifiers, or NULL -/// if there was an error. +/// \returns The type described by the declaration specifiers. This function +/// never returns null. QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS, SourceLocation DeclLoc, bool &isInvalid) { @@ -176,6 +176,9 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS, "Can't handle qualifiers on typedef names yet!"); // TypeQuals handled by caller. Result = Context.getTypeDeclType(cast<TypeDecl>(D)); + + if (D->isInvalidDecl()) + isInvalid = true; break; } case DeclSpec::TST_typename: { @@ -232,7 +235,9 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS, break; } case DeclSpec::TST_error: - return QualType(); + Result = Context.IntTy; + isInvalid = true; + break; } // Handle complex types. @@ -624,8 +629,6 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S, unsigned Skip) { } else { bool isInvalid = false; T = ConvertDeclSpecToType(DS, D.getIdentifierLoc(), isInvalid); - if (T.isNull()) - return T; if (isInvalid) D.setInvalidType(true); } @@ -938,7 +941,7 @@ Sema::TypeResult Sema::ActOnTypeName(Scope *S, Declarator &D) { assert(D.getIdentifier() == 0 && "Type name should have no identifier!"); QualType T = GetTypeForDeclarator(D, S); - if (T.isNull()) + if (D.isInvalidType()) return true; // Check that there are no default arguments (C++ only). diff --git a/test/Sema/function.c b/test/Sema/function.c index 974f6e9737..8b5c857207 100644 --- a/test/Sema/function.c +++ b/test/Sema/function.c @@ -80,6 +80,10 @@ typedef void fn_t(void); fn_t t17; // PR4049 -unknown_type t18(void*) { // expected-error {{unknown type name 'unknown_type'}} +unknown_type t18(void*) { // expected-error {{unknown type name 'unknown_type'}} expected-error{{parameter name omitted}} +} + +unknown_type t19(int* P) { // expected-error {{unknown type name 'unknown_type'}} + P = P+1; // no warning. } diff --git a/test/Sema/nested-redef.c b/test/Sema/nested-redef.c index 53b22d6989..ea18091012 100644 --- a/test/Sema/nested-redef.c +++ b/test/Sema/nested-redef.c @@ -1,7 +1,6 @@ // RUN: clang-cc -fsyntax-only -verify %s struct X { // expected-note{{previous definition is here}} - struct X { } x; // expected-error{{nested redefinition of 'X'}} \ - expected-error {{field has incomplete type}} + struct X { } x; // expected-error{{nested redefinition of 'X'}} }; struct Y { }; diff --git a/test/SemaObjC/ivar-sem-check-1.m b/test/SemaObjC/ivar-sem-check-1.m index ab9f6b163c..957abc397e 100644 --- a/test/SemaObjC/ivar-sem-check-1.m +++ b/test/SemaObjC/ivar-sem-check-1.m @@ -9,8 +9,7 @@ typedef int FOO(); int arr[]; // expected-error {{field has incomplete type}} struct S IC; // expected-error {{field has incomplete type}} struct T { // expected-note {{previous definition is here}} - struct T {} X; // expected-error {{nested redefinition of 'T'}} \ - expected-error {{field has incomplete type}} + struct T {} X; // expected-error {{nested redefinition of 'T'}} }YYY; FOO BADFUNC; // expected-error {{field 'BADFUNC' declared as a function}} int kaka; // expected-note {{previous declaration is here}} |