A function definition that starts with the in C++ superflous enum
before the enum name makes AStyle malformatting the function body. This seems a little problem because the enum can easily be deleted, but it was rather hard to detect the enum itself as the cause of the evil.
Since Astyle also formats C code, it should cope with these enums.
Here the example that made me wonder, because I first suspected the nested switch being the problem:
enum XYZ { X, Y, Z }; enum XYZ AStyle_2_05_1_fail( int a, int b ) { switch( a ) { case 0: { return X; } case 1: switch( b ) { case 1: return X; default: return Y; } case 2: return Y; } return Z; }
Astyle formatted like this:
enum XYZ { X, Y, Z }; enum XYZ AStyle_2_05_1_fail( int a, int b ) { switch( a ) { case 0: { return X; } case 1: switch( b ) { case 1: return X; default: return Y; } case 2: return Y; } return Z; }
The command line I used was
astyle --keep-one-line-blocks --keep-one-line-statements --formatted -v test.cpp
I attached the file
test.cpp
I used for testing