File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -6621,23 +6621,31 @@ void Parser::parse_enumerator_list(List<EnumeratorAST*>*& yyast,
66216621 parse_enumerator (enumerator, type);
66226622
66236623 if (!enumerator->expression ) {
6624+ // no explicit value given, so we need to increment the last value
6625+
66246626 if (lastValue.has_value ()) {
6627+ // we have a last value, so we can increment it
66256628 if (control_->is_unsigned (type)) {
6629+ // increment the last value as unsigned
66266630 if (auto v = interp.toUInt (lastValue.value ())) {
66276631 lastValue = v.value () + 1 ;
66286632 } else {
66296633 lastValue = std::nullopt ;
66306634 }
66316635 } else {
6636+ // increment the last value as signed
66326637 if (auto v = interp.toInt (lastValue.value ())) {
66336638 lastValue = v.value () + 1 ;
66346639 } else {
66356640 lastValue = std::nullopt ;
66366641 }
66376642 }
6643+
6644+ // set the value of the enumerator symbol
6645+ enumerator->symbol ->setValue (*lastValue);
66386646 }
6639- enumerator->symbol ->setValue (*lastValue);
66406647 } else {
6648+ // refresh the last value from the enumerator expression
66416649 lastValue = enumerator->symbol ->value ();
66426650 }
66436651
You can’t perform that action at this time.
0 commit comments