CC_C;
break;
case AttributeList::AT_Pcs: {
- StringLiteral *Str = 0;
- if (attr.isArgExpr(0))
- Str = dyn_cast<StringLiteral>(attr.getArgAsExpr(0));
-
- if (!Str || !Str->isAscii()) {
- Diag(attr.getLoc(), diag::err_attribute_argument_type) << attr.getName()
- << AANT_ArgumentString;
+ StringRef StrRef;
+ if (!checkStringLiteralArgument(*this, StrRef, attr, 0)) {
attr.setInvalid();
return true;
}
-
- StringRef StrRef = Str->getString();
if (StrRef == "aapcs") {
CC = CC_AAPCS;
break;
case AttributeList::AT_Pascal:
return AttributedType::attr_pascal;
case AttributeList::AT_Pcs: {
- // We know attr is valid so it can only have one of two strings args.
- StringLiteral *Str = cast<StringLiteral>(Attr.getArgAsExpr(0));
- return llvm::StringSwitch<AttributedType::Kind>(Str->getString())
+ // The attribute may have had a fixit applied where we treated an
+ // identifier as a string literal. The contents of the string are valid,
+ // but the form may not be.
+ StringRef Str;
+ if (Attr.isArgExpr(0))
+ Str = cast<StringLiteral>(Attr.getArgAsExpr(0))->getString();
+ else
+ Str = Attr.getArgAsIdent(0)->Ident->getName();
+ return llvm::StringSwitch<AttributedType::Kind>(Str)
.Case("aapcs", AttributedType::attr_pcs)
.Case("aapcs-vfp", AttributedType::attr_pcs_vfp);
}
int __attribute__((pcs("aapcs", "aapcs"))) pcs1(void); // expected-error {{'pcs' attribute takes one argument}}
int __attribute__((pcs())) pcs2(void); // expected-error {{'pcs' attribute takes one argument}}
-int __attribute__((pcs(pcs1))) pcs3(void); // expected-error {{'pcs' attribute requires a string}}
+int __attribute__((pcs(pcs1))) pcs3(void); // expected-error {{'pcs' attribute requires a string}} \
+ // expected-error {{invalid PCS type}}
int __attribute__((pcs(0))) pcs4(void); // expected-error {{'pcs' attribute requires a string}}
/* These are ignored because the target is i386 and not ARM */
int __attribute__((pcs("aapcs"))) pcs5(void); // expected-warning {{calling convention 'pcs' ignored for this target}}