Author: aaronballman Date: Sun Feb 25 12:28:10 2018 New Revision: 326057 URL: http://llvm.org/viewvc/llvm-project?rev=326057&view=rev Log: Fix a failing assertion with the pointer_with_type_tag attribute when the function the attribute appertains to is variadic.
Patch by Joel Denny. Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/test/Sema/warn-type-safety.c Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=326057&r1=326056&r2=326057&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Sun Feb 25 12:28:10 2018 @@ -4567,11 +4567,10 @@ static void handleArgumentWithTypeTagAtt bool IsPointer = AL.getName()->getName() == "pointer_with_type_tag"; if (IsPointer) { // Ensure that buffer has a pointer type. - QualType BufferTy = getFunctionOrMethodParamType(D, ArgumentIdx); - if (!BufferTy->isPointerType()) { + if (ArgumentIdx >= getFunctionOrMethodNumParams(D) || + !getFunctionOrMethodParamType(D, ArgumentIdx)->isPointerType()) S.Diag(AL.getLoc(), diag::err_attribute_pointers_only) - << AL.getName() << 0; - } + << AL.getName() << 0; } D->addAttr(::new (S.Context) ArgumentWithTypeTagAttr( Modified: cfe/trunk/test/Sema/warn-type-safety.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-type-safety.c?rev=326057&r1=326056&r2=326057&view=diff ============================================================================== --- cfe/trunk/test/Sema/warn-type-safety.c (original) +++ cfe/trunk/test/Sema/warn-type-safety.c Sun Feb 25 12:28:10 2018 @@ -37,6 +37,10 @@ int wrong9 __attribute__(( pointer_with_ int wrong10(double buf, MPI_Datatype type) __attribute__(( pointer_with_type_tag(mpi,1,2) )); // expected-error {{'pointer_with_type_tag' attribute only applies to pointer arguments}} +int ok11(void *, ...) + __attribute__(( pointer_with_type_tag(mpi,1,2) )); +int wrong11(void *, ...) + __attribute__(( pointer_with_type_tag(mpi,2,3) )); // expected-error {{'pointer_with_type_tag' attribute only applies to pointer arguments}} extern struct A datatype_wrong1 __attribute__(( type_tag_for_datatype )); // expected-error {{'type_tag_for_datatype' attribute requires parameter 1 to be an identifier}} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits