"Objective-C declarations may only appear in global scope")
// Attributes
+DIAG(err_attributes_are_not_compatible, ERROR,
+ "%0 and %1 attributes are not compatible")
DIAG(err_attribute_wrong_number_arguments, ERROR,
"attribute requires %0 argument(s)")
DIAG(err_attribute_missing_parameter_name, ERROR,
"automatic variable qualified with an address space")
DIAG(err_attribute_annotate_no_string, ERROR,
"argument to annotate attribute was not a string literal")
+DIAG(warn_redeclaration_without_attribute_prev_attribute_ignored, WARNING,
+ "'%0' redeclared without %1 attribute: previous %1 ignored")
DIAG(warn_attribute_ignored, WARNING,
"%0 attribute ignored")
DIAG(warn_attribute_weak_on_field, WARNING,
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return;
}
-
+
d->addAttr(new DLLImportAttr());
}
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return;
}
-
+
d->addAttr(new DLLExportAttr());
}
static void HandleStdCallAttr(Decl *d, const AttributeList &Attr, Sema &S) {
- // check the attribute arguments.
+ // Attribute has no arguments.
if (Attr.getNumArgs() != 0) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return;
}
-
+
+ // Attribute can be applied only to functions.
+ if (!isa<FunctionDecl>(d)) {
+ S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
+ << "stdcall" << "function";
+ return;
+ }
+
+ // stdcall and fastcall attributes are mutually incompatible.
+ if (d->getAttr<FastCallAttr>()) {
+ S.Diag(Attr.getLoc(), diag::err_attributes_are_not_compatible)
+ << "stdcall" << "fastcall";
+ return;
+ }
+
d->addAttr(new StdCallAttr());
}
static void HandleFastCallAttr(Decl *d, const AttributeList &Attr, Sema &S) {
- // check the attribute arguments.
+ // Attribute has no arguments.
if (Attr.getNumArgs() != 0) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return;
}
-
+
+ if (!isa<FunctionDecl>(d)) {
+ S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
+ << "fastcall" << "function";
+ return;
+ }
+
+ // stdcall and fastcall attributes are mutually incompatible.
+ if (d->getAttr<StdCallAttr>()) {
+ S.Diag(Attr.getLoc(), diag::err_attributes_are_not_compatible)
+ << "fastcall" << "stdcall";
+ return;
+ }
+
d->addAttr(new FastCallAttr());
}