{
case tbr_ambiguous_baseclass:
inform (input_location, " %qT is an ambiguous base class of %qT",
- arg, parm);
+ parm, arg);
break;
default:
inform (input_location, " %qT is not derived from %qT", arg, parm);
if (CLASS_TYPE_P (template_type) && is_dependent_type)
/* If the type makes use of template parameters, the
code that generates debugging information will crash. */
- DECL_IGNORED_P (TYPE_STUB_DECL (t)) = 1;
+ DECL_IGNORED_P (TYPE_MAIN_DECL (t)) = 1;
/* Possibly limit visibility based on template args. */
TREE_PUBLIC (type_decl) = 1;
else if (TREE_CODE (r) == FIELD_DECL)
{
/* Determine whether R has a valid type and can be
- completed later. If R is invalid, then it is
- replaced by error_mark_node so that it will not be
- added to TYPE_FIELDS. */
+ completed later. If R is invalid, then its type is
+ replaced by error_mark_node. */
tree rtype = TREE_TYPE (r);
if (can_complete_type_without_circularity (rtype))
complete_type (rtype);
if (!COMPLETE_TYPE_P (rtype))
{
cxx_incomplete_type_error (r, rtype);
- r = error_mark_node;
+ TREE_TYPE (r) = error_mark_node;
}
}
int arg_pack_len,
bool has_empty_arg)
{
+ /* If one pack has an expansion and another pack has a normal
+ argument or if one pack has an empty argument and an another
+ one hasn't then tsubst_pack_expansion cannot perform the
+ substitution and need to fall back on the
+ PACK_EXPANSION_EXTRA mechanism. */
if (parm_packs == NULL_TREE)
return false;
+ else if (has_empty_arg)
+ return true;
bool has_expansion_arg = false;
for (int i = 0 ; i < arg_pack_len; ++i)
has_non_expansion_arg = true;
}
- /* If one pack has an expansion and another pack has a normal
- argument or if one pack has an empty argument another one
- hasn't then tsubst_pack_expansion cannot perform the
- substitution and need to fall back on the
- PACK_EXPANSION_EXTRA mechanism. */
- if ((has_expansion_arg && has_non_expansion_arg)
- || (has_empty_arg && (has_expansion_arg || has_non_expansion_arg)))
+ if (has_expansion_arg && has_non_expansion_arg)
return true;
}
return false;
/* We don't have to set DECL_CONTEXT here; it is set by
finish_member_declaration. */
DECL_CHAIN (r) = NULL_TREE;
- if (VOID_TYPE_P (type))
- error ("instantiation of %q+D as type %qT", r, type);
apply_late_template_attributes (&r, DECL_ATTRIBUTES (r), 0,
args, complain, in_decl);
newlen = vec_safe_length (n);
FOR_EACH_VEC_SAFE_ELT (n, idx, ce)
{
- if (ce->index && process_index_p)
+ if (ce->index && process_index_p
+ /* An identifier index is looked up in the type
+ being initialized, not the current scope. */
+ && TREE_CODE (ce->index) != IDENTIFIER_NODE)
ce->index = RECUR (ce->index);
if (PACK_EXPANSION_P (ce->value))
later. */
return unify_success (explain_p);
else
- return unify_type_mismatch (explain_p, tparm, arg);
+ return unify_type_mismatch (explain_p, tparm, TREE_TYPE (arg));
/* If ARG is a parameter pack or an expansion, we cannot unify
against it unless PARM is also a parameter pack. */
if (TREE_ASM_WRITTEN (result))
return;
+ /* For anonymous namespace we don't need to do anything. */
+ if (decl_anon_ns_mem_p (result))
+ {
+ gcc_assert (!TREE_PUBLIC (result));
+ return;
+ }
+
if (TREE_CODE (result) != FUNCTION_DECL)
/* The TREE_PUBLIC flag for function declarations will have been
set correctly by tsubst. */
&& VAR_HAD_UNKNOWN_BOUND (expression))
return true;
+ /* An array of unknown bound depending on a variadic parameter, eg:
+
+ template<typename... Args>
+ void foo (Args... args)
+ {
+ int arr[] = { args... };
+ }
+
+ template<int... vals>
+ void bar ()
+ {
+ int arr[] = { vals... };
+ }
+
+ If the array has no length and has an initializer, it must be that
+ we couldn't determine its length in cp_complete_array_type because
+ it is dependent. */
+ if (VAR_P (expression)
+ && TREE_CODE (TREE_TYPE (expression)) == ARRAY_TYPE
+ && !TYPE_DOMAIN (TREE_TYPE (expression))
+ && DECL_INITIAL (expression))
+ return true;
+
if (TREE_TYPE (expression) == unknown_type_node)
{
if (TREE_CODE (expression) == ADDR_EXPR)
case TRAIT_EXPR:
if (dependent_type_p (TRAIT_EXPR_TYPE1 (*tp))
- || dependent_type_p (TRAIT_EXPR_TYPE2 (*tp)))
+ || (TRAIT_EXPR_TYPE2 (*tp)
+ && dependent_type_p (TRAIT_EXPR_TYPE2 (*tp))))
return *tp;
*walk_subtrees = false;
return NULL_TREE;
if (error_operand_p (arg))
return true;
- else if (TREE_CODE (arg) == TEMPLATE_DECL
- || TREE_CODE (arg) == TEMPLATE_TEMPLATE_PARM)
+ else if (TREE_CODE (arg) == TEMPLATE_DECL)
continue;
else if (TYPE_P (arg) && TYPE_STRUCTURAL_EQUALITY_P (arg))
return true;