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
diff --git a/lib/Sema/DeclSpec.cpp b/lib/Sema/DeclSpec.cpp
index 8a35ab7..bc289ec 100644
--- a/lib/Sema/DeclSpec.cpp
+++ b/lib/Sema/DeclSpec.cpp
@@ -226,7 +226,25 @@
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