if (StringLiteral *StrLit = dyn_cast<StringLiteral>(ArgExp)) {
if (StrLit->getLength() == 0 ||
- StrLit->getString() == StringRef("*")) {
+ (StrLit->isAscii() && StrLit->getString() == StringRef("*"))) {
// Pass empty strings to the analyzer without warnings.
// Treat "*" as the universal lock.
Args.push_back(ArgExp);
AvailabilityChange Obsoleted = Attr.getAvailabilityObsoleted();
bool IsUnavailable = Attr.getUnavailableLoc().isValid();
StringRef Str;
- const StringLiteral *SE =
- dyn_cast_or_null<const StringLiteral>(Attr.getMessageExpr());
- if (SE)
+ if (Attr.getMessageExpr()) {
+ const StringLiteral *SE = dyn_cast<StringLiteral>(Attr.getMessageExpr());
+ if (!SE || !SE->isAscii()) {
+ S.Diag(Attr.getMessageExpr()->getLocStart(),
+ diag::err_attribute_argument_type)
+ << Attr.getName() << AANT_ArgumentString;
+ return;
+ }
Str = SE->getString();
+ }
AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr(ND, Attr.getRange(), II,
Introduced.Version,
extern int x2 __attribute__((availability(macosx,introduced=10.2))); // expected-note {{previous attribute is here}}
extern int x2 __attribute__((availability(macosx,introduced=10.5))); // expected-warning {{availability does not match previous declaration}}
+
+extern int x3 __attribute__((availability(macosx,message=L"wide"))); // expected-error {{'availability' attribute requires a string}}
int gb_var_arg GUARDED_BY(mu1);
+int gb_non_ascii GUARDED_BY(L"wide"); // expected-warning {{ignoring 'guarded_by' attribute because its argument is invalid}}
+
int gb_var_args __attribute__((guarded_by(mu1, mu2))); // \
// expected-error {{'guarded_by' attribute takes one argument}}