diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-08-14 13:13:47 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-08-14 13:13:47 +0000 |
commit | fac8e43390fad67a5d02c9876e860496fee01868 (patch) | |
tree | faec1ebb193e0ebabebe2d06c18f23f1c21669ec | |
parent | 5d46db8882002c09c988b021b38c2334aa23f535 (diff) |
Fix horribly broken sema of __attribute__((pcs())).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161863 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 12 | ||||
-rw-r--r-- | test/Sema/callingconv.c | 8 |
2 files changed, 15 insertions, 5 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 22bff863c5..37c4948cb1 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -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"); } diff --git a/test/Sema/callingconv.c b/test/Sema/callingconv.c index 25669f08ae..6c844a3733 100644 --- a/test/Sema/callingconv.c +++ b/test/Sema/callingconv.c @@ -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() {} |