@@ -143,6 +143,7 @@ def SharedVar : SubsetSubject<Var,
143143def GlobalVar : SubsetSubject<Var,
144144 [{S->hasGlobalStorage()}], "global variables">;
145145
146+
146147def ExternalGlobalVar : SubsetSubject<Var,
147148 [{S->hasGlobalStorage() &&
148149 S->getStorageClass()!=StorageClass::SC_Static &&
@@ -408,10 +409,14 @@ class SubjectList<list<AttrSubject> subjects, SubjectDiag diag = WarnDiag,
408409 string CustomDiag = customDiag;
409410}
410411
411- class LangOpt<string name, code customCode = [{}]> {
412+ class LangOpt<string name, code customCode = [{}], bit silentlyIgnore = 0 > {
412413 // The language option to test; ignored when custom code is supplied.
413414 string Name = name;
414415
416+ // If set to 1, the attribute is accepted but is silently ignored. This is
417+ // useful in multi-compilation situations like SYCL.
418+ bit SilentlyIgnore = silentlyIgnore;
419+
415420 // A custom predicate, written as an expression evaluated in a context with
416421 // "LangOpts" bound.
417422 code CustomCode = customCode;
@@ -422,6 +427,7 @@ def CUDA : LangOpt<"CUDA">;
422427def HIP : LangOpt<"HIP">;
423428def SYCLHost : LangOpt<"SYCLIsHost">;
424429def SYCLDevice : LangOpt<"SYCLIsDevice">;
430+ def SilentlyIgnoreSYCLHost : LangOpt<"SYCLIsHost", "", 1>;
425431def COnly : LangOpt<"", "!LangOpts.CPlusPlus">;
426432def CPlusPlus : LangOpt<"CPlusPlus">;
427433def OpenCL : LangOpt<"OpenCL">;
@@ -1545,6 +1551,18 @@ def SYCLKernel : InheritableAttr {
15451551 let Documentation = [SYCLKernelDocs];
15461552}
15471553
1554+ def GlobalStorageNonLocalVar : SubsetSubject<Var,
1555+ [{S->hasGlobalStorage() &&
1556+ !S->isLocalVarDeclOrParm()}],
1557+ "global variables">;
1558+
1559+ def SYCLExternal : InheritableAttr {
1560+ let Spellings = [GNU<"sycl_external">];
1561+ let Subjects = SubjectList<[Function, GlobalStorageNonLocalVar]>;
1562+ let LangOpts = [SYCLDevice, SilentlyIgnoreSYCLHost];
1563+ let Documentation = [SYCLExternalDocs];
1564+ }
1565+
15481566def SYCLKernelEntryPoint : InheritableAttr {
15491567 let Spellings = [Clang<"sycl_kernel_entry_point">];
15501568 let Args = [
0 commit comments