You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow auto(x) to appear in a parenthesis
expression.
The pattern (auto( can appear as part of a declarator,
so the parser is modified to avoid the ambiguity,
in a way consistent with the proposed resolution to CWG1223.
Reviewed By: aaron.ballman, #clang-language-wg
Differential Revision: https://reviews.llvm.org/D149276
// RUN: not %clang_cc1 -std=c++17 %s -emit-llvm-only -fcxx-exceptions
3
4
4
5
structS { int a, b, c; };
@@ -30,7 +31,7 @@ namespace ForRangeDecl {
30
31
namespaceOtherDecl {
31
32
// A parameter-declaration is not a simple-declaration.
32
33
// This parses as an array declaration.
33
-
voidf(auto [a, b, c]); //expected-error {{'auto' not allowed in function prototype}} expected-error {{'a'}}
34
+
voidf(auto [a, b, c]); //cxx17-error {{'auto' not allowed in function prototype}} expected-error {{'a'}}
34
35
35
36
voidg() {
36
37
// A condition is allowed as a Clang extension.
@@ -57,7 +58,7 @@ namespace OtherDecl {
57
58
namespaceGoodSpecifiers {
58
59
voidf() {
59
60
int n[1];
60
-
constvolatileauto &[a] = n;
61
+
constvolatileauto &[a] = n;// cxx2b-warning {{volatile qualifier in structured binding declaration is deprecated}}
61
62
}
62
63
}
63
64
@@ -67,8 +68,8 @@ namespace BadSpecifiers {
67
68
structS { int n; } s;
68
69
voidf() {
69
70
// storage-class-specifiers
70
-
staticauto &[a] = n; //expected-warning {{declared 'static' is a C++20 extension}}
71
-
thread_localauto &[b] = n; //expected-warning {{declared 'thread_local' is a C++20 extension}}
71
+
staticauto &[a] = n; //cxx17-warning {{declared 'static' is a C++20 extension}}
72
+
thread_localauto &[b] = n; //cxx17-warning {{declared 'thread_local' is a C++20 extension}}
72
73
externauto &[c] = n; // expected-error {{cannot be declared 'extern'}} expected-error {{declaration of block scope identifier with linkage cannot have an initializer}}
73
74
structS {
74
75
mutableauto &[d] = n; // expected-error {{not permitted in this context}}
@@ -85,16 +86,19 @@ namespace BadSpecifiers {
85
86
}
86
87
87
88
staticconstexprinlinethread_localauto &[j1] = n; // expected-error {{cannot be declared with 'constexpr inline' specifiers}}
88
-
staticthread_localauto &[j2] = n; //expected-warning {{declared with 'static thread_local' specifiers is a C++20 extension}}
89
+
staticthread_localauto &[j2] = n; //cxx17-warning {{declared with 'static thread_local' specifiers is a C++20 extension}}
89
90
90
91
inlineauto &[k] = n; // expected-error {{cannot be declared 'inline'}}
91
92
92
93
constint K = 5;
94
+
auto ([c]) = s; // expected-error {{decomposition declaration cannot be declared with parentheses}}
93
95
voidg() {
94
96
// defining-type-specifiers other than cv-qualifiers and 'auto'
95
97
S [a] = s; // expected-error {{cannot be declared with type 'S'}}
96
98
decltype(auto) [b] = s; // expected-error {{cannot be declared with type 'decltype(auto)'}}
97
-
auto ([c]) = s; // expected-error {{cannot be declared with parentheses}}
99
+
auto ([c2]) = s; // cxx17-error {{decomposition declaration cannot be declared with parenthese}} \
100
+
// cxx2b-error {{use of undeclared identifier 'c2'}} \
101
+
// cxx2b-error {{expected body of lambda expression}} \
0 commit comments