def err_init_priority_object_attr : Error<
"can only use 'init_priority' attribute on file-scope definitions "
"of objects of class type">;
-def err_attribute_argument_duplicate: Error<
- "'%0' attribute parameter %1 is duplicated">;
def err_attribute_argument_n_not_int : Error<
"'%0' attribute requires parameter %1 to be an integer constant">;
def err_attribute_argument_n_not_string : Error<
return;
}
- // check if the argument is a duplicate
- SmallVectorImpl<unsigned>::iterator Pos;
- Pos = std::find(SizeArgs.begin(), SizeArgs.end(), x);
- if (Pos != SizeArgs.end()) {
- S.Diag(Attr.getLoc(), diag::err_attribute_argument_duplicate)
- << "alloc_size" << I.getArgNum() << Ex->getSourceRange();
- return;
- }
-
SizeArgs.push_back(x);
}
<< "alloc_size" << 0 /*function*/<< 1 /*pointer*/ << D->getSourceRange();
}
- unsigned size = SizeArgs.size();
- unsigned* start = &SizeArgs[0];
- llvm::array_pod_sort(start, start + size);
- D->addAttr(::new (S.Context) AllocSizeAttr(Attr.getRange(), S.Context, start,
- size));
+ D->addAttr(::new (S.Context) AllocSizeAttr(Attr.getRange(), S.Context,
+ SizeArgs.data(), SizeArgs.size()));
}
static void handleNonNullAttr(Sema &S, Decl *D, const AttributeList &Attr) {
void* fn7(unsigned) __attribute__((alloc_size)); // expected-error {{attribute takes at least 1 argument}}
-void *fn8(int, int) __attribute__((alloc_size(1, 1))); // expected-error {{attribute parameter 2 is duplicated}}
+void *fn8(int, int) __attribute__((alloc_size(1, 1))); // OK
void* fn9(unsigned) __attribute__((alloc_size(12345678901234567890123))); // expected-warning {{integer constant is too large for its type}} // expected-error {{attribute parameter 1 is out of bounds}}