diff options
author | Guy Benyei <guy.benyei@intel.com> | 2013-01-20 12:31:11 +0000 |
---|---|---|
committer | Guy Benyei <guy.benyei@intel.com> | 2013-01-20 12:31:11 +0000 |
commit | e6b9d802fb7b16d93474c4f1c179ab36202e8a8b (patch) | |
tree | 9a396d8d98d2ac759c7050a9838cd3439f6ba02a /lib/Sema/SemaDecl.cpp | |
parent | b3ce35764adcc5749e8729709b1f3737227d90ec (diff) |
Implement OpenCL event_t as Clang builtin type, including event_t related OpenCL restrictions (OpenCL 1.2 spec 6.9)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172973 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index dbdbc3d6a2..7936efa136 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -4401,6 +4401,22 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, SC = SC_OpenCLWorkGroupLocal; SCAsWritten = SC_OpenCLWorkGroupLocal; } + + // OpenCL 1.2 spec, p6.9 r: + // The event type cannot be used to declare a program scope variable. + // The event type cannot be used with the __local, __constant and __global + // address space qualifiers. + if (R->isEventT()) { + if (S->getParent() == 0) { + Diag(D.getLocStart(), diag::err_event_t_global_var); + D.setInvalidType(); + } + + if (R.getAddressSpace()) { + Diag(D.getLocStart(), diag::err_event_t_addr_space_qual); + D.setInvalidType(); + } + } } bool isExplicitSpecialization = false; @@ -6136,12 +6152,26 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, } } - // OpenCL v1.2 s6.8 static is invalid for kernel functions. - if ((getLangOpts().OpenCLVersion >= 120) - && NewFD->hasAttr<OpenCLKernelAttr>() - && (SC == SC_Static)) { - Diag(D.getIdentifierLoc(), diag::err_static_kernel); - D.setInvalidType(); + if (NewFD->hasAttr<OpenCLKernelAttr>()) { + + // OpenCL v1.2 s6.8 static is invalid for kernel functions. + if ((getLangOpts().OpenCLVersion >= 120) + && (SC == SC_Static)) { + Diag(D.getIdentifierLoc(), diag::err_static_kernel); + D.setInvalidType(); + } + + // OpenCL v1.2 s6.8 n: + // Arguments to kernel functions in a program cannot be declared to be of + // type event_t. + for (FunctionDecl::param_iterator PI = NewFD->param_begin(), + PE = NewFD->param_end(); PI != PE; ++PI) { + if ((*PI)->getType()->isEventT()) { + Diag((*PI)->getLocation(), diag::err_event_t_kernel_arg); + D.setInvalidType(); + } + } + } MarkUnusedFileScopedDecl(NewFD); @@ -9776,6 +9806,14 @@ FieldDecl *Sema::HandleField(Scope *S, RecordDecl *Record, } } + // OpenCL 1.2 spec, s6.9 r: + // The event type cannot be used to declare a structure or union field. + if (LangOpts.OpenCL && T->isEventT()) { + Diag(Loc, diag::err_event_t_struct_field); + D.setInvalidType(); + } + + DiagnoseFunctionSpecifiers(D); if (D.getDeclSpec().isThreadSpecified()) |