Fix a failing assertion with the pointer_with_type_tag attribute when the function the attribute appertains to is variadic.
Patch by Joel Denny.
llvm-svn: 326057
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 4247b32..dea16f9 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -4567,11 +4567,10 @@
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(