[PATCH] D21240: Revise RenderScript attribute declaration

Pirama Arumuga Nainar via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 10 14:57:57 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL272438: Revise RenderScript attribute declaration (authored by pirama).

Changed prior to commit:
  http://reviews.llvm.org/D21240?vs=60397&id=60411#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21240

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/Sema/renderscript.rs

Index: cfe/trunk/include/clang/Basic/Attr.td
===================================================================
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -240,6 +240,7 @@
 def CUDA : LangOpt<"CUDA">;
 def COnly : LangOpt<"CPlusPlus", 1>;
 def OpenCL : LangOpt<"OpenCL">;
+def RenderScript : LangOpt<"RenderScript">;
 
 // Defines targets for target-specific attributes. The list of strings should
 // specify architectures for which the target applies, based off the ArchType
@@ -728,10 +729,11 @@
   let ASTNode = 0;
 }
 
-def Kernel : Attr {
+def RenderScriptKernel : Attr {
   let Spellings = [GNU<"kernel">];
   let Subjects = SubjectList<[Function]>;
   let Documentation = [Undocumented];
+  let LangOpts = [RenderScript];
 }
 
 def Deprecated : InheritableAttr {
Index: cfe/trunk/test/Sema/renderscript.rs
===================================================================
--- cfe/trunk/test/Sema/renderscript.rs
+++ cfe/trunk/test/Sema/renderscript.rs
@@ -2,11 +2,15 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -x c %s
 
 #ifndef __RENDERSCRIPT__
-// expected-warning at +2 {{kernel attribute ignored}}
+// expected-warning at +2 {{'kernel' attribute ignored}}
 #endif
-void __attribute__((kernel)) kernel();
+void __attribute__((kernel)) kernel() {}
 
-// expected-warning at +1 {{'kernel' attribute only applies to functions}}
+#ifndef __RENDERSCRIPT__
+// expected-warning at +4 {{'kernel' attribute ignored}}
+#else
+// expected-warning at +2 {{'kernel' attribute only applies to functions}}
+#endif
 int __attribute__((kernel)) global;
 
 #ifndef __RENDERSCRIPT__
Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -4185,17 +4185,6 @@
                                     Attr.getAttributeSpellingListIndex()));
 }
 
-static void handleKernelAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (S.LangOpts.RenderScript) {
-    D->addAttr(::new (S.Context)
-               KernelAttr(Attr.getRange(), S.Context,
-                          Attr.getAttributeSpellingListIndex()));
-  } else {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << "kernel";
-  }
-}
-
-
 //===----------------------------------------------------------------------===//
 // Checker-specific attribute handlers.
 //===----------------------------------------------------------------------===//
@@ -5925,8 +5914,8 @@
     handleTypeTagForDatatypeAttr(S, D, Attr);
     break;
 
-  case AttributeList::AT_Kernel:
-    handleKernelAttr(S, D, Attr);
+  case AttributeList::AT_RenderScriptKernel:
+    handleSimpleAttribute<RenderScriptKernelAttr>(S, D, Attr);
     break;
   }
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21240.60411.patch
Type: text/x-patch
Size: 2754 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160610/1da409ca/attachment.bin>


More information about the cfe-commits mailing list