Topic: Enumerator name collision
Author: jgro@netcom.com (Jeremy Grodberg)
Date: Mon, 30 Aug 1993 21:30:31 GMT Raw View
I'm confused about the name space in which an enumerator's name is
placed. I though, from reading the ARM, that enumerators were
basically in the same name space as variables, and that this name
space was distinct from types, including typedefs. I also thought
that enumerators inside a class would hide, rather than conflict with,
whatever else had the same name outside the class. Thus, I thought
the following program fragment was completely legal:
typedef long Short;
typedef short Enum;
int Enum; // ARM 3.1c "A name s can be declared as a type *and* as
// a non-type in a single scope
class Class {
public:
enum Enum { Short }; // class scope hides outer scope
};
However, the CFront 3.0 based compilers choke on the above commented
lines. "int Enum" is rejected because variable name Enum conflicts
with type Enum. "enum Enum" is accepted, but the enumerator "Short"
is flagged as a syntax error.
Can anyone enlighten me as to what is "supposed" to happen, and
whether this is a compiler bug, as standards bug, or programmer error?
Thanks.
--
Jeremy Grodberg Committed to developing user-friendly products,
jgro@netcom.com Because technology is supposed to make life easier