Error Parsing Incomplete Enum Types

I’m running into an error parsing the source:

// Enum.cpp

namespace ns {

typedef enum _E E;

typedef struct _S S;

}

namespace ns {

typedef enum _E E;

typedef struct _S S;

}

// End Enum.cpp

CLang output:

enum.cpp(6,20) : error: typedef redefinition with different types (‘enum _E’ vs ‘enum _E’)

typedef enum _E E;

^

enum.cpp(2,20) : note: previous definition is here

typedef enum _E E;

^

I’m not a C++ “lawyer” so I’m not sure if this is a CLang issue, or a construct forbidden by the C++ standard? If this is in the standard, why does the same not apply to struct?

Thanks in advance.

-Uri Mann

This is ill-formed all by itself:

  typedef enum _E E;

... because enums can't be forward-declared like that. But apparently we
allow this in MS compatibility mode.

It seems that we only produce the error you reported if you run clang in MS
compatibility mode but with C++11 disabled, which is not likely to be a
well-tested setup.