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 | e2f82f71385051ce5abfba317d2f592aa332c588 (patch) | |
tree | 3bf4b0600e84f672f2eb7cbe6d58f661ceb73a9f /lib/Sema/DeclSpec.cpp | |
parent | 98caa2ccf04c02d14c99b3a918e0c6da57efddf4 (diff) |
Reject forbidden storage class specifiers in OpenCL. Patch by George Russell!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125399 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/DeclSpec.cpp')
-rw-r--r-- | lib/Sema/DeclSpec.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/Sema/DeclSpec.cpp b/lib/Sema/DeclSpec.cpp index 8a35ab7092..bc289ec42c 100644 --- a/lib/Sema/DeclSpec.cpp +++ b/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 |