flatc should output a warning, when an attribute is attached more than once (#6146)

* Added missing EndTable() call to VerifyObject()

VerifyObject called VerifyTableStart() but not EndTable(). This made Verifier::VerifyComplexity() increase depth_ with each table, not with the depth of tables.

https://groups.google.com/forum/#!topic/flatbuffers/OpxtW5UFAdg

* Added Check to VerifyAlignment

https://stackoverflow.com/questions/59376308/flatbuffers-verifier-returns-false-without-any-assertion-flatbuffers-debug-veri

* Add GetStringView (Convenience function to get string_view from a String returning an empty string_view on null pointer) like GetString, GetCstring

* flatc should warn, when an attribute is attached more than once.

flatc.exe -b duplicate.fbs
warning: duplicate.fbs(5, 36): warning: attribute already found: priority

duplicate.fbs:

namespace MyGame;

attribute "priority";

table Monster (priority:1, priority:2) {
}

root_type Monster;
This commit is contained in:
Stefan F 2020-09-28 18:28:47 +02:00 committed by GitHub
parent 689bfafa7e
commit ab01ae1620
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -1559,7 +1559,7 @@ CheckedError Parser::ParseMetaData(SymbolTable<Value> *attributes) {
name); name);
NEXT(); NEXT();
auto e = new Value(); auto e = new Value();
attributes->Add(name, e); if (attributes->Add(name, e)) Warning("attribute already found: " + name);
if (Is(':')) { if (Is(':')) {
NEXT(); NEXT();
ECHECK(ParseSingleValue(&name, *e, true)); ECHECK(ParseSingleValue(&name, *e, true));