[cfe-commits] r74280 - in /cfe/trunk: include/clang/AST/Attr.h include/clang/Parse/AttributeList.h lib/Frontend/PCHReaderDecl.cpp lib/Frontend/PCHWriter.cpp lib/Parse/AttributeList.cpp lib/Parse/ParseDecl.cpp lib/Sema/SemaDeclAttr.cpp

Nate Begeman natebegeman at mac.com
Sat Jun 27 18:22:20 PDT 2009


On Jun 27, 2009, at 8:04 PM, Eli Friedman wrote:

> On Thu, Jun 25, 2009 at 11:32 PM, Nate Begeman<natebegeman at mac.com>  
> wrote:
>> +static void HandleReqdWorkGroupSize(Decl *D, const AttributeList  
>> &Attr,
>> +                                    Sema &S) {
>> +  // Attribute has 3 arguments.
>> +  if (Attr.getNumArgs() != 3) {
>> +    S.Diag(Attr.getLoc(),  
>> diag::err_attribute_wrong_number_arguments) << 1;
>> +    return;
>> +  }
>> +
>> +  unsigned WGSize[3];
>> +  for (unsigned i = 0; i < 3; ++i) {
>> +    Expr *E = static_cast<Expr *>(Attr.getArg(i));
>> +    llvm::APSInt ArgNum(32);
>> +    if (!E->isIntegerConstantExpr(ArgNum, S.Context)) {
>> +      S.Diag(Attr.getLoc(), diag::err_attribute_argument_not_int)
>> +        << "reqd_work_group_size" << E->getSourceRange();
>> +      return;
>> +    }
>> +    WGSize[i] = (unsigned) ArgNum.getZExtValue();
>> +  }
>> +  D->addAttr(S.Context,
>> +             ::new (S.Context) ReqdWorkGroupSizeAttr(WGSize[0],  
>> WGSize[1],
>> +                                                     WGSize[2]));
>> +}
>
> Shouldn't there be some sort of check that this attribute isn't
> applied to anything other than an __kernel?

That would require an ordering of attributes not required by the  
spec.  Currently it's just up to codegen to do something with this  
attribute other than ignore it.

Nate




More information about the cfe-commits mailing list