[cfe-dev] Error Parsing Incomplete Enum Types

Richard Smith richard at metafoo.co.uk
Fri May 16 11:49:05 PDT 2014


On Fri, May 16, 2014 at 10:31 AM, Uri Mann <umann at symantec.com> wrote:

> 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?
>

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140516/71060977/attachment.html>


More information about the cfe-dev mailing list