(gcc 2.95 NT4 SP6) function declaration with enum argument
Martin v. Loewis
martin@loewis.home.cs.tu-berlin.de
Sun Mar 5 04:22:00 GMT 2000
> 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
enumÃÂname:
identifier
enumÃÂspecifier:
enum identifier-opt { enumeratorÃÂlist-opt }
enumeratorÃÂlist:
enumeratorÃÂdefinition
enumeratorÃÂlist , enumeratorÃÂdefinition
enumeratorÃÂdefinition:
enumerator
enumerator = constantÃÂexpression
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 elaboratedÃÂtypeÃÂspecifier refers to an enumÃÂname and this
# lookup does not find a previously declared enumÃÂname, the
# elaboratedÃÂtypeÃÂspecifier is illÃÂformed.
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
More information about the Gcc-bugs
mailing list