summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/Basic/Attr.td4
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp15
-rw-r--r--clang/test/Sema/renderscript.rs10
3 files changed, 12 insertions, 17 deletions
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index 0187f829f09..9d1453495da 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -240,6 +240,7 @@ def Borland : LangOpt<"Borland">;
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 @@ def OpenCLNoSVM : Attr {
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 {
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index b3846157ffc..ec8746b681c 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -4185,17 +4185,6 @@ static void handleTypeTagForDatatypeAttr(Sema &S, Decl *D,
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 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
handleTypeTagForDatatypeAttr(S, D, Attr);
break;
- case AttributeList::AT_Kernel:
- handleKernelAttr(S, D, Attr);
+ case AttributeList::AT_RenderScriptKernel:
+ handleSimpleAttribute<RenderScriptKernelAttr>(S, D, Attr);
break;
}
}
diff --git a/clang/test/Sema/renderscript.rs b/clang/test/Sema/renderscript.rs
index c6ffb4df1cf..80be5ae424f 100644
--- a/clang/test/Sema/renderscript.rs
+++ b/clang/test/Sema/renderscript.rs
@@ -2,11 +2,15 @@
// RUN: %clang_cc1 -fsyntax-only -verify -x c %s
#ifndef __RENDERSCRIPT__
-// expected-warning@+2 {{kernel attribute ignored}}
+// expected-warning@+2 {{'kernel' attribute ignored}}
#endif
-void __attribute__((kernel)) kernel();
+void __attribute__((kernel)) kernel() {}
-// expected-warning@+1 {{'kernel' attribute only applies to functions}}
+#ifndef __RENDERSCRIPT__
+// expected-warning@+4 {{'kernel' attribute ignored}}
+#else
+// expected-warning@+2 {{'kernel' attribute only applies to functions}}
+#endif
int __attribute__((kernel)) global;
#ifndef __RENDERSCRIPT__
OpenPOWER on IntegriCloud