• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Compile with "cl /c /Zi /GR- TypeQualifiersTest.cpp"
2 // Link with "link TypeQualifiersTest.obj /debug /nodefaultlib /entry:main"
3 
4 union Union {
5   int * __restrict x_member;
6   float * __restrict y_member;
7   int* volatile __restrict m_volatile;
8   const char* m_const;
9 };
10 
f(const volatile int * __restrict arg_crv)11 int f(const volatile int* __restrict arg_crv) {
12   Union u;
13   return 1;
14 }
15 
g(int & __restrict arg_ref)16 void g(int& __restrict arg_ref) {
17 }
18 
19 namespace NS {
20   class Class {
21   public:
get() const22     int get() const { return 1;}
set()23     int set() __restrict { return 2; }
help()24     void help() volatile { return; }
25   };
26 
27   struct Foo {
28     int a;
29     int b;
funcNS::Foo30     int func(int x) __restrict { return 1; }
31   };
32 
33   Foo s = { 10 };
34 
35   const int* __restrict p_object = &s.a;
36 
37   volatile int Foo:: * __restrict p_data_member = &Foo::a;
38 
39   int (Foo::* p_member_func)(int) __restrict = &Foo::func;
40 }
41 
42 typedef long* __restrict RestrictTypedef;
43 RestrictTypedef RestrictVar;
44 
45 typedef volatile int* __restrict RankNArray[10][100];
46 RankNArray ArrayVar;
47 
main()48 int main() {
49   NS::Class ClassVar;
50   ClassVar.get();
51   ClassVar.help();
52   ClassVar.set();
53 
54   return 0;
55 }
56