}
template <typename AttrTy>
-static void handleAttrWithMessage(Sema &S, Decl *D, const AttributeList &Attr,
- const char *Name) {
+static void handleAttrWithMessage(Sema &S, Decl *D,
+ const AttributeList &Attr) {
unsigned NumArgs = Attr.getNumArgs();
if (NumArgs > 1) {
S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments) << 1;
StringLiteral *SE = dyn_cast<StringLiteral>(Attr.getArg(0));
if (!SE) {
S.Diag(Attr.getArg(0)->getLocStart(), diag::err_attribute_not_string)
- << Name;
+ << Attr.getName();
return;
}
Str = SE->getString();
handleCXX11NoReturnAttr(S, D, Attr);
break;
case AttributeList::AT_Deprecated:
- handleAttrWithMessage<DeprecatedAttr>(S, D, Attr, "deprecated");
+ handleAttrWithMessage<DeprecatedAttr>(S, D, Attr);
break;
case AttributeList::AT_Destructor: handleDestructorAttr (S, D, Attr); break;
case AttributeList::AT_ExtVectorType:
case AttributeList::AT_Packed: handlePackedAttr (S, D, Attr); break;
case AttributeList::AT_Section: handleSectionAttr (S, D, Attr); break;
case AttributeList::AT_Unavailable:
- handleAttrWithMessage<UnavailableAttr>(S, D, Attr, "unavailable");
+ handleAttrWithMessage<UnavailableAttr>(S, D, Attr);
break;
case AttributeList::AT_ArcWeakrefUnavailable:
handleArcWeakrefUnavailableAttr (S, D, Attr);
#define MY_TEXT "This is also deprecated"
__declspec(deprecated(MY_TEXT)) void Dfunc1( void ) {} // expected-note {{'Dfunc1' declared here}}
-struct __declspec(deprecated(123)) DS2 {}; // expected-error {{argument to deprecated attribute was not a string literal}}
+struct __declspec(deprecated(123)) DS2 {}; // expected-error {{argument to 'deprecated' attribute was not a string literal}}
void test( void ) {
e1 = one; // expected-warning {{'e1' is deprecated: This is deprecated}}
void bar() __attribute__((__unavailable__)); // expected-note {{explicitly marked unavailable}}
+int quux(void) __attribute__((__unavailable__(12))); // expected-error {{argument to '__unavailable__' attribute was not a string literal}}
+
+#define ACCEPTABLE "Use something else"
+int quux2(void) __attribute__((__unavailable__(ACCEPTABLE)));
+
void test_foo() {
int ir = foo(1); // expected-error {{'foo' is unavailable: USE IFOO INSTEAD}}
double dr = dfoo(1.0); // expected-error {{'dfoo' is unavailable: NO LONGER}}