https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98030

            Bug ID: 98030
           Summary: error message for enum definition without ';' could be
                    improved
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tangyixuan at mail dot dlut.edu.cn
  Target Milestone: ---

Hi, the following code misses a ';' at the end of the enum definition. GCC
reports an error with 'new types may not be defined', which may not be easily
understood by novices, while clang suggests the additional ';' could be better.

$ cat s.cpp
enum E {
   e = 3,
}                   //miss a ';' here
int main() {
  bool var1 = e;
  bool var2 = 3;
}

$ g++ -c s.cpp
s.cpp:1:1: error: new types may not be defined in a return type
    1 | enum E {
      | ^~~~
s.cpp:1:1: note: (perhaps a semicolon is missing after the definition of ‘E’)
s.cpp:1:1: error: two or more data types in declaration of ‘main’


$ clang++ -c s.cpp
s.cpp:3:2: error: expected ';' after enum
}
 ^
 ;
1 error generated.


$ g++ -v
Using built-in specs.
COLLECT_GCC=/usr/local/gcc-20201122/bin/g++
COLLECT_LTO_WRAPPER=/usr/local/gcc-20201122/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-11-20201122/configure --prefix=/usr/local/gcc-20201122
--enable-checking=release --enable-languages=c,c++ --disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20201122 (experimental) (GCC)

Reply via email to