qapi: Better error messages for duplicated expressions
authorEric Blake <eblake@redhat.com>
Mon, 4 May 2015 15:05:17 +0000 (09:05 -0600)
committerMarkus Armbruster <armbru@redhat.com>
Tue, 5 May 2015 16:39:01 +0000 (18:39 +0200)
commit4dc2e6906e1084fdd37bf67385c5dcd2c72ae22b
tree38dbff47247cefd2448c56813de8bed894096c92
parentcfdd5bcad515a8371af59dba9625e31a6f6f733e
qapi: Better error messages for duplicated expressions

The previous commit demonstrated that the generator overlooked
duplicate expressions:
- a complex type or command reusing a built-in type name
- redeclaration of a type name, whether by the same or different
metatype
- redeclaration of a command or event
- collision of a type with implicit 'Kind' enum for a union
- collision with an implicit MAX enum constant

Since the c_type() function in the generator treats all names
as being in the same namespace, this patch adds a global array
to track all known names and their source, to prevent collisions
before it can cause further problems.  While valid .json files
won't trigger any of these cases, we might as well be nicer to
developers that make a typo while trying to add new QAPI code.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
29 files changed:
scripts/qapi.py
tests/qapi-schema/command-int.err
tests/qapi-schema/command-int.exit
tests/qapi-schema/command-int.json
tests/qapi-schema/command-int.out
tests/qapi-schema/enum-union-clash.err
tests/qapi-schema/enum-union-clash.exit
tests/qapi-schema/enum-union-clash.json
tests/qapi-schema/enum-union-clash.out
tests/qapi-schema/event-max.err
tests/qapi-schema/event-max.exit
tests/qapi-schema/event-max.json
tests/qapi-schema/event-max.out
tests/qapi-schema/redefined-builtin.err
tests/qapi-schema/redefined-builtin.exit
tests/qapi-schema/redefined-builtin.json
tests/qapi-schema/redefined-builtin.out
tests/qapi-schema/redefined-command.err
tests/qapi-schema/redefined-command.exit
tests/qapi-schema/redefined-command.json
tests/qapi-schema/redefined-command.out
tests/qapi-schema/redefined-event.err
tests/qapi-schema/redefined-event.exit
tests/qapi-schema/redefined-event.json
tests/qapi-schema/redefined-event.out
tests/qapi-schema/redefined-type.err
tests/qapi-schema/redefined-type.exit
tests/qapi-schema/redefined-type.json
tests/qapi-schema/redefined-type.out