[GCC-XML]typdef vs. tagged enums
John Waggenspack
jwag at celion.com
Wed, 31 Mar 2004 17:26:56 -0600
These enums:
enum tagged {
tagged0
};
typedef enum {
tdeffed0
} tdeffed;
Generate the following xml:
<?xml version=3D"1.0"?>
<GCC_XML>
<Namespace id=3D"_1" name=3D"::" members=3D"_3 _4 " =
mangled=3D"_Z2::"/>
<Namespace id=3D"_2" name=3D"std" context=3D"_1" members=3D"" =
mangled=3D"_Z3std"/>
<Enumeration id=3D"_3" name=3D"tdeffed" context=3D"_1" =
location=3D"f0:8" file=3D"f0" line=3D"8">
<EnumValue name=3D"tdeffed0" init=3D"0"/>
</Enumeration>
<Enumeration id=3D"_4" name=3D"tagged" context=3D"_1" =
location=3D"f0:2" file=3D"f0" line=3D"2">
<EnumValue name=3D"tagged0" init=3D"0"/>
</Enumeration>
<File id=3D"f0" name=3D"test.h"/>
</GCC_XML>
Note there is no difference in the XML output for the two different =
styles of enum specification.
However, gcc 2.95 expect functions that use these enums to have =
different signatures. =20
This compiles without errors:
#include "test.h"
extern void foo();
enum tagged returnTagged()
{
return(tagged0);
}
tdeffed returnTdeffed()
{
return(tdeffed0);
}
void useTagged(enum tagged e)
{
if (e =3D=3D tagged0)
foo();
}
void useTDeffed(tdeffed e)
{
if (e =3D=3D tdeffed0)
foo();
}
This has errors:
#include "test.h"
extern void foo();
tagged returnTagged()
{
return(tagged0);
}
enum tdeffed returnTdeffed()
{
return(tdeffed0);
}
void useTagged(tagged e)
{
if (e =3D=3D tagged0)
foo();
}
void useTDeffed(enum tdeffed e)
{
if (e =3D=3D tdeffed0)
foo();
}
gcc -c test_ERRORS.c
test_ERRORS.c:5: syntax error before `returnTagged'
test_ERRORS.c:11: return-type is an incomplete type
test_ERRORS.c: In function `returnTdeffed':
test_ERRORS.c:12: warning: `return' with a value, in function =
returning void
test_ERRORS.c: At top level:
test_ERRORS.c:15: syntax error before `e'
test_ERRORS.c: In function `useTagged':
test_ERRORS.c:17: `e' undeclared (first use in this function)
test_ERRORS.c:17: (Each undeclared identifier is reported only once
test_ERRORS.c:17: for each function it appears in.)
test_ERRORS.c: At top level:
test_ERRORS.c:22: parameter `e' has incomplete type
Is there anyway to have the generated XML indicate if an enum is
typedefed?
Thanks,
jwag