DIAG(warn_transparent_union_nonpointer, WARNING,
"'transparent_union' attribute support incomplete; only supported for "
"pointer unions")
+
+DIAG(warn_attribute_sentinel_named_arguments, WARNING,
+ "'sentinel' attribute requires named arguments")
DIAG(warn_attribute_sentinel_not_variadic, WARNING,
"'sentinel' attribute only supported for variadic functions")
DIAG(err_attribute_sentinel_less_than_zero, ERROR,
"'transparent_union' attribute support incomplete; only supported for "
"pointer unions">;
+def warn_attribute_sentinel_named_arguments : Warning<
+ "'sentinel' attribute requires named arguments">;
def warn_attribute_sentinel_not_variadic : Warning<
"'sentinel' attribute only supported for variadic functions">;
def err_attribute_sentinel_less_than_zero : Error<
}
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(d)) {
- QualType FT = FD->getType();
- if (!FT->getAsFunctionProtoType()->isVariadic()) {
+ const FunctionType *FT = FD->getType()->getAsFunctionType();
+ assert(FT && "FunctionDecl has non-function type?");
+
+ if (isa<FunctionNoProtoType>(FT)) {
+ S.Diag(Attr.getLoc(), diag::warn_attribute_sentinel_named_arguments);
+ return;
+ }
+
+ if (!cast<FunctionProtoType>(FT)->isVariadic()) {
S.Diag(Attr.getLoc(), diag::warn_attribute_sentinel_not_variadic);
return;
}
void f5(int a) __attribute__ ((sentinel)); //expected-warning{{'sentinel' attribute only supported for variadic functions}}
+
+void f6() __attribute__((__sentinel__)); // expected-warning {{'sentinel' attribute requires named arguments}}