[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

Eli Friedman eli.friedman at gmail.com
Sat Jun 27 18:04:19 PDT 2009


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?

-Eli




More information about the cfe-commits mailing list