If this is C++, create assign operators for volatile structs: Semantically this should work, though for bit fields it's probably not what was intended. volatile struct S0& operator=(const volatile struct S0& val) volatile { if (this == &val) { return *this; } f0 = val.f0; f1 = val.f1; return *this; } As a result of generating this, have to generate 'default' assignment operator as well
| 1754 | //} |
| 1755 | // As a result of generating this, have to generate 'default' assignment operator as well |
| 1756 | void OutputStructAssignOp(Type* type, std::ostream &out, bool vol) |
| 1757 | { |
| 1758 | if (CGOptions::lang_cpp()){ |
| 1759 | if (type->has_assign_ops() && (type->eType == eStruct)){ |
| 1760 | out << " "; |
| 1761 | if (vol){ |
| 1762 | out << "volatile "; |
| 1763 | } |
| 1764 | type->Output(out); out << "& operator=(const "; |
| 1765 | if (vol){ |
| 1766 | out << "volatile "; |
| 1767 | } |
| 1768 | type->Output(out); out << "& val) "; |
| 1769 | if (vol){ |
| 1770 | out << "volatile "; |
| 1771 | } |
| 1772 | out << "{"; really_outputln(out); |
| 1773 | out << " if (this == &val) {"; really_outputln(out); |
| 1774 | out << " return *this;"; really_outputln(out); |
| 1775 | out << " }"; really_outputln(out); |
| 1776 | // for all fields: |
| 1777 | for (size_t i = 0, j = 0; i<type->fields.size(); i++) { |
| 1778 | int length = type->bitfields_length_[i]; |
| 1779 | if (length != 0){ |
| 1780 | out << " "; |
| 1781 | out << " f" << j << "= val.f" << j << ";"; |
| 1782 | really_outputln(out); |
| 1783 | ++j; |
| 1784 | } |
| 1785 | } |
| 1786 | |
| 1787 | out << " return *this;"; really_outputln(out); |
| 1788 | out << " }"; really_outputln(out); |
| 1789 | } |
| 1790 | } |
| 1791 | } |
| 1792 | |
| 1793 | // To have volatile unions in C++ they need assignment operators: |
| 1794 | //union U1& operator=(const union U1& val){ |
no test coverage detected