[PATCH] Additional features for -fms-extensions

"Schönbeck, Andreas" Andreas.Schoenbeck2@fabalabs.org
Sat Oct 30 17:01:00 GMT 2004


Hi!

I am submitting six patches. They address some problems a company had while porting their sourcecode to GNU/Linux. Until now they compiled their code with the microsoft c++ compiler. When doing this with GCC there were some errors the microsoft compiler didn't complain about. So they tried the -fms-extensions but this did not address all of the problems so they asked me to add some features to the -fms-extensions.

I know that the behavior of the GCC is as it is expected. But I think it is a benefit for the GCC if it CAN do these things as the microsoft compiler can. So I'd be delighted if these patches I submit could be taken into the sources.
I tested those patches on a i686 on a SuSE System and they where tested by the above mentioned company (Fabasoft) with their sources and everything worked fine.

The prblems addressed are: (each with a short description and an example)

+ An ellipsis does not take variables of non-POD type as arguments:
====================================
/*
  Results:

  GCC:
    test2.cxx: In function 'int main()':
    test2.cxx:xx: warning: cannot pass objects of non-POD type 'Class Point'
       through '...'; call will abort at runtime
*/

void test(...)
{
}

class Point
{
public:
  Point(int x, int y) { this->x = x; this->y = y; }
  int getX() { return x; }
  int getY() { return y; }

private:
  int x;
  int y;
};

int main()
{
  Point p(1,1);

  test(p);

  return 0;
}
====================================
+ When passing a lvalue to a function which wants to take a reference there is an error thrown:
====================================
/*
  Results:

  GCC:
    test2.cxx: In function 'int main()':
    test2.cxx:xx: error: no matching function for call to 'Class2::add(Class1)'
    test2.cxx:xx: error: candidates are: static void Class2::add(Class1&)
*/

class A
{
public:
  A() {}
};

class B
{
public:
  static void test(A& a) {}
};


int main()
{
  B::test(A());

  return 0;
}
====================================
+ When declaring a not-anonymous union within an anonymous union an error is thrown
====================================
/*
  Results:

  GCC:
    test3.cxx:xx: error: Union 'TestStruct::<anonymous union>::TestUnion'
    invalid; an anonymous union can only have non-static data members
*/

struct TestStruct
{
  union
  {
    union TestUnion
    {
      int test;
    };
  };
};

int main()
{
  return 0;
}
====================================
+ When declaring something extern and later static an error is thrown
====================================
/*
  Results:

  GCC:
    test4.cxx:xx: error: 'void test()' was declared 'extern' and later 'static'
*/GCC (3.3):

class A
{
  friend void test();
};

static void test()
{
}

int main()
{
  test();
  return 0;
}
====================================
+ There can't be a forward declaration of an enum
====================================
/*
  Results:

  GCC:
    test5.cxx:xx: error: use of enum 'A' without previous declaration
*/

enum A;

int main()
{
  return 0;
}
====================================
+ The address of a member of a packed struct can't be retrieved
====================================
/*
  Results:

  GCC (3.4.2):
    test8.cxx:xx: error: cannot bind packed field `a.A::field2' to `int&'

*/

#include <unistd.h>

struct A
{
  char field1;
  int field2;
} __attribute__((packed));

void test(int& value) 
{
}

int main()
{
  A a;

  test(a.field2);

  return 0;
}
====================================


-------------- next part --------------
A non-text attachment was scrubbed...
Name: call.c_non-POD.patch
Type: text/x-patch
Size: 1575 bytes
Desc: call.c_non-POD.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20041030/4c5fd52f/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: call.c_packed_field.patch
Type: text/x-patch
Size: 865 bytes
Desc: call.c_packed_field.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20041030/4c5fd52f/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: call.c_reference.patch
Type: text/x-patch
Size: 841 bytes
Desc: call.c_reference.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20041030/4c5fd52f/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: class.c_anon_union.patch
Type: text/x-patch
Size: 922 bytes
Desc: class.c_anon_union.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20041030/4c5fd52f/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: decl.c_enum.patch
Type: text/x-patch
Size: 1073 bytes
Desc: decl.c_enum.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20041030/4c5fd52f/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: decl.c_extern_redecl.patch
Type: text/x-patch
Size: 1304 bytes
Desc: decl.c_extern_redecl.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20041030/4c5fd52f/attachment-0005.bin>


More information about the Gcc-patches mailing list