Clang Project

clang_source_code/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp
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
4
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).
7
8auto 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
12
13auto 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
17
18register int ro; // expected-error {{illegal storage class on file-scoped variable}}
19#if __cplusplus >= 201103L // C++11 or later
20// expected-warning@-2 {{'register' storage class specifier is deprecated}}
21#endif
22
23register void rf(); // expected-error {{illegal storage class on function}}
24
25struct S {
26  auto int ao; // expected-error {{storage class specified for a member declaration}}
27#if __cplusplus >= 201103L // C++11 or later
28// expected-warning@-2 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}}
29#endif
30  auto void af(); // expected-error {{storage class specified for a member declaration}}
31#if __cplusplus >= 201103L // C++11 or later
32// expected-warning@-2 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}}
33#endif
34
35  register int ro; // expected-error {{storage class specified for a member declaration}}
36  register void rf(); // expected-error {{storage class specified for a member declaration}}
37};
38
39void foo(auto int ap, register int rp) {
40#if __cplusplus >= 201103L // C++11 or later
41// expected-warning@-2 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}}
42// expected-warning@-3 {{'register' storage class specifier is deprecated}}
43#endif
44  auto int abo;
45#if __cplusplus >= 201103L // C++11 or later
46// expected-warning@-2 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}}
47#endif
48  auto void abf(); // expected-error {{illegal storage class on function}}
49#if __cplusplus >= 201103L // C++11 or later
50// expected-warning@-2 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}}
51#endif
52
53  register int rbo;
54#if __cplusplus >= 201103L // C++11 or later
55// expected-warning@-2 {{'register' storage class specifier is deprecated}}
56#endif
57
58  register void rbf(); // expected-error {{illegal storage class on function}}
59}
60