Skip to content
  • Oliver Kellogg's avatar
    Support C++11 "enum class" in C++ Import: · 464c7132
    Oliver Kellogg authored
    lib/cppparser/ast.{h,cpp} class EnumSpecifierAST
    - Add functions setClass, isClass accessing new member m_isClass of type
      bool.
    - Add functions setEnumBase, enumBase accessing new member m_enumBase
      of type TypeSpecifierAST::Node.
    
    lib/cppparser/parser.cpp function parseEnumSpecifier
    - Add bool isClass initialized to false.
    - After consuming Token_enum add int tk initialized to
      m_lexer->lookAhead(0).
    - If tk is Token_class or Token_struct then set isClass true and call
      nextToken().
    - After call to parseName(name) add variable enumBase of type
      TypeSpecifierAST::Node.
    - If m_lexer->lookAhead(0) is ':' then call nextToken() followed by
      parseSimpleTypeSpecifier(enumBase).
    - Reassign tk from m_lexer->lookAhead(0) and permit only ';' or '{' as
      its value.
    - Remove call to nextToken(), it is postponed to after the assignments
      to `ast'.
    - At assignments to `ast' call ast->setClass(isClass) and
      ast->setEnumBase(enumBase).
    
    test/import/cxx/cxx11-strongly-typed-enumerations.h
    - Rename second definition of Enum2,Enum3 to Enum4,Enum5 to avoid
      overlap.
    
    CCBUG: 338649
    464c7132