fix: primitive types are allowed in compound literal expressions

pull/708/head
Amaan Qureshi 2023-07-25 06:26:09 +07:00
parent 2c7aff437d
commit eba14809da
No known key found for this signature in database
GPG Key ID: E67890ADC4227273
2 changed files with 10 additions and 1 deletions

@ -1111,7 +1111,7 @@ module.exports = grammar(C, {
compound_literal_expression: ($, original) => choice( compound_literal_expression: ($, original) => choice(
original, original,
seq( seq(
field('type', $._class_name), field('type', choice($._class_name, $.primitive_type)),
field('value', $.initializer_list), field('value', $.initializer_list),
), ),
), ),

@ -32,6 +32,7 @@ Compound literals without parentheses
T x = T{0}; T x = T{0};
U<V> y = U<V>{0}; U<V> y = U<V>{0};
int x = int{1};
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -58,6 +59,14 @@ U<V> y = U<V>{0};
(template_argument_list (template_argument_list
(type_descriptor (type_descriptor
(type_identifier)))) (type_identifier))))
(initializer_list
(number_literal)))))
(declaration
(primitive_type)
(init_declarator
(identifier)
(compound_literal_expression
(primitive_type)
(initializer_list (initializer_list
(number_literal)))))) (number_literal))))))