[lldb][Windows] Fix build with MSVC compiler broken by (#108072)
[llvm-project.git] / clang / test / CXX / dcl.dcl / dcl.spec / dcl.stc / p2.cpp
blob723a79628116cce6555d98084cc36d070e49795a
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
5 // The auto or register specifiers can be applied only to names of objects
6 // declared in a block (6.3) or to function parameters (8.4).
8 auto int ao; // expected-error {{illegal storage class on file-scoped variable}}
9 #if __cplusplus >= 201103L // C++11 or later
10 // expected-warning@-2 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}}
11 #endif
13 auto void af(); // expected-error {{illegal storage class on function}}
14 #if __cplusplus >= 201103L // C++11 or later
15 // expected-warning@-2 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}}
16 #endif
18 register int ro; // expected-error {{illegal storage class on file-scoped variable}}
19 #if __cplusplus >= 201703L
20 // expected-error@-2 {{ISO C++17 does not allow 'register' storage class specifier}}
21 #elif __cplusplus >= 201103L
22 // expected-warning@-4 {{'register' storage class specifier is deprecated}}
23 #endif
25 register void rf(); // expected-error {{illegal storage class on function}}
27 struct S {
28 auto int ao; // expected-error {{storage class specified for a member declaration}}
29 #if __cplusplus >= 201103L // C++11 or later
30 // expected-warning@-2 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}}
31 #endif
32 auto void af(); // expected-error {{storage class specified for a member declaration}}
33 #if __cplusplus >= 201103L // C++11 or later
34 // expected-warning@-2 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}}
35 #endif
37 register int ro; // expected-error {{storage class specified for a member declaration}}
38 register void rf(); // expected-error {{storage class specified for a member declaration}}
41 void foo(auto int ap, register int rp) {
42 #if __cplusplus >= 201703L
43 // expected-warning@-2 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}}
44 // expected-error@-3 {{ISO C++17 does not allow 'register' storage class specifier}}
45 #elif __cplusplus >= 201103L
46 // expected-warning@-5 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}}
47 // expected-warning@-6 {{'register' storage class specifier is deprecated}}
48 #endif
49 auto int abo;
50 #if __cplusplus >= 201103L // C++11 or later
51 // expected-warning@-2 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}}
52 #endif
53 auto void abf(); // expected-error {{illegal storage class on function}}
54 #if __cplusplus >= 201103L // C++11 or later
55 // expected-warning@-2 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}}
56 #endif
58 register int rbo;
59 #if __cplusplus >= 201703L
60 // expected-error@-2 {{ISO C++17 does not allow 'register' storage class specifier}}
61 #elif __cplusplus >= 201103L
62 // expected-warning@-4 {{'register' storage class specifier is deprecated}}
63 #endif
65 register void rbf(); // expected-error {{illegal storage class on function}}