forked from OSchip/llvm-project
Fix horribly broken sema of __attribute__((pcs())).
llvm-svn: 161863
This commit is contained in:
parent
ef7758f561
commit
833fb9f7e3
|
@ -3560,10 +3560,9 @@ bool Sema::CheckCallingConvAttr(const AttributeList &attr, CallingConv &CC) {
|
|||
if (attr.isInvalid())
|
||||
return true;
|
||||
|
||||
if ((attr.getNumArgs() != 0 &&
|
||||
!(attr.getKind() == AttributeList::AT_Pcs && attr.getNumArgs() == 1)) ||
|
||||
attr.getParameterName()) {
|
||||
Diag(attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
|
||||
unsigned ReqArgs = attr.getKind() == AttributeList::AT_Pcs ? 1 : 0;
|
||||
if (attr.getNumArgs() != ReqArgs || attr.getParameterName()) {
|
||||
Diag(attr.getLoc(), diag::err_attribute_wrong_number_arguments) << ReqArgs;
|
||||
attr.setInvalid();
|
||||
return true;
|
||||
}
|
||||
|
@ -3594,7 +3593,10 @@ bool Sema::CheckCallingConvAttr(const AttributeList &attr, CallingConv &CC) {
|
|||
CC = CC_AAPCS_VFP;
|
||||
break;
|
||||
}
|
||||
// FALLS THROUGH
|
||||
|
||||
attr.setInvalid();
|
||||
Diag(attr.getLoc(), diag::err_invalid_pcs);
|
||||
return true;
|
||||
}
|
||||
default: llvm_unreachable("unexpected attribute kind");
|
||||
}
|
||||
|
|
|
@ -36,6 +36,14 @@ void (__attribute__((cdecl)) *pctest2)() = ctest2;
|
|||
typedef void (__attribute__((fastcall)) *Handler) (float *);
|
||||
Handler H = foo;
|
||||
|
||||
int __attribute__((pcs("aapcs", "aapcs"))) pcs1(void); // expected-error {{attribute takes one argument}}
|
||||
int __attribute__((pcs())) pcs2(void); // expected-error {{attribute takes one argument}}
|
||||
int __attribute__((pcs(pcs1))) pcs3(void); // expected-error {{attribute takes one argument}}
|
||||
int __attribute__((pcs(0))) pcs4(void); // expected-error {{'pcs' attribute requires parameter 1 to be a string}}
|
||||
int __attribute__((pcs("aapcs"))) pcs5(void); // no-error
|
||||
int __attribute__((pcs("aapcs-vfp"))) pcs6(void); // no-error
|
||||
int __attribute__((pcs("foo"))) pcs7(void); // expected-error {{Invalid PCS type}}
|
||||
|
||||
// PR6361
|
||||
void ctest3();
|
||||
void __attribute__((cdecl)) ctest3() {}
|
||||
|
|
Loading…
Reference in New Issue