diff options
| -rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 10 | ||||
| -rw-r--r-- | clang/test/Sema/MicrosoftExtensions.c | 2 | ||||
| -rw-r--r-- | clang/test/Sema/attr-unavailable-message.c | 5 |
3 files changed, 11 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 4c18a330614..cdc9649d9ad 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2038,8 +2038,8 @@ static void handleDestructorAttr(Sema &S, Decl *D, const AttributeList &Attr) { } 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; @@ -2052,7 +2052,7 @@ static void handleAttrWithMessage(Sema &S, Decl *D, const AttributeList &Attr, 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(); @@ -4792,7 +4792,7 @@ static void ProcessInheritableDeclAttr(Sema &S, Scope *scope, Decl *D, 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: @@ -4873,7 +4873,7 @@ static void ProcessInheritableDeclAttr(Sema &S, Scope *scope, Decl *D, 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); diff --git a/clang/test/Sema/MicrosoftExtensions.c b/clang/test/Sema/MicrosoftExtensions.c index 5215e72b1ba..6bafc364828 100644 --- a/clang/test/Sema/MicrosoftExtensions.c +++ b/clang/test/Sema/MicrosoftExtensions.c @@ -96,7 +96,7 @@ struct __declspec(deprecated) DS1 { int i; float f; }; // expected-note {{declar #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}} diff --git a/clang/test/Sema/attr-unavailable-message.c b/clang/test/Sema/attr-unavailable-message.c index 97104960e5e..1e1e19e60b7 100644 --- a/clang/test/Sema/attr-unavailable-message.c +++ b/clang/test/Sema/attr-unavailable-message.c @@ -6,6 +6,11 @@ double dfoo(double) __attribute__((__unavailable__("NO LONGER"))); // expected- 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}} |

