[cfe-dev] AST: scoped enums with and without type qualifier

don hinton via cfe-dev cfe-dev at lists.llvm.org
Sun Oct 9 11:07:35 PDT 2016


You need to tell the compiler to use at least c++11 by adding -std=c++11.

hth...
don

On Sunday, October 9, 2016, Ivan Kush via cfe-dev <cfe-dev at lists.llvm.org>
wrote:

> Hello!
> I wanted to see the AST of scoped enums. The file test.cc containt only
> enum definition, nothing else.
>
>
> clang -Xclang -ast-dump -fsyntax-only test.cc
>
>
> clang output an error, when i specified a type and no error without type
> specification. Is it normal?
>
>
> *With type qualifier an error*
>
> enum class Foo *: int *{
>     kOne,
>     kTwo
> };
>
>
>
>
> *test.cc:1:6: **warning: **scoped enumerations are a C++11 extension
> [-Wc++11-extensions]*
> enum class Foo : int {
> *    ^*
> *test.cc:1:12: **error: **ISO C++ forbids forward references to 'enum'
> types*
>
> enum class Foo : int {
> *          ^*
> *test.cc:1:16: **error: **expected unqualified-id*
>
>
> enum class Foo : int {
> *              ^*
> *TranslationUnitDecl* 0x238a3f0 <<invalid sloc>> <invalid sloc>
>
>
> |-*TypedefDecl* 0x238a928 <<invalid sloc>> <invalid sloc> implicit*
> __int128_t* '__int128'
> | `-BuiltinType 0x238a640 '__int128'
> |-*TypedefDecl* 0x238a988 <<invalid sloc>> <invalid sloc> implicit*
> __uint128_t* 'unsigned __int128'
> | `-BuiltinType 0x238a660 'unsigned __int128'
> |-*TypedefDecl* 0x238aa18 <<invalid sloc>> <invalid sloc> implicit*
> __builtin_ms_va_list* 'char *'
> | `-PointerType 0x238a9e0 'char *'
> |   `-BuiltinType 0x238a480 'char'
> `-*TypedefDecl* 0x238ad38 <<invalid sloc>> <invalid sloc> implicit*
> __builtin_va_list* 'struct __va_list_tag [1]'
>  `-ConstantArrayType 0x238ace0 'struct __va_list_tag [1]' 1
>    `-RecordType 0x238ab00 'struct __va_list_tag'
>      `-*CXXRecord* 0x238aa68* '__va_list_tag'*
> 1 warning and 2 errors generated.
>
>
> *Without type qualifier*
>
> enum class Foo {
>     kOne,
>     kTwo
> };
>
>
> *test.cc:1:6: **warning: **scoped enumerations are a C++11 extension
> [-Wc++11-extensions]*
> enum class Foo {
> *    ^*
> *TranslationUnitDecl* 0x346c3b0 <<invalid sloc>> <invalid sloc>
>
>
> |-*TypedefDecl* 0x346c8e8 <<invalid sloc>> <invalid sloc> implicit*
> __int128_t* '__int128'
> | `-BuiltinType 0x346c600 '__int128'
> |-*TypedefDecl* 0x346c948 <<invalid sloc>> <invalid sloc> implicit*
> __uint128_t* 'unsigned __int128'
> | `-BuiltinType 0x346c620 'unsigned __int128'
> |-*TypedefDecl* 0x346c9d8 <<invalid sloc>> <invalid sloc> implicit*
> __builtin_ms_va_list* 'char *'
> | `-PointerType 0x346c9a0 'char *'
> |   `-BuiltinType 0x346c440 'char'
> |-*TypedefDecl* 0x346ccf8 <<invalid sloc>> <invalid sloc> implicit*
> __builtin_va_list* 'struct __va_list_tag [1]'
> | `-ConstantArrayType 0x346cca0 'struct __va_list_tag [1]' 1
> |   `-RecordType 0x346cac0 'struct __va_list_tag'
> |     `-*CXXRecord* 0x346ca28* '__va_list_tag'*
> `-*EnumDecl* 0x346cd48 <test.cc:1:1, line:4:1> line:1:12 class* Foo* 'int'
>  |-*EnumConstantDecl* 0x346ce00 <line:2:5> col:5* kOne* 'enum Foo'
>  `-*EnumConstantDecl* 0x346ce50 <line:3:5> col:5* kTwo* 'enum Foo'
> 1 warning generated.
>
>
>
>
>
>
>
>
>
>
> --
> Best wishes,
> Ivan Kush
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161009/d2e14033/attachment.html>


More information about the cfe-dev mailing list