[cfe-dev] forward declare enums

John McCall rjmccall at apple.com
Tue Jul 2 10:12:36 PDT 2013


On Jul 1, 2013, at 2:37 AM, Yingshen Yu <yingshen.yu at gmail.com> wrote:
> I'm working on an old codebase, it uses some (if not a lot) enum forward declarations like below.
> 
> struct MyStruct;
> enum MyStruct::MyEnum;
> 
> the enum definition is like 
> 
> struct MyStruct {
>     enum MyEnum { .... };
> };
> 
> The enum forward declaration seems working with the XCode4 and XCode5-DP, but it is reported as error when building with a trunk build of open source LLVM.
> 
> So should I understand Apple's Clang is more tolerate than the open sourced Clang? or It just because such checks are added recently and not available in Xcode 5?

Yes, Clang previously had a bug where we failed to diagnose invalid out-of-life declarations of enums like this, and that bug persists in the Xcode 5 DP.

However, we only accepted such declarations after the definition of the struct, so this forward-declaration is always useless.

John.



More information about the cfe-dev mailing list