diff options
Diffstat (limited to 'clang/lib/Sema/SemaDeclObjC.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index ac1e3923afa..f28abf4c070 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -600,7 +600,8 @@ ActOnSuperClassOfClassInterface(Scope *S, } } -DeclResult Sema::actOnObjCTypeParam(Scope *S, IdentifierInfo *paramName, +DeclResult Sema::actOnObjCTypeParam(Scope *S, unsigned index, + IdentifierInfo *paramName, SourceLocation paramLoc, SourceLocation colonLoc, ParsedType parsedTypeBound) { @@ -643,6 +644,23 @@ DeclResult Sema::actOnObjCTypeParam(Scope *S, IdentifierInfo *paramName, // Forget the bound; we'll default to id later. typeBoundInfo = nullptr; } + + // Type bounds cannot have explicit nullability. + if (typeBoundInfo) { + // Type arguments cannot explicitly specify nullability. + if (auto nullability = AttributedType::stripOuterNullability(typeBound)) { + // Look at the type location information to find the nullability + // specifier so we can zap it. + SourceLocation nullabilityLoc + = typeBoundInfo->getTypeLoc().findNullabilityLoc(); + SourceLocation diagLoc + = nullabilityLoc.isValid()? nullabilityLoc + : typeBoundInfo->getTypeLoc().getLocStart(); + Diag(diagLoc, diag::err_type_param_bound_explicit_nullability) + << paramName << typeBoundInfo->getType() + << FixItHint::CreateRemoval(nullabilityLoc); + } + } } // If there was no explicit type bound (or we removed it due to an error), @@ -653,8 +671,8 @@ DeclResult Sema::actOnObjCTypeParam(Scope *S, IdentifierInfo *paramName, } // Create the type parameter. - return ObjCTypeParamDecl::Create(Context, CurContext, paramLoc, paramName, - colonLoc, typeBoundInfo); + return ObjCTypeParamDecl::Create(Context, CurContext, index, paramLoc, + paramName, colonLoc, typeBoundInfo); } ObjCTypeParamList *Sema::actOnObjCTypeParamList(Scope *S, @@ -868,6 +886,7 @@ ActOnStartClassInterface(Scope *S, SourceLocation AtInterfaceLoc, ObjCTypeParamDecl::Create( Context, CurContext, + typeParam->getIndex(), SourceLocation(), typeParam->getIdentifier(), SourceLocation(), |