diff mbox

[c++] : Make structure in exten C block and for -fms-extension more permissive.

Message ID AANLkTinzwoy8CtrX_FprdtnAQtRrHLA3PqabP0D1t689@mail.gmail.com
State New
Headers show

Commit Message

Kai Tietz Aug. 16, 2010, 7:59 p.m. UTC
Hello,

This patch allows the use of typedef'ed names as arguments in structures, if the
structure is defined in an external C block. By this handling gets
more similar to
C. If the the option -fms-extensions is enabled, this is also allowed
for class in C++ - like the option -fpermissive.

This adjustments helps mingw and wine to mimic the behavior of VC in
such cases better.

ChangeLog for gcc/cp

2010-08-16  Kai Tietz

	* class.c (note_name_declared_in_class): Make in 'extern "C"' blocks,
	or if -fms-extensions is enabled check, check permissive.


Patch tested for x86_64-w64-mingw32 and i686-w64-mingw32. Ok for apply?

Kai

Comments

Joseph Myers Aug. 16, 2010, 8:05 p.m. UTC | #1
On Mon, 16 Aug 2010, Kai Tietz wrote:

> This patch allows the use of typedef'ed names as arguments in structures, if the
> structure is defined in an external C block. By this handling gets
> more similar to
> C. If the the option -fms-extensions is enabled, this is also allowed
> for class in C++ - like the option -fpermissive.

This patch is missing both documentation and testcases for your proposed 
extension.
Kai Tietz Aug. 16, 2010, 8:48 p.m. UTC | #2
2010/8/16 Joseph S. Myers <joseph@codesourcery.com>:
> On Mon, 16 Aug 2010, Kai Tietz wrote:
>
>> This patch allows the use of typedef'ed names as arguments in structures, if the
>> structure is defined in an external C block. By this handling gets
>> more similar to
>> C. If the the option -fms-extensions is enabled, this is also allowed
>> for class in C++ - like the option -fpermissive.
>
> This patch is missing both documentation and testcases for your proposed
> extension.

Added testcases and some documentation extension.

ChangeLog for gcc/doc

2010-08-16  Kai Tietz

	* invoke.texi (ms-extension): Add documentation.

ChangeLog for gcc/testsuite
2010-08-16  Kai Tietz

	* g++.dg/ext/uow-1.C: New test.
	* g++.dg/ext/uow-2.C: New test.
	* g++.dg/ext/uow-3.C: New test.

ChangeLog for gcc/cp

2010-08-16  Kai Tietz

	* class.c (note_name_declared_in_class): Make in 'extern "C"' blocks,
	or if -fms-extensions is enabled check, check permissive.


Patch tested for x86_64-w64-mingw32 and i686-w64-mingw32. Ok for apply?

Kai
Jason Merrill Aug. 16, 2010, 10:06 p.m. UTC | #3
On 08/16/2010 04:48 PM, Kai Tietz wrote:
> +   For records in external C blocks allow member-names even to types,
> +   if pedantic isn't set.  */

This comment should be by the new code, not at the top of the function. 
  And it should be clearer, like 'C allows members to be declared with a 
type of the same name, and the C++ standard says this diagnostic is not 
required, so allow it in extern "C" blocks unless pedantic.  Allow it in 
all cases if -fms-extensions.'

> +It allows for c++ that member-names in structures can be similiar
> +to previous types declarations.

"Allows class members to be declared with a type of the same name."

Lets add one more test for the pedantic case.

OK with those changes.

Jason
Kai Tietz Aug. 17, 2010, 9:55 a.m. UTC | #4
2010/8/17 Jason Merrill <jason@redhat.com>:
> On 08/16/2010 04:48 PM, Kai Tietz wrote:
>>
>> +   For records in external C blocks allow member-names even to types,
>> +   if pedantic isn't set.  */
>
> This comment should be by the new code, not at the top of the function.  And
> it should be clearer, like 'C allows members to be declared with a type of
> the same name, and the C++ standard says this diagnostic is not required, so
> allow it in extern "C" blocks unless pedantic.  Allow it in all cases if
> -fms-extensions.'
>
>> +It allows for c++ that member-names in structures can be similiar
>> +to previous types declarations.
>
> "Allows class members to be declared with a type of the same name."
>
> Lets add one more test for the pedantic case.
>
> OK with those changes.
>
> Jason
>

Ok, modified as you suggested and added a fourth test-case for
-pedantic. Applied at  revision 163298, 163300, and 163301.

Regards,
Kai
diff mbox

Patch

Index: class.c
===================================================================
--- class.c     (revision 163283)
+++ class.c     (working copy)
@@ -6807,7 +6807,9 @@ 
     = current_class_stack[current_class_depth - 1].names_used;
   if (!names_used)
     return;
-
+  if ((!pedantic && current_lang_name == lang_name_c)
+      || flag_ms_extensions)
+    return;
   n = splay_tree_lookup (names_used, (splay_tree_key) name);
   if (n)
     {