Commit 4e2bb0a4 by Danny Smith

re PR target/27789 (attribute handling fallout from DECL_INITIAL changes)

	PR target/27789
	* config/i386/winnt.c (ix86_handle_selectany_attribute): Move check
	for initialization and setting of one_only flag to ...
	(i386_pe_encode_section_info): ...here.
	(i386_pe_dllimport_p): Check for DECL_DLLIMPORT_P also.
	Recheck that the symbol has not been defined.

cp
	* decl.c (start_decl): Check that dllimports are not initialized.

testsuite
	* g++.dg/ext/dllimport4.C. Add more tests for invalid
	initialization.

From-SVN: r114927
parent ecf7b86f
2006-06-23 Danny Smith <dannysmith@users.sourceforge.net>
PR target/27789
* config/i386/winnt.c (ix86_handle_selectany_attribute): Move check
for initialization and setting of one_only flag to ...
(i386_pe_encode_section_info): ...here.
(i386_pe_dllimport_p): Check for DECL_DLLIMPORT_P also.
Recheck that the symbol has not been defined.
2006-06-23 Richard Guenther <rguenther@suse.de> 2006-06-23 Richard Guenther <rguenther@suse.de>
* ggc-page.c (init_ggc): Do not round up the extra_order_size_table * ggc-page.c (init_ggc): Do not round up the extra_order_size_table
...@@ -26,6 +35,7 @@ ...@@ -26,6 +35,7 @@
* reload1.c (gen_reload): Call mark_jump_label on the new insns * reload1.c (gen_reload): Call mark_jump_label on the new insns
generated by gen_move_insn to add REG_LABEL notes if necessary. generated by gen_move_insn to add REG_LABEL notes if necessary.
>>>>>>> .r114926
2006-06-22 Bob Wilson <bob.wilson@acm.org> 2006-06-22 Bob Wilson <bob.wilson@acm.org>
* config/xtensa/lib1funcs.asm (MIN_ESA): Delete. * config/xtensa/lib1funcs.asm (MIN_ESA): Delete.
......
/* Subroutines for insn-output.c for Windows NT. /* Subroutines for insn-output.c for Windows NT.
Contributed by Douglas Rupp (drupp@cs.washington.edu) Contributed by Douglas Rupp (drupp@cs.washington.edu)
Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
Free Software Foundation, Inc. 2005, 2006 Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -88,17 +88,10 @@ ix86_handle_selectany_attribute (tree *node, tree name, ...@@ -88,17 +88,10 @@ ix86_handle_selectany_attribute (tree *node, tree name,
bool *no_add_attrs) bool *no_add_attrs)
{ {
/* The attribute applies only to objects that are initialized and have /* The attribute applies only to objects that are initialized and have
external linkage, */ external linkage. However, we may not know about initialization
if (TREE_CODE (*node) == VAR_DECL && TREE_PUBLIC (*node) until the language frontend has processed the decl. We'll check for
&& (DECL_INITIAL (*node) initialization later in encode_section_info. */
/* If an object is initialized with a ctor, the static if (TREE_CODE (*node) != VAR_DECL || !TREE_PUBLIC (*node))
initialization and destruction code for it is present in
each unit defining the object. The code that calls the
ctor is protected by a link-once guard variable, so that
the object still has link-once semantics, */
|| TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (*node))))
make_decl_one_only (*node);
else
{ {
error ("%qs attribute applies only to initialized variables" error ("%qs attribute applies only to initialized variables"
" with external linkage", IDENTIFIER_POINTER (name)); " with external linkage", IDENTIFIER_POINTER (name));
...@@ -148,18 +141,28 @@ i386_pe_dllimport_p (tree decl) ...@@ -148,18 +141,28 @@ i386_pe_dllimport_p (tree decl)
&& TREE_CODE (decl) != FUNCTION_DECL) && TREE_CODE (decl) != FUNCTION_DECL)
return false; return false;
/* Lookup the attribute rather than rely on the DECL_DLLIMPORT_P flag. /* Lookup the attribute in addition to checking the DECL_DLLIMPORT_P flag.
We may need to override an earlier decision. */ We may need to override an earlier decision. */
if (lookup_attribute ("dllimport", DECL_ATTRIBUTES (decl))) if (DECL_DLLIMPORT_P (decl)
return true; && lookup_attribute ("dllimport", DECL_ATTRIBUTES (decl)))
{
/* Make a final check to see if this is a definition before we generate
RTL for an indirect reference. */
if (!DECL_EXTERNAL (decl))
{
error ("%q+D: definition is marked as dllimport", decl);
DECL_DLLIMPORT_P (decl) = 0;
return false;
}
return true;
}
/* The DECL_DLLIMPORT_P flag was set for decls in the class definition /* The DECL_DLLIMPORT_P flag was set for decls in the class definition
by targetm.cxx.adjust_class_at_definition. Check again to emit by targetm.cxx.adjust_class_at_definition. Check again to emit
warnings if the class attribute has been overridden by an warnings if the class attribute has been overridden by an
out-of-class definition. */ out-of-class definition. */
if (associated_type (decl) else if (associated_type (decl)
&& lookup_attribute ("dllimport", && lookup_attribute ("dllimport",
TYPE_ATTRIBUTES (associated_type (decl)))) TYPE_ATTRIBUTES (associated_type (decl))))
return i386_pe_type_dllimport_p (decl); return i386_pe_type_dllimport_p (decl);
return false; return false;
...@@ -362,6 +365,22 @@ i386_pe_encode_section_info (tree decl, rtx rtl, int first) ...@@ -362,6 +365,22 @@ i386_pe_encode_section_info (tree decl, rtx rtl, int first)
} }
} }
else if (TREE_CODE (decl) == VAR_DECL
&& lookup_attribute ("selectany", DECL_ATTRIBUTES (decl)))
{
if (DECL_INITIAL (decl)
/* If an object is initialized with a ctor, the static
initialization and destruction code for it is present in
each unit defining the object. The code that calls the
ctor is protected by a link-once guard variable, so that
the object still has link-once semantics, */
|| TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (decl)))
make_decl_one_only (decl);
else
error ("%q+D:'selectany' attribute applies only to initialized objects",
decl);
}
/* Mark the decl so we can tell from the rtl whether the object is /* Mark the decl so we can tell from the rtl whether the object is
dllexport'd or dllimport'd. tree.c: merge_dllimport_decl_attributes dllexport'd or dllimport'd. tree.c: merge_dllimport_decl_attributes
handles dllexport/dllimport override semantics. */ handles dllexport/dllimport override semantics. */
......
2006-06-23 Danny Smith <dannysmith@users.sourceforge.net>
PR target/27789
* decl.c (start_decl): Check that dllimports are not initialized.
2006-06-22 Lee Millward <lee.millward@gmail.com> 2006-06-22 Lee Millward <lee.millward@gmail.com>
PR c++/27805 PR c++/27805
......
...@@ -3873,6 +3873,16 @@ start_decl (const cp_declarator *declarator, ...@@ -3873,6 +3873,16 @@ start_decl (const cp_declarator *declarator,
/* Set attributes here so if duplicate decl, will have proper attributes. */ /* Set attributes here so if duplicate decl, will have proper attributes. */
cplus_decl_attributes (&decl, attributes, 0); cplus_decl_attributes (&decl, attributes, 0);
/* Dllimported symbols cannot be defined. Static data members (which
can be initialized in-class and dllimported) go through grokfield,
not here, so we don't need to exclude those decls when checking for
a definition. */
if (initialized && DECL_DLLIMPORT_P (decl))
{
error ("definition of %q#D is marked %<dllimport%>", decl);
DECL_DLLIMPORT_P (decl) = 0;
}
/* If #pragma weak was used, mark the decl weak now. */ /* If #pragma weak was used, mark the decl weak now. */
maybe_apply_pragma_weak (decl); maybe_apply_pragma_weak (decl);
......
2006-06-23 Danny Smith <dannysmith@users.sourceforge.net>
PR target/27789
* g++.dg/ext/dllimport4.C. Add more tests for invalid
initialization.
2006-06-22 Roger Sayle <roger@eyesopen.com> 2006-06-22 Roger Sayle <roger@eyesopen.com>
PR target/27531 PR target/27531
...@@ -4,3 +4,35 @@ ...@@ -4,3 +4,35 @@
__attribute__((dllimport)) void bar () { } // { dg-error "definition" } __attribute__((dllimport)) void bar () { } // { dg-error "definition" }
__attribute__((dllimport)) int foo = 1; // { dg-error "definition" } __attribute__((dllimport)) int foo = 1; // { dg-error "definition" }
void faz()
{
__attribute__((dllimport)) int faa = 1; // { dg-error "definition" }
faa++;
}
__attribute__((dllimport)) int fee (1); // { dg-error "definition" }
// In-class initialization of a static data member is not a definition.
struct F
{
__attribute__ ((dllimport)) static const int i = 1; // OK
};
// Reference the dllimport'd static data member.
void f ()
{
const int* j = &F::i;
}
struct G
{
__attribute__ ((dllimport)) static const int i = 1;
};
// Define the static data member _without_ the dllimport.
// This should override the prior declaration with dllimport.
const int G::i; // { dg-warning "dllimport ignored" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment