| 246 | } |
| 247 | |
| 248 | void NameAndTypeResolver::warnHomonymDeclarations() const |
| 249 | { |
| 250 | DeclarationContainer::Homonyms homonyms; |
| 251 | m_scopes.at(nullptr)->populateHomonyms(back_inserter(homonyms)); |
| 252 | |
| 253 | for (auto [innerLocation, outerDeclarations]: homonyms) |
| 254 | { |
| 255 | solAssert(innerLocation && !outerDeclarations.empty(), ""); |
| 256 | |
| 257 | bool magicShadowed = false; |
| 258 | SecondarySourceLocation homonymousLocations; |
| 259 | SecondarySourceLocation shadowedLocations; |
| 260 | for (Declaration const* outerDeclaration: outerDeclarations) |
| 261 | { |
| 262 | solAssert(outerDeclaration, ""); |
| 263 | if (dynamic_cast<MagicVariableDeclaration const*>(outerDeclaration)) |
| 264 | magicShadowed = true; |
| 265 | else if (!outerDeclaration->isVisibleInContract()) |
| 266 | homonymousLocations.append("The other declaration is here:", outerDeclaration->location()); |
| 267 | else |
| 268 | shadowedLocations.append("The shadowed declaration is here:", outerDeclaration->location()); |
| 269 | } |
| 270 | |
| 271 | if (magicShadowed) |
| 272 | m_errorReporter.warning( |
| 273 | 2319_error, |
| 274 | *innerLocation, |
| 275 | "This declaration shadows a builtin symbol." |
| 276 | ); |
| 277 | if (!homonymousLocations.infos.empty()) |
| 278 | m_errorReporter.warning( |
| 279 | 8760_error, |
| 280 | *innerLocation, |
| 281 | "This declaration has the same name as another declaration.", |
| 282 | homonymousLocations |
| 283 | ); |
| 284 | if (!shadowedLocations.infos.empty()) |
| 285 | m_errorReporter.warning( |
| 286 | 2519_error, |
| 287 | *innerLocation, |
| 288 | "This declaration shadows an existing declaration.", |
| 289 | shadowedLocations |
| 290 | ); |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | void NameAndTypeResolver::setScope(ASTNode const* _node) |
| 295 | { |
no test coverage detected