def warn_gnu_inline_attribute_requires_inline : Warning<
"'gnu_inline' attribute requires function to be marked 'inline',"
" attribute ignored">;
+def err_cconv_knr : Error<
+ "function with no prototype cannot use '%0' calling convention">;
+def err_cconv_varargs : Error<
+ "variadic function cannot use '%0' calling convention">;
def warn_attribute_ignored_for_field_of_type : Warning<
"%0 attribute ignored for field of type %1">;
d->addAttr(::new (S.Context) StdCallAttr());
}
+/// Diagnose the use of a non-standard calling convention on the given
+/// function.
+static void DiagnoseCConv(FunctionDecl *D, const char *CConv,
+ SourceLocation Loc, Sema &S) {
+ if (!D->hasPrototype()) {
+ S.Diag(Loc, diag::err_cconv_knr) << CConv;
+ return;
+ }
+
+ const FunctionProtoType *T = D->getType()->getAs<FunctionProtoType>();
+ if (T->isVariadic()) {
+ S.Diag(Loc, diag::err_cconv_varargs) << CConv;
+ return;
+ }
+}
+
static void HandleFastCallAttr(Decl *d, const AttributeList &Attr, Sema &S) {
// Attribute has no arguments.
if (Attr.getNumArgs() != 0) {
return;
}
+ DiagnoseCConv(cast<FunctionDecl>(d), "fastcall", Attr.getLoc(), S);
+
// stdcall and fastcall attributes are mutually incompatible.
if (d->getAttr<StdCallAttr>()) {
S.Diag(Attr.getLoc(), diag::err_attributes_are_not_compatible)
void __attribute__((fastcall(1))) baz(float *a) { // expected-error {{attribute requires 0 argument(s)}}
}
+
+void __attribute__((fastcall)) test0() { // expected-error {{function with no prototype cannot use 'fastcall' calling convention}}
+}
+
+void __attribute__((fastcall)) test1(void) {
+}
+
+void __attribute__((fastcall)) test2(int a, ...) { // expected-error {{variadic function cannot use 'fastcall' calling convention}}
+}
int __attribute__((fastcall)) var2; // expected-warning{{'fastcall' attribute only applies to function types}}
// Different CC qualifiers are not compatible
-void __attribute__((stdcall, fastcall)) foo3(); // expected-error{{stdcall and fastcall attributes are not compatible}}
+void __attribute__((stdcall, fastcall)) foo3(void); // expected-error{{stdcall and fastcall attributes are not compatible}}
void __attribute__((stdcall)) foo4();
-void __attribute__((fastcall)) foo4(); // expected-error{{fastcall and stdcall attributes are not compatible}}
+void __attribute__((fastcall)) foo4(void); // expected-error{{fastcall and stdcall attributes are not compatible}}