/* Routines for GCC for a Symbian OS targeted SH backend.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
Contributed by RedHat.
Most of this code is stolen from i386/winnt.c.
GCC is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT
License for more details.
You should have received a copy of the GNU General Public License
- along with GCC; see the file COPYING. If not, write to
- the Free Software Foundation, 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ along with GCC; see the file COPYING3. If not see
+ <http://www.gnu.org/licenses/>. */
#include "config.h"
#include "system.h"
1 for informative messages about decisions to add attributes
2 for verbose information about what is being done. */
#define SYMBIAN_DEBUG 0
-//#define SYMBIAN_DEBUG 1
-//#define SYMBIAN_DEBUG 2
+/* #define SYMBIAN_DEBUG 1 */
+/* #define SYMBIAN_DEBUG 2 */
/* A unique character to encode declspec encoded objects. */
#define SH_SYMBIAN_FLAG_CHAR "$"
{
/* Don't warn about artificial methods. */
if (!DECL_ARTIFICIAL (decl))
- warning ("%H function '%D' is defined after prior declaration as dllimport: attribute ignored",
- & DECL_SOURCE_LOCATION (decl), decl);
+ warning (OPT_Wattributes, "function %q+D is defined after prior "
+ "declaration as dllimport: attribute ignored",
+ decl);
return false;
}
else if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INLINE (decl))
{
if (extra_warnings)
- warning ("%Hinline function '%D' is declared as dllimport: attribute ignored.",
- & DECL_SOURCE_LOCATION (decl), decl);
+ warning (OPT_Wattributes, "inline function %q+D is declared as "
+ "dllimport: attribute ignored",
+ decl);
return false;
}
&& !DECL_EXTERNAL (decl))
{
if (!DECL_VIRTUAL_P (decl))
- error ("%Hdefinition of static data member '%D' of dllimport'd class.",
- & DECL_SOURCE_LOCATION (decl), decl);
+ error ("definition of static data member %q+D of dllimport'd class",
+ decl);
return false;
}
}
/* Mark a DECL as being dllexport'd.
- Note that we override the previous setting (eg: dllimport). */
+ Note that we override the previous setting (e.g.: dllimport). */
static void
sh_symbian_mark_dllexport (tree decl)
tree idp;
rtlname = XEXP (DECL_RTL (decl), 0);
-
- if (GET_CODE (rtlname) == SYMBOL_REF)
- oldname = XSTR (rtlname, 0);
- else if (GET_CODE (rtlname) == MEM
- && GET_CODE (XEXP (rtlname, 0)) == SYMBOL_REF)
- oldname = XSTR (XEXP (rtlname, 0), 0);
- else
- abort ();
+ if (GET_CODE (rtlname) == MEM)
+ rtlname = XEXP (rtlname, 0);
+ gcc_assert (GET_CODE (rtlname) == SYMBOL_REF);
+ oldname = XSTR (rtlname, 0);
if (sh_symbian_dllimport_name_p (oldname))
{
unit which has included the header in order to ensure argument
correctness. */
oldname += strlen (DLL_IMPORT_PREFIX);
- DECL_NON_ADDR_CONST_P (decl) = 0;
+ DECL_DLLIMPORT_P (decl) = 0;
}
else if (sh_symbian_dllexport_name_p (oldname))
return; /* Already done. */
rtx newrtl;
rtlname = XEXP (DECL_RTL (decl), 0);
-
- if (GET_CODE (rtlname) == SYMBOL_REF)
- oldname = XSTR (rtlname, 0);
- else if (GET_CODE (rtlname) == MEM
- && GET_CODE (XEXP (rtlname, 0)) == SYMBOL_REF)
- oldname = XSTR (XEXP (rtlname, 0), 0);
- else
- abort ();
+ if (GET_CODE (rtlname) == MEM)
+ rtlname = XEXP (rtlname, 0);
+ gcc_assert (GET_CODE (rtlname) == SYMBOL_REF);
+ oldname = XSTR (rtlname, 0);
if (sh_symbian_dllexport_name_p (oldname))
{
- error ("`%s' declared as both exported to and imported from a DLL",
+ error ("%qs declared as both exported to and imported from a DLL",
IDENTIFIER_POINTER (DECL_NAME (decl)));
}
else if (sh_symbian_dllimport_name_p (oldname))
{
/* Already done, but do a sanity check to prevent assembler errors. */
if (!DECL_EXTERNAL (decl) || !TREE_PUBLIC (decl))
- error ("%Hfailure in redeclaration of '%D': dllimport'd symbol lacks external linkage.",
- &DECL_SOURCE_LOCATION (decl), decl);
+ error ("failure in redeclaration of %q+D: dllimport'd symbol lacks external linkage",
+ decl);
}
else
{
/* It might be that DECL has already been marked as dllimport, but a
subsequent definition nullified that. The attribute is gone but
DECL_RTL still has (DLL_IMPORT_PREFIX) prefixed. We need to remove
- that. Ditto for the DECL_NON_ADDR_CONST_P flag. */
+ that. Ditto for the DECL_DLLIMPORT_P flag. */
else if ( (TREE_CODE (decl) == FUNCTION_DECL
|| TREE_CODE (decl) == VAR_DECL)
&& DECL_RTL (decl) != NULL_RTX
tree idp = get_identifier (oldname + strlen (DLL_IMPORT_PREFIX));
rtx newrtl = gen_rtx_SYMBOL_REF (Pmode, IDENTIFIER_POINTER (idp));
- warning ("%H%s '%D' %s after being referenced with dllimport linkage.",
- & DECL_SOURCE_LOCATION (decl),
+ warning (0, "%s %q+D %s after being referenced with dllimport linkage",
TREE_CODE (decl) == VAR_DECL ? "variable" : "function",
decl, (DECL_INITIAL (decl) || !DECL_EXTERNAL (decl))
? "defined locally" : "redeclared without dllimport attribute");
XEXP (DECL_RTL (decl), 0) = newrtl;
- DECL_NON_ADDR_CONST_P (decl) = 0;
+ DECL_DLLIMPORT_P (decl) = 0;
}
}
attr = get_identifier (attr_name);
- (DECL_P (node) ? DECL_ATTRIBUTES (node) : TYPE_ATTRIBUTES (node))
- = tree_cons (attr, NULL_TREE, attrs);
+ if (DECL_P (node))
+ DECL_ATTRIBUTES (node) = tree_cons (attr, NULL_TREE, attrs);
+ else
+ TYPE_ATTRIBUTES (node) = tree_cons (attr, NULL_TREE, attrs);
#if SYMBIAN_DEBUG
- fprintf (stderr, "propogate %s attribute", attr_name);
+ fprintf (stderr, "propagate %s attribute", attr_name);
print_node_brief (stderr, " to", node, 0);
fprintf (stderr, "\n");
#endif
| (int) ATTR_FLAG_FUNCTION_NEXT
| (int) ATTR_FLAG_ARRAY_NEXT))
{
- warning ("`%s' attribute ignored", attr);
+ warning (OPT_Wattributes, "%qs attribute ignored", attr);
*no_add_attrs = true;
return tree_cons (name, args, NULL_TREE);
}
if (TREE_CODE (node) != RECORD_TYPE && TREE_CODE (node) != UNION_TYPE)
{
- warning ("`%s' attribute ignored", attr);
+ warning (OPT_Wattributes, "%qs attribute ignored", attr);
*no_add_attrs = true;
}
{
if (DECL_INITIAL (node))
{
- error ("%Hvariable `%D' definition is marked dllimport.",
- & DECL_SOURCE_LOCATION (node), node);
+ error ("variable %q+D definition is marked dllimport",
+ node);
*no_add_attrs = true;
}
&& ( TREE_CODE (node) == VAR_DECL
|| TREE_CODE (node) == FUNCTION_DECL))
{
- error ("%Hexternal linkage required for symbol '%D' because of '%s' attribute.",
- & DECL_SOURCE_LOCATION (node), node, IDENTIFIER_POINTER (name));
+ error ("external linkage required for symbol %q+D because of %qs attribute",
+ node, IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
static void
symbian_possibly_export_base_class (tree base_class)
{
- tree methods;
+ VEC(tree,gc) *method_vec;
int len;
- if (! (TYPE_POLYMORPHIC_P (base_class)
- || TYPE_USES_VIRTUAL_BASECLASSES (base_class)))
+ if (! (TYPE_CONTAINS_VPTR_P (base_class)))
return;
- methods = CLASSTYPE_METHOD_VEC (base_class);
- len = methods ? TREE_VEC_LENGTH (methods) : 0;
+ method_vec = CLASSTYPE_METHOD_VEC (base_class);
+ len = method_vec ? VEC_length (tree, method_vec) : 0;
for (;len --;)
{
- tree member = TREE_VEC_ELT (methods, len);
+ tree member = VEC_index (tree, method_vec, len);
if (! member)
continue;
bool dllimport_ctor_dtor;
bool dllimport_member;
tree binfo, base_binfo;
- tree methods;
+ VEC(tree,gc) *method_vec;
tree key;
int i;
int len;
dllimport_ctor_dtor = false;
dllimport_member = false;
- methods = CLASSTYPE_METHOD_VEC (ctype);
- len = methods ? TREE_VEC_LENGTH (methods) : 0;
+ method_vec = CLASSTYPE_METHOD_VEC (ctype);
+ len = method_vec ? VEC_length (tree, method_vec) : 0;
for (;len --;)
{
- tree member = TREE_VEC_ELT (methods, len);
+ tree member = VEC_index (tree, method_vec, len);
if (! member)
continue;
static bool
symbian_class_needs_attribute_p (tree ctype, const char *attribute_name)
{
+ VEC(tree,gc) *method_vec;
+
+ method_vec = CLASSTYPE_METHOD_VEC (ctype);
+
/* If the key function has the attribute then the class needs it too. */
if (TYPE_POLYMORPHIC_P (ctype)
- && CLASSTYPE_KEY_METHOD (ctype)
+ && method_vec
&& lookup_attribute (attribute_name,
- DECL_ATTRIBUTES (CLASSTYPE_KEY_METHOD (ctype))))
+ DECL_ATTRIBUTES (VEC_index (tree, method_vec, 0))))
return true;
/* Check the class's member functions. */
if (TREE_CODE (ctype) == RECORD_TYPE)
{
- tree methods = CLASSTYPE_METHOD_VEC (ctype);
- unsigned int len = methods ? TREE_VEC_LENGTH (methods) : 0;
+ unsigned int len;
+
+ len = method_vec ? VEC_length (tree, method_vec) : 0;
for (;len --;)
{
- tree member = TREE_VEC_ELT (methods, len);
+ tree member = VEC_index (tree, method_vec, len);
if (! member)
continue;