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]

Re: dllexport patch


Jason Merrill <jason@cygnus.com> writes:
> MSVC++ allows dllexport/import to be applied to classes, to export or
> import all of the members en masse.  This patch adds this support to gcc,
> and removes the old code for guessing if a vtable should be imported or
> exported.

Thanks. It does fix a few problems that I couldn't fix (trust me, I
tried!), but most of the parser related ones are still there 
unfortunately.

btw, I'm not sure if the rest of this message is appropriate for
egcs-patches, so I'm copying egcs-bugs instead. 

I'm attaching my favorite C++ parser choker when it comes to attribute
parsing that hopefully will show the problems. I have patches from 
Alastair Houghton that solve all but the last (slightly modified by me
since I submitted it the egcs-patches). Note that the C parser handles
all of these cases (except for the C++ specific ones of course).

Here's a summary of test results (please refer to the attached test case):

1. No patches (egcs-1.1 today's snapshot):

    c++-attrib-test.cc:9: parse error before `__attribute__'
    c++-attrib-test.cc:12: parse error before `__attribute__'
    c++-attrib-test.cc:18: parse error before `__attribute__'
    c++-attrib-test.cc:19: parse error before `__attribute__'
    c++-attrib-test.cc:25: parse error before `__attribute__'
    c++-attrib-test.cc:26: parse error before `__attribute__'
    c++-attrib-test.cc:27: parse error before `__attribute__'
    c++-attrib-test.cc:41: warning: `stdcall' attribute directive ignored
    c++-attrib-test.cc:42: warning: `stdcall' attribute ignored
    c++-attrib-test.cc: In method `void foobar3::foo()':
    c++-attrib-test.cc:45: warning: `stdcall' attribute directive ignored
    c++-attrib-test.cc: At top level:
    c++-attrib-test.cc:48: warning: `dllimport' attribute directive ignored
    c++-attrib-test.cc:49: parse error before `:'

2. + your just posted patch:

    c++-attrib-test.cc:9: parse error before `__attribute__'
    c++-attrib-test.cc:12: parse error before `__attribute__'
    c++-attrib-test.cc:18: parse error before `__attribute__'
    c++-attrib-test.cc:19: parse error before `__attribute__'
    c++-attrib-test.cc:25: parse error before `__attribute__'
    c++-attrib-test.cc:26: parse error before `__attribute__'
    c++-attrib-test.cc:27: parse error before `__attribute__'
    c++-attrib-test.cc:42: warning: `stdcall' attribute ignored
    c++-attrib-test.cc:49: parse error before `:'

3. + my local patches:

    c++-attrib-test.cc:49: parse error before `:'

The patch I had submitted is (again, my current version is slightly
modified to fix a bug in the patch):

  http://www.cygnus.com/ml/egcs-patches/1998-Jun/0542.html

I'll be more than happy to resubmit the fixed version if you're interested
in looking at it now. Or else, I'll just wait until the 1.1 dust settles.

Regards,
Mumit

/*
 * Attribute handling in C vs C++ parsers. All of these are accepted
 * by C parser, but the ones marked "bad" are rejected by C++.
 */

#define STDCALL __attribute__((stdcall))
#define NO_COPY __attribute__((section (".data$cygwin_nocopy")))

int (STDCALL *foo) ();				// bad. Line 9 

int STDCALL * funcname();
int * STDCALL funcname();			// bad. Line 12

int NO_COPY var1;
int NO_COPY *var2;
int NO_COPY **var3;

int * NO_COPY var4;				// bad. Line 18
int ** NO_COPY var5;				// bad.
int NO_COPY **var6;
int NO_COPY var7 = 5;
static int NO_COPY var8 = 5;
static NO_COPY int var9 = 5;
static NO_COPY char *var10 = 0;
static char * NO_COPY var11 = 0;		// bad. Line 25
static char * NO_COPY * var12 = 0;		// bad.
struct foobar * NO_COPY * var13 = 0;		// bad. Line 27

typedef int BOOL;
static NO_COPY BOOL var14;
static NO_COPY BOOL var15 = 0;

typedef struct {
  int i;
} foobar2;

static NO_COPY foobar2 var16;
NO_COPY static foobar2 var17;

struct foobar3 {
  STDCALL void foo ();				// bad. Line 41
  STDCALL void foo2 () { return; } 		// bad.
};

STDCALL void foobar3::foo () { return; }	// bad. Line 45

// the following still doesn't work right, thanks to parse.y:class_head
class __attribute__((dllimport)) foobar4 { public: int i; }; // bad. Line 48
class __attribute__((dllexport)) foobar5 : public foobar3 { public: int i; };

/* C++ PROBLEMS (all but the last is fixed by this patch)
c++-attrib-test.cc:9: parse error before `__attribute__'
c++-attrib-test.cc:12: parse error before `__attribute__'
c++-attrib-test.cc:18: parse error before `__attribute__'
c++-attrib-test.cc:19: parse error before `__attribute__'
c++-attrib-test.cc:25: parse error before `__attribute__'
c++-attrib-test.cc:26: parse error before `__attribute__'
c++-attrib-test.cc:27: parse error before `__attribute__'
c++-attrib-test.cc:41: warning: `stdcall' attribute directive ignored
c++-attrib-test.cc:42: warning: `stdcall' attribute ignored
c++-attrib-test.cc: In method `void foobar3::foo()':
c++-attrib-test.cc:45: warning: `stdcall' attribute directive ignored
c++-attrib-test.cc: At top level:
c++-attrib-test.cc:48: warning: `dllimport' attribute directive ignored
c++-attrib-test.cc:49: parse error before `:'
*/

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