You need to tell the compiler to use at least c++11 by adding -std=c++11.<div><br></div><div>hth...</div><div>don<span></span><br><div><br>On Sunday, October 9, 2016, Ivan Kush via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>Hello!</div><div>I wanted to see the AST of scoped enums. The file test.cc containt only enum definition, nothing else.</div><div> </div><blockquote><div><span style="font-family:monospace"><span style="background-color:#ffffff;color:#000000">clang -Xclang -ast-dump -fsyntax-only test.cc</span></span></div></blockquote><div> </div><div>clang output an error, when i specified a type and no error without type specification. Is it normal?</div><div> </div><div> </div><div><div><strong>With type qualifier an error</strong></div><div> </div><div><div>enum class Foo <strong>: int </strong>{</div><div>    kOne,</div><div>    kTwo</div><div>};</div><div> </div><div><blockquote><div> </div></blockquote><blockquote><p><span style="font-family:monospace"><strong style="background-color:#ffffff;color:#000000;font-weight:bold">test.cc:1:6: </strong><strong style="background-color:#ffffff;color:#ff54ff;font-weight:bold">warning: </strong><strong style="background-color:#ffffff;color:#000000;font-weight:bold">scoped enumerations are a C++11 extension [-Wc++11-extensions]</strong><span style="background-color:#ffffff;color:#000000"> </span><br>enum class Foo : int {<br><strong style="background-color:#ffffff;color:#54ff54;font-weight:bold">    ^</strong><span style="background-color:#ffffff;color:#000000"> </span><br><strong style="background-color:#ffffff;color:#000000;font-weight:bold">test.cc:1:12: </strong><strong style="background-color:#ffffff;color:#ff5454;font-weight:bold">error: </strong><strong style="background-color:#ffffff;color:#000000;font-weight:bold">ISO C++ forbids forward references to 'enum' types</strong><span style="background-color:#ffffff;color:#18b218">                               <wbr>                              <wbr>                              <wbr>        </span><span style="background-color:#ffffff;color:#000000"> </span><br>enum class Foo : int {<br><strong style="background-color:#ffffff;color:#54ff54;font-weight:bold">          ^</strong><span style="background-color:#ffffff;color:#000000"> </span><br><strong style="background-color:#ffffff;color:#000000;font-weight:bold">test.cc:1:16: </strong><strong style="background-color:#ffffff;color:#ff5454;font-weight:bold">error: </strong><strong style="background-color:#ffffff;color:#000000;font-weight:bold">expected unqualified-id</strong><span style="background-color:#ffffff;color:#18b218">                               <wbr>                              <wbr>                              <wbr>                              <wbr>     </span><span style="background-color:#ffffff;color:#000000"> </span><br>enum class Foo : int {<br><strong style="background-color:#ffffff;color:#54ff54;font-weight:bold">              ^</strong><span style="background-color:#ffffff;color:#000000"> </span><br><strong style="background-color:#ffffff;color:#54ff54;font-weight:bold">TranslationUnitDecl</strong><span style="background-color:#ffffff;color:#b26818"> 0x238a3f0</span><span style="background-color:#ffffff;color:#000000"> <</span><span style="background-color:#ffffff;color:#b26818"><invalid sloc></span><span style="background-color:#ffffff;color:#000000">> </span><span style="background-color:#ffffff;color:#b26818"><invalid sloc></span><span style="background-color:#ffffff;color:#18b218">                               <wbr>                              <wbr>                              <wbr>                  </span><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2">|-</span><strong style="background-color:#ffffff;color:#54ff54;font-weight:bold">TypedefDecl</strong><span style="background-color:#ffffff;color:#b26818"> 0x238a928</span><span style="background-color:#ffffff;color:#000000"> <</span><span style="background-color:#ffffff;color:#b26818"><invalid sloc></span><span style="background-color:#ffffff;color:#000000">> </span><span style="background-color:#ffffff;color:#b26818"><invalid sloc></span><span style="background-color:#ffffff;color:#000000"> implicit</span><strong style="background-color:#ffffff;color:#54ffff;font-weight:bold"> __int128_t</strong><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'__int128'</span><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2">| `-</span><span style="background-color:#ffffff;color:#18b218">BuiltinType</span><span style="background-color:#ffffff;color:#b26818"> 0x238a640</span><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'__int128'</span><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2">|-</span><strong style="background-color:#ffffff;color:#54ff54;font-weight:bold">TypedefDecl</strong><span style="background-color:#ffffff;color:#b26818"> 0x238a988</span><span style="background-color:#ffffff;color:#000000"> <</span><span style="background-color:#ffffff;color:#b26818"><invalid sloc></span><span style="background-color:#ffffff;color:#000000">> </span><span style="background-color:#ffffff;color:#b26818"><invalid sloc></span><span style="background-color:#ffffff;color:#000000"> implicit</span><strong style="background-color:#ffffff;color:#54ffff;font-weight:bold"> __uint128_t</strong><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'unsigned __int128'</span><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2">| `-</span><span style="background-color:#ffffff;color:#18b218">BuiltinType</span><span style="background-color:#ffffff;color:#b26818"> 0x238a660</span><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'unsigned __int128'</span><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2">|-</span><strong style="background-color:#ffffff;color:#54ff54;font-weight:bold">TypedefDecl</strong><span style="background-color:#ffffff;color:#b26818"> 0x238aa18</span><span style="background-color:#ffffff;color:#000000"> <</span><span style="background-color:#ffffff;color:#b26818"><invalid sloc></span><span style="background-color:#ffffff;color:#000000">> </span><span style="background-color:#ffffff;color:#b26818"><invalid sloc></span><span style="background-color:#ffffff;color:#000000"> implicit</span><strong style="background-color:#ffffff;color:#54ffff;font-weight:bold"> __builtin_ms_va_list</strong><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'char *'</span><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2">| `-</span><span style="background-color:#ffffff;color:#18b218">PointerType</span><span style="background-color:#ffffff;color:#b26818"> 0x238a9e0</span><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'char *'</span><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2">|   `-</span><span style="background-color:#ffffff;color:#18b218">BuiltinType</span><span style="background-color:#ffffff;color:#b26818"> 0x238a480</span><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'char'</span><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2">`-</span><strong style="background-color:#ffffff;color:#54ff54;font-weight:bold">TypedefDecl</strong><span style="background-color:#ffffff;color:#b26818"> 0x238ad38</span><span style="background-color:#ffffff;color:#000000"> <</span><span style="background-color:#ffffff;color:#b26818"><invalid sloc></span><span style="background-color:#ffffff;color:#000000">> </span><span style="background-color:#ffffff;color:#b26818"><invalid sloc></span><span style="background-color:#ffffff;color:#000000"> implicit</span><strong style="background-color:#ffffff;color:#54ffff;font-weight:bold"> __builtin_va_list</strong><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'struct __va_list_tag [1]'</span><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2"> `-</span><span style="background-color:#ffffff;color:#18b218">ConstantArrayType</span><span style="background-color:#ffffff;color:#b26818"> 0x238ace0</span><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'struct __va_list_tag [1]'</span><span style="background-color:#ffffff;color:#000000"> 1  </span><br><span style="background-color:#ffffff;color:#1818b2">   `-</span><span style="background-color:#ffffff;color:#18b218">RecordType</span><span style="background-color:#ffffff;color:#b26818"> 0x238ab00</span><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'struct __va_list_tag'</span><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2">     `-</span><strong style="background-color:#ffffff;color:#54ff54;font-weight:bold">CXXRecord</strong><span style="background-color:#ffffff;color:#b26818"> 0x238aa68</span><strong style="background-color:#ffffff;color:#54ffff;font-weight:bold"> '__va_list_tag'</strong><span style="background-color:#ffffff;color:#000000"> </span><br>1 warning and 2 errors generated.</span></p></blockquote></div></div></div></div><div> </div><div><div><strong>Without type qualifier</strong><br> </div><div>enum class Foo {</div><div>    kOne,</div><div>    kTwo</div><div>};</div><div> </div><blockquote><div><span style="font-family:monospace"><strong style="background-color:#ffffff;color:#000000;font-weight:bold">test.cc:1:6: </strong><strong style="background-color:#ffffff;color:#ff54ff;font-weight:bold">warning: </strong><strong style="background-color:#ffffff;color:#000000;font-weight:bold">scoped enumerations are a C++11 extension [-Wc++11-extensions]</strong><span style="background-color:#ffffff;color:#000000"> </span><br>enum class Foo {<br><strong style="background-color:#ffffff;color:#54ff54;font-weight:bold">    ^</strong><span style="background-color:#ffffff;color:#000000"> </span><br><strong style="background-color:#ffffff;color:#54ff54;font-weight:bold">TranslationUnitDecl</strong><span style="background-color:#ffffff;color:#b26818"> 0x346c3b0</span><span style="background-color:#ffffff;color:#000000"> <</span><span style="background-color:#ffffff;color:#b26818"><invalid sloc></span><span style="background-color:#ffffff;color:#000000">> </span><span style="background-color:#ffffff;color:#b26818"><invalid sloc></span><span style="background-color:#ffffff;color:#18b218">                               <wbr>                              <wbr>                              <wbr>                  </span><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2">|-</span><strong style="background-color:#ffffff;color:#54ff54;font-weight:bold">TypedefDecl</strong><span style="background-color:#ffffff;color:#b26818"> 0x346c8e8</span><span style="background-color:#ffffff;color:#000000"> <</span><span style="background-color:#ffffff;color:#b26818"><invalid sloc></span><span style="background-color:#ffffff;color:#000000">> </span><span style="background-color:#ffffff;color:#b26818"><invalid sloc></span><span style="background-color:#ffffff;color:#000000"> implicit</span><strong style="background-color:#ffffff;color:#54ffff;font-weight:bold"> __int128_t</strong><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'__int128'</span><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2">| `-</span><span style="background-color:#ffffff;color:#18b218">BuiltinType</span><span style="background-color:#ffffff;color:#b26818"> 0x346c600</span><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'__int128'</span><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2">|-</span><strong style="background-color:#ffffff;color:#54ff54;font-weight:bold">TypedefDecl</strong><span style="background-color:#ffffff;color:#b26818"> 0x346c948</span><span style="background-color:#ffffff;color:#000000"> <</span><span style="background-color:#ffffff;color:#b26818"><invalid sloc></span><span style="background-color:#ffffff;color:#000000">> </span><span style="background-color:#ffffff;color:#b26818"><invalid sloc></span><span style="background-color:#ffffff;color:#000000"> implicit</span><strong style="background-color:#ffffff;color:#54ffff;font-weight:bold"> __uint128_t</strong><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'unsigned __int128'</span><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2">| `-</span><span style="background-color:#ffffff;color:#18b218">BuiltinType</span><span style="background-color:#ffffff;color:#b26818"> 0x346c620</span><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'unsigned __int128'</span><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2">|-</span><strong style="background-color:#ffffff;color:#54ff54;font-weight:bold">TypedefDecl</strong><span style="background-color:#ffffff;color:#b26818"> 0x346c9d8</span><span style="background-color:#ffffff;color:#000000"> <</span><span style="background-color:#ffffff;color:#b26818"><invalid sloc></span><span style="background-color:#ffffff;color:#000000">> </span><span style="background-color:#ffffff;color:#b26818"><invalid sloc></span><span style="background-color:#ffffff;color:#000000"> implicit</span><strong style="background-color:#ffffff;color:#54ffff;font-weight:bold"> __builtin_ms_va_list</strong><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'char *'</span><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2">| `-</span><span style="background-color:#ffffff;color:#18b218">PointerType</span><span style="background-color:#ffffff;color:#b26818"> 0x346c9a0</span><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'char *'</span><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2">|   `-</span><span style="background-color:#ffffff;color:#18b218">BuiltinType</span><span style="background-color:#ffffff;color:#b26818"> 0x346c440</span><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'char'</span><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2">|-</span><strong style="background-color:#ffffff;color:#54ff54;font-weight:bold">TypedefDecl</strong><span style="background-color:#ffffff;color:#b26818"> 0x346ccf8</span><span style="background-color:#ffffff;color:#000000"> <</span><span style="background-color:#ffffff;color:#b26818"><invalid sloc></span><span style="background-color:#ffffff;color:#000000">> </span><span style="background-color:#ffffff;color:#b26818"><invalid sloc></span><span style="background-color:#ffffff;color:#000000"> implicit</span><strong style="background-color:#ffffff;color:#54ffff;font-weight:bold"> __builtin_va_list</strong><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'struct __va_list_tag [1]'</span><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2">| `-</span><span style="background-color:#ffffff;color:#18b218">ConstantArrayType</span><span style="background-color:#ffffff;color:#b26818"> 0x346cca0</span><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'struct __va_list_tag [1]'</span><span style="background-color:#ffffff;color:#000000"> 1  </span><br><span style="background-color:#ffffff;color:#1818b2">|   `-</span><span style="background-color:#ffffff;color:#18b218">RecordType</span><span style="background-color:#ffffff;color:#b26818"> 0x346cac0</span><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'struct __va_list_tag'</span><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2">|     `-</span><strong style="background-color:#ffffff;color:#54ff54;font-weight:bold">CXXRecord</strong><span style="background-color:#ffffff;color:#b26818"> 0x346ca28</span><strong style="background-color:#ffffff;color:#54ffff;font-weight:bold"> '__va_list_tag'</strong><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2">`-</span><strong style="background-color:#ffffff;color:#54ff54;font-weight:bold">EnumDecl</strong><span style="background-color:#ffffff;color:#b26818"> 0x346cd48</span><span style="background-color:#ffffff;color:#000000"> <</span><span style="background-color:#ffffff;color:#b26818">test.cc:1:1</span><span style="background-color:#ffffff;color:#000000">, </span><span style="background-color:#ffffff;color:#b26818">line:4:1</span><span style="background-color:#ffffff;color:#000000">> </span><span style="background-color:#ffffff;color:#b26818">line:1:12</span><span style="background-color:#ffffff;color:#000000"> class</span><strong style="background-color:#ffffff;color:#54ffff;font-weight:bold"> Foo</strong><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'int'</span><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2"> |-</span><strong style="background-color:#ffffff;color:#54ff54;font-weight:bold">EnumConstantDecl</strong><span style="background-color:#ffffff;color:#b26818"> 0x346ce00</span><span style="background-color:#ffffff;color:#000000"> <</span><span style="background-color:#ffffff;color:#b26818">line:2:5</span><span style="background-color:#ffffff;color:#000000">> </span><span style="background-color:#ffffff;color:#b26818">col:5</span><strong style="background-color:#ffffff;color:#54ffff;font-weight:bold"> kOne</strong><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'enum Foo'</span><span style="background-color:#ffffff;color:#000000"> </span><br><span style="background-color:#ffffff;color:#1818b2"> `-</span><strong style="background-color:#ffffff;color:#54ff54;font-weight:bold">EnumConstantDecl</strong><span style="background-color:#ffffff;color:#b26818"> 0x346ce50</span><span style="background-color:#ffffff;color:#000000"> <</span><span style="background-color:#ffffff;color:#b26818">line:3:5</span><span style="background-color:#ffffff;color:#000000">> </span><span style="background-color:#ffffff;color:#b26818">col:5</span><strong style="background-color:#ffffff;color:#54ffff;font-weight:bold"> kTwo</strong><span style="background-color:#ffffff;color:#000000"> </span><span style="background-color:#ffffff;color:#18b218">'enum Foo'</span><span style="background-color:#ffffff;color:#000000"> </span><br>1 warning generated.</span><br><br> </div></blockquote><div> <div><blockquote><p> </p></blockquote><blockquote><div> </div></blockquote></div></div></div><div> </div><div>-- <br>Best wishes,</div><div>Ivan Kush</div><div> </div></blockquote></div></div>