diff options
| author | Peter Collingbourne <peter@pcc.me.uk> | 2011-02-11 19:59:54 +0000 |
|---|---|---|
| committer | Peter Collingbourne <peter@pcc.me.uk> | 2011-02-11 19:59:54 +0000 |
| commit | de32b20bdd1bb32967e52aff6947c0a579363a44 (patch) | |
| tree | 07f477ff4e1f5f9d45f4b3cdc295d57db7c984e7 /clang/lib/Sema/DeclSpec.cpp | |
| parent | a49a02a04f5fc09f67a8bfbe84193e28d7452bfe (diff) | |
| download | bcm5719-llvm-de32b20bdd1bb32967e52aff6947c0a579363a44.tar.gz bcm5719-llvm-de32b20bdd1bb32967e52aff6947c0a579363a44.zip | |
Reject forbidden storage class specifiers in OpenCL. Patch by George Russell!
llvm-svn: 125399
Diffstat (limited to 'clang/lib/Sema/DeclSpec.cpp')
| -rw-r--r-- | clang/lib/Sema/DeclSpec.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index 8a35ab70923..bc289ec42c9 100644 --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -226,7 +226,25 @@ const char *DeclSpec::getSpecifierName(TQ T) { bool DeclSpec::SetStorageClassSpec(SCS S, SourceLocation Loc, const char *&PrevSpec, - unsigned &DiagID) { + unsigned &DiagID, + const LangOptions &Lang) { + // OpenCL prohibits extern, auto, register, and static + // It seems sensible to prohibit private_extern too + if (Lang.OpenCL) { + switch (S) { + case SCS_extern: + case SCS_private_extern: + case SCS_auto: + case SCS_register: + case SCS_static: + DiagID = diag::err_not_opencl_storage_class_specifier; + PrevSpec = getSpecifierName(S); + return true; + default: + break; + } + } + if (StorageClassSpec != SCS_unspecified) { // Changing storage class is allowed only if the previous one // was the 'extern' that is part of a linkage specification and |

