Bug 33963

Summary: [4.3/4.4 Regression] Dllimport attribute wrongly accepted on typedefs
Product: gcc Reporter: Danny Smith <dannysmith>
Component: targetAssignee: Joseph S. Myers <jsm28>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs, mark
Priority: P4 Keywords: accepts-invalid, diagnostic
Version: 4.3.0   
Target Milestone: 4.3.1   
Host: Target: i686-pc-mingw32
Build: Known to work: 4.2.0 4.3.1 4.4.0
Known to fail: 4.3.0 Last reconfirmed: 2008-02-26 12:13:45

Description Danny Smith 2007-10-31 20:13:09 UTC
Testcase gcc.dg/attr-invalid.c started failing on mingw32 with

http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=125975

In particular, this delta
	* tree.c (handle_dll_attribute): Set DECL_VISIBILITY on the
	imported or exported declaration, including type declarations.
 
made these TYPE_DECL's valid:

# 88 "attr-invalid.c"
typedef int dllimport_type __attribute__((dllimport));

typedef int (*dllimport_fntype)(void) __attribute__((dllimport));

Prior to that revision the attribute was valid only on FUNCTION_DECLS's
and VAR_DECL's 

However, although there is no warning, the attribute is ignored 

typedef int dllimport_type __attribute__((dllimport));
extern dllimport_type foo;
int bar () { return foo; }

gives

_bar:
	pushl	%ebp
	movl	%esp, %ebp
	movl	_foo, %eax
	popl	%ebp
	ret
Comment 1 Joseph S. Myers 2008-02-26 12:13:43 UTC
Mark confirms this should not be accepted for scalar types, so a regression.  Working on a patch.
Comment 2 Joseph S. Myers 2008-02-28 12:35:42 UTC
Subject: Bug 33963

Author: jsm28
Date: Thu Feb 28 12:34:51 2008
New Revision: 132744

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132744
Log:
	PR target/33963
	* tree.c (handle_dll_attribute): Disallow TYPE_DECLs for types
	other than structures and unions.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree.c

Comment 3 Joseph S. Myers 2008-03-06 17:30:26 UTC
Subject: Bug 33963

Author: jsm28
Date: Thu Mar  6 17:29:36 2008
New Revision: 132978

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132978
Log:
	PR target/33963
	* tree.c (handle_dll_attribute): Disallow TYPE_DECLs for types
	other than structures and unions.

Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/tree.c

Comment 4 Joseph S. Myers 2008-03-06 17:31:59 UTC
Fixed in 4.3.1 and 4.4.0.