Re: Semicolons at the end of member function definitions
On Wed, 1 Aug 2007, Mark Mitchell wrote: | Volker Reichelt wrote: | | 2007-03-26 Dirk Mueller [EMAIL PROTECTED] | | * parser.c (cp_parser_member_declaration): Pedwarn | about stray semicolons after member declarations. | | | It makes | |struct A |{ | void foo() {}; |} | | That is indeed still legal in the current working draft. (The reason | that I copied the grammar productions above the parser functions was so | that it would be easy to check things like this...) | | Therefore, IMHO the patch is wrong and should be reverted. | | Yes, please go ahead and revert it. And, if you have time, please add a | test-case specifically for this case. The previous patch removed | semicolons from lots of valid code, but probably none of those test | cases were specifically for this case. I agree with Mark. Sorry for the confusion. -- Gaby
Re: Semicolons at the end of member function definitions
On Tuesday, 31. July 2007, Volker Reichelt wrote: Therefore, IMHO the patch is wrong and should be reverted. Or am I missing something? I don't have access to a newer version of the language standard either. I couldn't find a different case that is comparable to this one either (for example, we handle the difference between an enumerator list with a trailing ',' and a initializer list with a trailing ',' - although that is equally counter-intuitive). So, assuming that this hasn't changed in a newer standard then I guess you're right and the check should only be a warning with -pedantic, (and no -pedantic-errors) given. This is however not implementable currently. As I don't know why -pedantic-errors is on by default for C++ (but not for C), the only possibility I see is indeed to revert this patch and add a comment/testcase. Greetings, Dirk
Re: Semicolons at the end of member function definitions
On 01/08/07, Dirk Mueller [EMAIL PROTECTED] wrote: On Tuesday, 31. July 2007, Volker Reichelt wrote: So, assuming that this hasn't changed in a newer standard then I guess you're right and the check should only be a warning with -pedantic, (and no -pedantic-errors) given. This is however not implementable currently. As I don't know why -pedantic-errors is on by default for C++ (but not for C), the only possibility I see is indeed to revert this patch and add a comment/testcase. pedantic-errors is not on by default in C++. The function pedwarn() produces errors by default in C++ as opposed to C. On the other hand, -pedantic-errors makes pedwarn() produce errors instead of warnings AND sets the flag pedantic. It is a subtle difference. (Then, -pedantic sets the flag pedantic but does not change the way pedwarn() works and -fpermissive just change pedwarn() to emit warnings instead of errors). This is how it works internally, now whether it is reflecting the desired behaviour I just don't know. With the above cheat sheet, you can play to guess what is the actual effect of combinations like 1) -pedantic, 2) -pedantic -fpermissive 3) -fpermissive -Werror 4) -fpermissive 5) -pedantic-errors -fpermissive. (As you will see, 4 and 5 are not the same, so no, -pedantic-errors is not enabled by default in C++ however, 2 and 5 will produce the same output in C++). I hope this clarifies. Cheers, Manuel.
Re: Semicolons at the end of member function definitions
Volker Reichelt wrote: 2007-03-26 Dirk Mueller [EMAIL PROTECTED] * parser.c (cp_parser_member_declaration): Pedwarn about stray semicolons after member declarations. It makes struct A { void foo() {}; } That is indeed still legal in the current working draft. (The reason that I copied the grammar productions above the parser functions was so that it would be easy to check things like this...) Therefore, IMHO the patch is wrong and should be reverted. Yes, please go ahead and revert it. And, if you have time, please add a test-case specifically for this case. The previous patch removed semicolons from lots of valid code, but probably none of those test cases were specifically for this case. Thanks, -- Mark Mitchell CodeSourcery [EMAIL PROTECTED] (650) 331-3385 x713
Semicolons at the end of member function definitions
Hi, I just stumbled over the patch 2007-03-26 Dirk Mueller [EMAIL PROTECTED] * parser.c (cp_parser_member_declaration): Pedwarn about stray semicolons after member declarations. which was approved by Gaby here: http://gcc.gnu.org/ml/gcc-patches/2007-03/msg01456.html and made it into the trunk here: http://gcc.gnu.org/ml/gcc-cvs/2007-03/msg00841.html It makes struct A { void foo() {}; } a hard error with -pedantic. The 1998 version of the standard (sorry, I don't have the 2003 version available) contains in [class.mem]: member-declaration: ... function-definition ;opt ... Therefore, IMHO the patch is wrong and should be reverted. Or am I missing something? Regards, Volker