This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: (gcc 2.95 NT4 SP6) function declaration with enum argument
> Do you mean that
>
> enum TLanguage;
>
> is invalid? I don't think so.
He means exactly that. There is no point in arguing against the
language definition.
> > an extension, try with -pedantic.
>
> I don't see why an extension should be needed for my code to compile. It
> seems just straight C++ to me.
Well, it may seem straight C++ to you, but it certainly is not
standard C++. 7.2 ([dcl.enum]) defines enumerations as
enumname:
identifier
enumspecifier:
enum identifier-opt { enumeratorlist-opt }
enumeratorlist:
enumeratordefinition
enumeratorlist , enumeratordefinition
enumeratordefinition:
enumerator
enumerator = constantexpression
enumerator:
identifier
so there is no option to leave out the curly brackets.
You could think that 'enum foo' should be an elaborated-type-specifier
(it is), but 3.4.4, [basic.lookup.elab]/2 says
# If the elaboratedtypespecifier refers to an enumname and this
# lookup does not find a previously declared enumname, the
# elaboratedtypespecifier is illformed.
So you can use 'enum foo;' only if you had foo declared previously.
If you question this line of reasoning, please discuss it in one of
the public C++ fora first, eg. comp.lang.c++.moderated, or
comp.std.c++.
Regards,
Martin