/* Process declarations and variables for C++ compiler.
Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+ 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
Contributed by Michael Tiemann (tiemann@cygnus.com)
#include "tm_p.h"
#include "target.h"
#include "c-family/c-common.h"
+#include "c-family/c-objc.h"
#include "c-family/c-pragma.h"
#include "diagnostic.h"
#include "intl.h"
/* Used only for jumps to as-yet undefined labels, since jumps to
defined labels can have their validity checked immediately. */
-struct GTY(()) named_label_use_entry {
+struct GTY((chain_next ("%h.next"))) named_label_use_entry {
struct named_label_use_entry *next;
/* The binding level to which this entry is *currently* attached.
This is initially the binding level in which the goto appeared,
if (same_type_p (TREE_TYPE (f1), TREE_TYPE (f2)))
{
- if (p2 == NULL_TREE && DECL_EXTERN_C_P (olddecl)
+ if (!prototype_p (f2) && DECL_EXTERN_C_P (olddecl)
&& (DECL_BUILT_IN (olddecl)
#ifndef NO_IMPLICIT_EXTERN_C
|| (DECL_IN_SYSTEM_HEADER (newdecl) && !DECL_CLASS_SCOPE_P (newdecl))
TREE_TYPE (newdecl) = TREE_TYPE (olddecl);
}
#ifndef NO_IMPLICIT_EXTERN_C
- else if (p1 == NULL_TREE
+ else if (!prototype_p (f1)
&& (DECL_EXTERN_C_P (olddecl)
&& DECL_IN_SYSTEM_HEADER (olddecl)
&& !DECL_CLASS_SCOPE_P (olddecl))
}
#endif
else
- types_match = compparms (p1, p2);
+ types_match =
+ compparms (p1, p2)
+ && (TYPE_ATTRIBUTES (TREE_TYPE (newdecl)) == NULL_TREE
+ || comp_type_attributes (TREE_TYPE (newdecl),
+ TREE_TYPE (olddecl)) != 0);
}
else
types_match = 0;
error ("declaration of C function %q#D conflicts with",
newdecl);
error ("previous declaration %q+#D here", olddecl);
+ return NULL_TREE;
}
else if (compparms (TYPE_ARG_TYPES (TREE_TYPE (newdecl)),
TYPE_ARG_TYPES (TREE_TYPE (olddecl))))
}
else if (TREE_CODE (olddecl) == FUNCTION_DECL
&& DECL_INITIAL (olddecl) != NULL_TREE
- && TYPE_ARG_TYPES (TREE_TYPE (olddecl)) == NULL_TREE
- && TYPE_ARG_TYPES (TREE_TYPE (newdecl)) != NULL_TREE)
+ && !prototype_p (TREE_TYPE (olddecl))
+ && prototype_p (TREE_TYPE (newdecl)))
{
/* Prototype decl follows defn w/o prototype. */
warning_at (input_location, 0, "prototype for %q+#D", newdecl);
{
tree type, decl;
if (size > 0)
- type = build_nonstandard_integer_type (size, 0);
+ {
+ type = build_nonstandard_integer_type (size, 0);
+ type = build_distinct_type_copy (type);
+ }
else if (size > -32)
{
tree stype;
/* "__java_char" or ""__java_boolean". */
type = build_nonstandard_integer_type (-size, 1);
+ type = build_distinct_type_copy (type);
/* Get the signed type cached and attached to the unsigned type,
so it doesn't get garbage-collected at "random" times,
causing potential codegen differences out of different UIDs
and different alias set numbers. */
stype = build_nonstandard_integer_type (-size, 0);
+ stype = build_distinct_type_copy (stype);
TREE_CHAIN (type) = stype;
/*if (size == -1) TREE_SET_CODE (type, BOOLEAN_TYPE);*/
}
LOOKUP_ONLYCONVERTING);
}
else
- pushdecl_top_level_and_finish (decl, init);
+ {
+ DECL_THIS_STATIC (decl) = true;
+ pushdecl_top_level_and_finish (decl, init);
+ }
return decl;
}
if (ce->index == error_mark_node)
error ("name used in a GNU-style designated "
"initializer for an array");
+ else if (TREE_CODE (ce->index) == INTEGER_CST)
+ /* An index added by reshape_init. */
+ return true;
else
{
gcc_assert (TREE_CODE (ce->index) == IDENTIFIER_NODE);
elt_init = reshape_init_r (elt_type, d, /*first_initializer_p=*/false);
if (elt_init == error_mark_node)
return error_mark_node;
- CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (new_init), NULL_TREE, elt_init);
+ CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (new_init),
+ size_int (index), elt_init);
}
return new_init;
if (init && TREE_CODE (decl) == VAR_DECL)
{
DECL_NONTRIVIALLY_INITIALIZED_P (decl) = 1;
- /* FIXME we rely on TREE_CONSTANT below; basing that on
- init_const_expr_p is probably wrong for C++0x. */
if (init_const_expr_p)
{
- /* Set these flags now for C++98 templates. We'll update the
- flags in store_init_value for instantiations and C++0x. */
+ /* Set these flags now for templates. We'll update the flags in
+ store_init_value for instantiations. */
DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl) = 1;
if (decl_maybe_constant_var_p (decl))
TREE_CONSTANT (decl) = 1;
{
/* An out-of-class default definition is defined at
the point where it is explicitly defaulted. */
- if (DECL_INITIAL (decl) == error_mark_node)
+ if (DECL_DELETED_FN (decl))
+ maybe_explain_implicit_delete (decl);
+ else if (DECL_INITIAL (decl) == error_mark_node)
synthesize_method (decl);
}
else
if (size == error_mark_node)
return error_mark_node;
type = TREE_TYPE (size);
+ /* We didn't support this case in GCC 3.2, so don't bother
+ trying to model it now in ABI v1. */
+ abi_1_itype = error_mark_node;
}
size = maybe_constant_value (size);
+ if (!TREE_CONSTANT (size))
+ size = osize;
}
if (error_operand_p (size))
return itype;
}
- if (!abi_version_at_least (2) && processing_template_decl)
+ if (!abi_version_at_least (2) && processing_template_decl
+ && abi_1_itype == NULL_TREE)
/* For abi-1, we handled all instances in templates the same way,
even when they were non-dependent. This affects the manglings
produced. So, we do the normal checking for non-dependent
}
/* Create and return the appropriate index type. */
- if (abi_1_itype)
+ if (abi_1_itype && abi_1_itype != error_mark_node)
{
tree t = build_index_type (itype);
TYPE_CANONICAL (abi_1_itype) = TYPE_CANONICAL (t);
error ("const %qs cannot be declared %<mutable%>", name);
storage_class = sc_none;
}
+ else if (TREE_CODE (type) == REFERENCE_TYPE)
+ {
+ permerror (input_location, "reference %qs cannot be declared "
+ "%<mutable%>", name);
+ storage_class = sc_none;
+ }
}
/* If this is declaring a typedef name, return a TYPE_DECL. */
if (thread_p)
DECL_TLS_MODEL (decl) = decl_default_tls_model (decl);
+
+ if (constexpr_p && !initialized)
+ {
+ error ("constexpr static data member %qD must have an "
+ "initializer", decl);
+ constexpr_p = false;
+ }
}
else
{
{
value = cxx_constant_value (value);
- if (TREE_CODE (value) == INTEGER_CST)
+ if (TREE_CODE (value) == INTEGER_CST
+ && INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (value)))
{
value = perform_integral_promotions (value);
}
if (DECL_IN_AGGR_P (fndecl))
{
- if (DECL_CONTEXT (fndecl)
- && TREE_CODE (DECL_CONTEXT (fndecl)) != NAMESPACE_DECL)
+ if (DECL_CLASS_SCOPE_P (fndecl))
error ("%qD is already defined in class %qT", fndecl,
DECL_CONTEXT (fndecl));
return error_mark_node;
void
revert_static_member_fn (tree decl)
{
- TREE_TYPE (decl) = static_fn_type (decl);
+ tree stype = static_fn_type (decl);
- if (cp_type_quals (TREE_TYPE (decl)) != TYPE_UNQUALIFIED)
- error ("static member function %q#D declared with type qualifiers", decl);
+ if (type_memfn_quals (stype) != TYPE_UNQUALIFIED)
+ {
+ error ("static member function %q#D declared with type qualifiers", decl);
+ stype = apply_memfn_quals (stype, TYPE_UNQUALIFIED);
+ }
+ TREE_TYPE (decl) = stype;
if (DECL_ARGUMENTS (decl))
DECL_ARGUMENTS (decl) = DECL_CHAIN (DECL_ARGUMENTS (decl));