Menu

#401 C++ enum forward-declaration breaks following indentation

closed-fixed
None
2017-01-14
2016-06-17
No

Artistic Style Version 2.05.1

Example input (astyle --style=attach test.cpp):

class TestClass : public ParentClass {
protected:
    enum class Registers : uint16_t;
public:
    void testFunction();
}

Expected output: no change
Actual output:

class TestClass : public ParentClass {
protected:
    enum class Registers : uint16_t;
    public:
        void testFunction();
    }

The problem appears to be associated with expecting braces, as placing braces after the enum seems to "fix" it:

class TestClass : public ParentClass {
protected:
    enum class Registers : uint16_t;
    {}
public:
    void testFunction();
}

Discussion

  • w-peuker

    w-peuker - 2016-06-19

    I'm not sure if this is possible to change now, the title should be better changed into "C++ enum class forward-declaration breaks following indentation"

     
    • Erich Edgar Hoover

      The same thing happens with "normal" enums, example:

      class TestClass : public ParentClass {
      protected:
          enum Registers : uint16_t;
      public:
          void testFunction();
      }
      

      output:

      class TestClass : public ParentClass {
      protected:
          enum Registers : uint16_t;
          public:
              void testFunction();
          }
      
       
  • Jim Pattee

    Jim Pattee - 2016-11-19
    • status: open --> open-fixed
    • assigned_to: Jim Pattee
    • Priority: 5 --> 7
     
  • Jim Pattee

    Jim Pattee - 2016-11-19

    Fixed.

     
  • Erich Edgar Hoover

    Awesome, thank you so much!

     
  • Jim Pattee

    Jim Pattee - 2017-01-14
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.