File tree Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -1687,8 +1687,9 @@ class parser
1687
1687
if (term.op ->type () == lexeme::LeftBracket)
1688
1688
{
1689
1689
term.expr_list = expression_list (term.op );
1690
- if (!term.expr_list ) {
1691
- error (" subscript expression [ ] must not be empty" );
1690
+ if (!term.expr_list || term.expr_list ->expressions .empty ()) {
1691
+ error (" subscript expression [ ] must not be empty (if you were trying to name a C-style array type, use 'std::array' instead)" );
1692
+ next ();
1692
1693
return {};
1693
1694
}
1694
1695
if (curr ().type () != lexeme::RightBracket) {
@@ -2121,26 +2122,30 @@ class parser
2121
2122
n->pos = id->position ();
2122
2123
n->id = std::move (id);
2123
2124
assert (n->id .index () == type_id_node::qualified);
2124
- return n;
2125
2125
}
2126
- if (auto id = unqualified_id ()) {
2126
+ else if (auto id = unqualified_id ()) {
2127
2127
n->pos = id->position ();
2128
2128
n->id = std::move (id);
2129
2129
assert (n->id .index () == type_id_node::unqualified);
2130
- return n;
2131
2130
}
2132
- if (curr ().type () == lexeme::Keyword || curr ().type () == lexeme::Cpp2FixedType) {
2131
+ else if (curr ().type () == lexeme::Keyword || curr ().type () == lexeme::Cpp2FixedType) {
2133
2132
n->pos = curr ().position ();
2134
2133
n->id = &curr ();
2135
2134
next ();
2136
2135
assert (n->id .index () == type_id_node::keyword);
2137
- return n;
2138
2136
}
2139
-
2140
- if (!n->pc_qualifiers .empty ()) {
2137
+ else {
2138
+ if (!n->pc_qualifiers .empty ()) {
2141
2139
error (" '*'/'const' type qualifiers must be followed by a type name or '_' wildcard" );
2140
+ }
2141
+ return {};
2142
2142
}
2143
- return {};
2143
+
2144
+ if (curr ().type () == lexeme::LeftBracket) {
2145
+ error (" C-style array types are not allowed, use std::array instead" );
2146
+ return {};
2147
+ }
2148
+ return n;
2144
2149
}
2145
2150
2146
2151
You can’t perform that action at this time.
0 commit comments