return cp_build_type_attribute_variant (t1, attributes);
}
+/* Return the ARRAY_TYPE type without its domain. */
+
+tree
+strip_array_domain (tree type)
+{
+ tree t2;
+ gcc_assert (TREE_CODE (type) == ARRAY_TYPE);
+ if (TYPE_DOMAIN (type) == NULL_TREE)
+ return type;
+ t2 = build_cplus_array_type (TREE_TYPE (type), NULL_TREE);
+ return cp_build_type_attribute_variant (t2, TYPE_ATTRIBUTES (type));
+}
+
/* Wrapper around cp_common_type that is used by c-common.c and other
front end optimizations that remove promotions.
template info from T itself. */
if ((tinfo = get_template_info (t)))
;
- /* If T1 is a typedef or whatever has a template info associated
- to its context, get the template parameters from that context. */
+ else if (TREE_CODE (t) == TEMPLATE_TYPE_PARM)
+ return TEMPLATE_TYPE_PARM_SIBLING_PARMS (t);
else if (typedef_variant_p (t)
- && DECL_CONTEXT (TYPE_NAME (t))
- && !NAMESPACE_SCOPE_P (TYPE_NAME (t)))
+ && !NAMESPACE_SCOPE_P (TYPE_NAME (t)))
tinfo = get_template_info (DECL_CONTEXT (TYPE_NAME (t)));
+ /* If T is a TYPENAME_TYPE which context is a template type
+ parameter, get the template parameters from that context. */
+ else if (TYPE_CONTEXT (t)
+ && TREE_CODE (TYPE_CONTEXT (t)) == TEMPLATE_TYPE_PARM)
+ return TEMPLATE_TYPE_PARM_SIBLING_PARMS (TYPE_CONTEXT (t));
else if (TYPE_CONTEXT (t)
&& !NAMESPACE_SCOPE_P (t))
tinfo = get_template_info (TYPE_CONTEXT (t));
if (tinfo)
tparms = DECL_TEMPLATE_PARMS (TI_TEMPLATE (tinfo));
- /* If T is a template type parameter, get the template parameter
- set it is part of. */
- else if (TREE_CODE (t) == TEMPLATE_TYPE_PARM
- && DECL_CONTEXT (TYPE_NAME (t)))
- tparms = DECL_TEMPLATE_PARMS (DECL_CONTEXT (TYPE_NAME (t)));
- /* If T is a TYPENAME_TYPE which context is a template type
- parameter, get the template parameters from that context. */
- else if (TYPE_CONTEXT (t)
- && TREE_CODE (TYPE_CONTEXT (t)) == TEMPLATE_TYPE_PARM)
- tparms = get_template_parms_of_dependent_type (TYPE_CONTEXT (t));
return tparms;
}
tparms1 = get_template_parms_of_dependent_type (t1);
tparms2 = get_template_parms_of_dependent_type (t2);
+ /* If T2 is a template type parm and if we could not get the template
+ parms it belongs to, that means we have not finished parsing the
+ full set of template parameters of the template declaration it
+ belongs to yet. If we could get the template parms T1 belongs to,
+ that mostly means T1 and T2 belongs to templates that are
+ different and incompatible. */
+ if (TREE_CODE (t1) == TEMPLATE_TYPE_PARM
+ && (tparms1 == NULL_TREE || tparms2 == NULL_TREE)
+ && tparms1 != tparms2)
+ return true;
+
if (tparms1 == NULL_TREE
|| tparms2 == NULL_TREE
|| tparms1 == tparms2)
if (TYPE_FOR_JAVA (t1) != TYPE_FOR_JAVA (t2))
return false;
+ /* If T1 and T2 are dependent typedefs then check upfront that
+ the template parameters of their typedef DECLs match before
+ going down checking their subtypes. */
+ if (incompatible_dependent_types_p (t1, t2))
+ return false;
+
/* Allow for two different type nodes which have essentially the same
definition. Note that we already checked for equality of the type
qualifiers (just above). */
&& TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2))
return true;
- /* If T1 and T2 are dependent typedefs then check upfront that
- the template parameters of their typedef DECLs match before
- going down checking their subtypes. */
- if (incompatible_dependent_types_p (t1, t2))
- return false;
/* Compare the types. Break out if they could be the same. */
switch (TREE_CODE (t1))
return e;
}
+ /* To get the size of a static data member declared as an array of
+ unknown bound, we need to instantiate it. */
+ if (TREE_CODE (e) == VAR_DECL
+ && VAR_HAD_UNKNOWN_BOUND (e)
+ && DECL_TEMPLATE_INSTANTIATION (e))
+ instantiate_decl (e, /*defer_ok*/true, /*expl_inst_mem*/false);
+
if (TREE_CODE (e) == COMPONENT_REF
&& TREE_CODE (TREE_OPERAND (e, 1)) == FIELD_DECL
&& DECL_C_BIT_FIELD (TREE_OPERAND (e, 1)))
{
if (fndecl)
{
- error ("too many arguments to %s %q+#D",
- called_thing, fndecl);
- error ("at this point in file");
+ error_at (input_location, "too many arguments to %s %q#D",
+ called_thing, fndecl);
+ inform (DECL_SOURCE_LOCATION (fndecl),
+ "declared here");
}
else
error ("too many arguments to function");
{
if (fndecl)
{
- error ("too few arguments to %s %q+#D",
- called_thing, fndecl);
- error ("at this point in file");
+ error_at (input_location, "too few arguments to %s %q#D",
+ called_thing, fndecl);
+ inform (DECL_SOURCE_LOCATION (fndecl),
+ "declared here");
}
else
error ("too few arguments to function");
return error_mark_node;
}
+ if (TREE_CODE (type) == POINTER_TYPE
+ && TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE
+ /* Casting to an integer of smaller size is an error detected elsewhere. */
+ && TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (value))
+ /* Don't warn about converting any constant. */
+ && !TREE_CONSTANT (value))
+ warning_at (input_location, OPT_Wint_to_pointer_cast,
+ "cast to pointer from integer of different size");
+
/* A C-style cast can be a const_cast. */
result = build_const_cast_1 (type, value, /*complain=*/false,
&valid_p);