storageclass.cl 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
  2. static constant int G1 = 0;
  3. constant int G2 = 0;
  4. int G3 = 0; // expected-error{{program scope variable must reside in constant address space}}
  5. global int G4 = 0; // expected-error{{program scope variable must reside in constant address space}}
  6. static float g_implicit_static_var = 0; // expected-error {{program scope variable must reside in constant address space}}
  7. static constant float g_constant_static_var = 0;
  8. static global float g_global_static_var = 0; // expected-error {{program scope variable must reside in constant address space}}
  9. static local float g_local_static_var = 0; // expected-error {{program scope variable must reside in constant address space}}
  10. static private float g_private_static_var = 0; // expected-error {{program scope variable must reside in constant address space}}
  11. static generic float g_generic_static_var = 0; // expected-error{{OpenCL C version 1.2 does not support the 'generic' type qualifier}} // expected-error {{program scope variable must reside in constant address space}}
  12. extern float g_implicit_extern_var; // expected-error {{extern variable must reside in constant address space}}
  13. extern constant float g_constant_extern_var;
  14. extern global float g_global_extern_var; // expected-error {{extern variable must reside in constant address space}}
  15. extern local float g_local_extern_var; // expected-error {{extern variable must reside in constant address space}}
  16. extern private float g_private_extern_var; // expected-error {{extern variable must reside in constant address space}}
  17. extern generic float g_generic_extern_var; // expected-error{{OpenCL C version 1.2 does not support the 'generic' type qualifier}} // expected-error {{extern variable must reside in constant address space}}
  18. void kernel foo(int x) {
  19. // static is not allowed at local scope before CL2.0
  20. static int S1 = 5; // expected-error{{variables in function scope cannot be declared static}}
  21. static constant int S2 = 5; // expected-error{{variables in function scope cannot be declared static}}
  22. constant int L1 = 0;
  23. local int L2;
  24. if (true) {
  25. local int L1; // expected-error {{variables in the local address space can only be declared in the outermost scope of a kernel function}}
  26. constant int L1 = 42; // expected-error {{variables in the constant address space can only be declared in the outermost scope of a kernel function}}
  27. }
  28. auto int L3 = 7; // expected-error{{OpenCL C version 1.2 does not support the 'auto' storage class specifier}}
  29. global int L4; // expected-error{{function scope variable cannot be declared in global address space}}
  30. __attribute__((address_space(100))) int L5; // expected-error{{automatic variable qualified with an invalid address space}}
  31. constant int L6 = x; // expected-error {{initializer element is not a compile-time constant}}
  32. global int *constant L7 = &G4;
  33. private int *constant L8 = &x; // expected-error {{initializer element is not a compile-time constant}}
  34. constant int *constant L9 = &L1;
  35. local int *constant L10 = &L2; // expected-error {{initializer element is not a compile-time constant}}
  36. }
  37. static void kernel bar() { // expected-error{{kernel functions cannot be declared static}}
  38. }
  39. void f() {
  40. constant int L1 = 0; // expected-error{{non-kernel function variable cannot be declared in constant address space}}
  41. local int L2; // expected-error{{non-kernel function variable cannot be declared in local address space}}
  42. global int L3; // expected-error{{function scope variable cannot be declared in global address space}}
  43. __attribute__((address_space(100))) int L4; // expected-error{{automatic variable qualified with an invalid address space}}
  44. {
  45. constant int L1 = 0; // expected-error{{non-kernel function variable cannot be declared in constant address space}}
  46. local int L2; // expected-error{{non-kernel function variable cannot be declared in local address space}}
  47. global int L3; // expected-error{{function scope variable cannot be declared in global address space}}
  48. __attribute__((address_space(100))) int L4; // expected-error{{automatic variable qualified with an invalid address space}}
  49. }
  50. static float l_implicit_static_var = 0; // expected-error {{variables in function scope cannot be declared static}}
  51. static constant float l_constant_static_var = 0; // expected-error {{variables in function scope cannot be declared static}}
  52. static global float l_global_static_var = 0; // expected-error {{variables in function scope cannot be declared static}}
  53. static local float l_local_static_var = 0; // expected-error {{variables in function scope cannot be declared static}}
  54. static private float l_private_static_var = 0; // expected-error {{variables in function scope cannot be declared static}}
  55. static generic float l_generic_static_var = 0; // expected-error{{OpenCL C version 1.2 does not support the 'generic' type qualifier}} // expected-error {{variables in function scope cannot be declared static}}
  56. extern float l_implicit_extern_var; // expected-error {{extern variable must reside in constant address space}}
  57. extern constant float l_constant_extern_var;
  58. extern global float l_global_extern_var; // expected-error {{extern variable must reside in constant address space}}
  59. extern local float l_local_extern_var; // expected-error {{extern variable must reside in constant address space}}
  60. extern private float l_private_extern_var; // expected-error {{extern variable must reside in constant address space}}
  61. extern generic float l_generic_extern_var; // expected-error{{OpenCL C version 1.2 does not support the 'generic' type qualifier}} // expected-error {{extern variable must reside in constant address space}}
  62. }