This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/45331] New: Generate clear diagnostics when a semicolon is missing at the end of a class definition


Consider this sample code:

# cat tst.cc
class X
{
public:
 int a;
}

int foo(const X &x)
{
 return x.a;
}


The clang front end generates a very nice warning (which is actually color
coded for ease of readability):

# clang ./tst.cc
./tst.cc:5:2: error: expected ';' after class
}
 ^
 ;
1 diagnostic generated.


By comparison, this is what gcc generates (in both Crosstool v14 and the
current upstream trunk):

# ./install/bin/gcc -c tst.cc
tst.cc:1:1: error: new types may not be defined in a return type
tst.cc:1:1: note: (perhaps a semicolon is missing after the definition of ?X?)
tst.cc:7:19: error: two or more data types in declaration of ?foo?

True, it *does* mention that there is likely a missing semicolon, but does it
really need to mention the other cruft, too?  Why not just emit an error about
the semicolon, add the missing semicolon to the input stream, and continue
parsing the file?


-- 
           Summary: Generate clear diagnostics when a semicolon is missing
                    at the end of a class definition
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: aaw at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45331


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]