[cfe-commits] patch for review

Reed Kotler rkotler at mips.com
Sun Jan 13 18:34:19 PST 2013


I have not isolated the problem yet but in TargetAttributes.cpp, when 
you check the number of attribute arguments, I always get 0.

But other checks I do like checking whether an attribute is attached to 
a function work.

Attr.getNumArgs() is always coming back as 0.
Attr.getName() works fine.

The following test case for x86 fails also.

void  __attribute__((force_align_arg_pointer(foo))) p();

It fails to notice the argument foo passed to the attribute even though 
it checks the number of attribute args.

static void HandleX86ForceAlignArgPointerAttr(Decl *D,
                                               const AttributeList& Attr,
                                               Sema &S) {
   // Check the attribute arguments.
   if (Attr.getNumArgs() != 0) {
     S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
     return;
   }

On 01/12/2013 06:44 AM, Dmitri Gribenko wrote:
> On Sat, Jan 12, 2013 at 4:32 PM, Reed Kotler <rkotler at mips.com> wrote:
>> I don't have commit access to the clang list (as far as I know; just llvm).
>>
>> Please commit if you approve the patch.
> Since you have commit access to llvm, you have commit access to clang,
> and every other repository.
>
>> This patch is the first step to adding function attributes mips16 and
>> nomips16 to the mips
>> target.
> Please add
> let Subjects = [Function];
> just for documentation purposes now.  Somebody will come along in
> future and will write the necessary TableGen magic to make
> lib/Sema/SemaDeclAttr.cpp autogenerated.  (We hope!)
>
> +    bool ProcessDeclAttribute(Scope *scope, Decl *D, const AttributeList &Attr,
> +                              Sema &S) const {
>
> 1. scope -> Scope
>
> 2. Please add checks to ensure that there are no parameters passed to
> the attributes.
>
> 3. Please add tests for (2), like:
>
> void __attribute__((mips16(foo))) foo32(); // expected-error {{whatever}}
> void __attribute__((mips16(10))) foo32(); // expected-error {{whatever}}
>
> and same for nomips16.
>
> +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
>
> Triple is not needed in a target-independent test.
>
> +int main() {
> +  foo32();
> +  foo16();
> +}
>
> That is not needed.
>
> Another suggestion: should we reject these attributes when we are not
> targeting mips?
>
> Dmitri
>




More information about the cfe-commits mailing list