Loop attributes
| 225 | // Loop attributes |
| 226 | // |
| 227 | void TParseContext::handleLoopAttributes(const TAttributes& attributes, TIntermNode* node) |
| 228 | { |
| 229 | TIntermLoop* loop = node->getAsLoopNode(); |
| 230 | if (loop == nullptr) { |
| 231 | // the actual loop might be part of a sequence |
| 232 | TIntermAggregate* agg = node->getAsAggregate(); |
| 233 | if (agg == nullptr) |
| 234 | return; |
| 235 | for (auto it = agg->getSequence().begin(); it != agg->getSequence().end(); ++it) { |
| 236 | loop = (*it)->getAsLoopNode(); |
| 237 | if (loop != nullptr) |
| 238 | break; |
| 239 | } |
| 240 | if (loop == nullptr) |
| 241 | return; |
| 242 | } |
| 243 | |
| 244 | for (auto it = attributes.begin(); it != attributes.end(); ++it) { |
| 245 | |
| 246 | const auto noArgument = [&](const char* feature) { |
| 247 | if (it->size() > 0) { |
| 248 | warn(node->getLoc(), "expected no arguments", feature, ""); |
| 249 | return false; |
| 250 | } |
| 251 | return true; |
| 252 | }; |
| 253 | |
| 254 | const auto positiveSignedArgument = [&](const char* feature, int& value) { |
| 255 | if (it->size() == 1 && it->getInt(value)) { |
| 256 | if (value <= 0) { |
| 257 | error(node->getLoc(), "must be positive", feature, ""); |
| 258 | return false; |
| 259 | } |
| 260 | } else { |
| 261 | warn(node->getLoc(), "expected a single integer argument", feature, ""); |
| 262 | return false; |
| 263 | } |
| 264 | return true; |
| 265 | }; |
| 266 | |
| 267 | const auto unsignedArgument = [&](const char* feature, unsigned int& uiValue) { |
| 268 | int value; |
| 269 | if (!(it->size() == 1 && it->getInt(value))) { |
| 270 | warn(node->getLoc(), "expected a single integer argument", feature, ""); |
| 271 | return false; |
| 272 | } |
| 273 | uiValue = (unsigned int)value; |
| 274 | return true; |
| 275 | }; |
| 276 | |
| 277 | const auto positiveUnsignedArgument = [&](const char* feature, unsigned int& uiValue) { |
| 278 | int value; |
| 279 | if (it->size() == 1 && it->getInt(value)) { |
| 280 | if (value == 0) { |
| 281 | error(node->getLoc(), "must be greater than or equal to 1", feature, ""); |
| 282 | return false; |
| 283 | } |
| 284 | } else { |
no test coverage detected