/* Call-backs for C++ error reporting.
This code is non-reentrant.
- Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003,
- 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
- Free Software Foundation, Inc.
+ Copyright (C) 1993-2013 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
static void dump_expr_list (tree, int);
static void dump_global_iord (tree);
static void dump_parameters (tree, int);
+static void dump_ref_qualifier (tree, int);
static void dump_exception_spec (tree, int);
static void dump_template_argument (tree, int);
static void dump_template_argument_list (tree, int);
static void dump_template_parameter (tree, int);
-static void dump_template_bindings (tree, tree, VEC(tree,gc) *);
+static void dump_template_bindings (tree, tree, vec<tree, va_gc> *);
static void dump_scope (tree, int);
static void dump_template_parms (tree, int, int);
static int get_non_default_template_args_count (tree, int);
TREE_VEC. */
static void
-dump_template_bindings (tree parms, tree args, VEC(tree,gc)* typenames)
+dump_template_bindings (tree parms, tree args, vec<tree, va_gc> *typenames)
{
bool need_semicolon = false;
int i;
}
/* Don't bother with typenames for a partial instantiation. */
- if (VEC_empty (tree, typenames) || uses_template_parms (args))
+ if (vec_safe_is_empty (typenames) || uses_template_parms (args))
return;
- FOR_EACH_VEC_ELT (tree, typenames, i, t)
+ FOR_EACH_VEC_SAFE_ELT (typenames, i, t)
{
if (need_semicolon)
pp_separate_with_semicolon (cxx_pp);
else
pp_printf (pp_base (cxx_pp), M_("<anonymous %s>"), variety);
}
- else if (LAMBDANAME_P (name))
+ else if (LAMBDA_TYPE_P (name))
{
/* A lambda's "type" is essentially its signature. */
pp_string (cxx_pp, M_("<lambda"));
pp_cxx_cv_qualifier_seq (cxx_pp, class_of_this_parm (t));
else
pp_cxx_cv_qualifier_seq (cxx_pp, t);
+ dump_ref_qualifier (t, flags);
dump_exception_spec (TYPE_RAISES_EXCEPTIONS (t), flags);
dump_type_suffix (TREE_TYPE (t), flags);
break;
{
tree dtype = TYPE_DOMAIN (t);
tree max = TYPE_MAX_VALUE (dtype);
- if (host_integerp (max, 0))
+ if (integer_all_onesp (max))
+ pp_character (cxx_pp, '0');
+ else if (host_integerp (max, 0))
pp_wide_integer (cxx_pp, tree_low_cst (max, 0) + 1);
else if (TREE_CODE (max) == MINUS_EXPR)
dump_expr (TREE_OPERAND (max, 0),
dump_scope (CP_DECL_CONTEXT (t), flags);
flags &= ~TFF_UNQUALIFIED_NAME;
if (DECL_NAME (t) == NULL_TREE)
- pp_cxx_ws_string (cxx_pp, M_("{anonymous}"));
+ {
+ if (!(pp_c_base (cxx_pp)->flags & pp_c_flag_gnu_v3))
+ pp_cxx_ws_string (cxx_pp, M_("{anonymous}"));
+ else
+ pp_cxx_ws_string (cxx_pp, M_("(anonymous namespace)"));
+ }
else
pp_cxx_tree_identifier (cxx_pp, DECL_NAME (t));
}
case SCOPE_REF:
dump_type (TREE_OPERAND (t, 0), flags);
pp_string (cxx_pp, "::");
- dump_decl (TREE_OPERAND (t, 1), flags|TFF_UNQUALIFIED_NAME);
+ dump_decl (TREE_OPERAND (t, 1), TFF_UNQUALIFIED_NAME);
break;
case ARRAY_REF:
}
/* find_typenames looks through the type of the function template T
- and returns a VEC containing any typedefs, decltypes or TYPENAME_TYPEs
+ and returns a vec containing any typedefs, decltypes or TYPENAME_TYPEs
it finds. */
struct find_typenames_t
{
struct pointer_set_t *p_set;
- VEC (tree,gc) *typenames;
+ vec<tree, va_gc> *typenames;
};
static tree
-find_typenames_r (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED, void *data)
+find_typenames_r (tree *tp, int *walk_subtrees, void *data)
{
struct find_typenames_t *d = (struct find_typenames_t *)data;
tree mv = NULL_TREE;
/* Add the typename without any cv-qualifiers. */
mv = TYPE_MAIN_VARIANT (*tp);
+ if (TREE_CODE (*tp) == TYPE_PACK_EXPANSION)
+ {
+ /* Don't mess with parameter packs since we don't remember
+ the pack expansion context for a particular typename. */
+ *walk_subtrees = false;
+ return NULL_TREE;
+ }
+
if (mv && (mv == *tp || !pointer_set_insert (d->p_set, mv)))
- VEC_safe_push (tree, gc, d->typenames, mv);
+ vec_safe_push (d->typenames, mv);
/* Search into class template arguments, which cp_walk_subtrees
doesn't do. */
return NULL_TREE;
}
-static VEC(tree,gc) *
+static vec<tree, va_gc> *
find_typenames (tree t)
{
struct find_typenames_t ft;
int show_return = flags & TFF_RETURN_TYPE || flags & TFF_DECL_SPECIFIERS;
int do_outer_scope = ! (flags & TFF_UNQUALIFIED_NAME);
tree exceptions;
- VEC(tree,gc) *typenames = NULL;
+ vec<tree, va_gc> *typenames = NULL;
if (DECL_NAME (t) && LAMBDA_FUNCTION_P (t))
{
return;
}
- flags &= ~TFF_UNQUALIFIED_NAME;
+ flags &= ~(TFF_UNQUALIFIED_NAME | TFF_TEMPLATE_NAME);
if (TREE_CODE (t) == TEMPLATE_DECL)
t = DECL_TEMPLATE_RESULT (t);
{
pp_base (cxx_pp)->padding = pp_before;
pp_cxx_cv_qualifier_seq (cxx_pp, class_of_this_parm (fntype));
+ dump_ref_qualifier (fntype, flags);
}
if (flags & TFF_EXCEPTION_SPECIFICATION)
pp_cxx_right_paren (cxx_pp);
}
+/* Print ref-qualifier of a FUNCTION_TYPE or METHOD_TYPE. FLAGS are ignored. */
+
+static void
+dump_ref_qualifier (tree t, int flags ATTRIBUTE_UNUSED)
+{
+ if (FUNCTION_REF_QUALIFIED (t))
+ {
+ pp_base (cxx_pp)->padding = pp_before;
+ if (FUNCTION_RVALUE_QUALIFIED (t))
+ pp_cxx_ws_string (cxx_pp, "&&");
+ else
+ pp_cxx_ws_string (cxx_pp, "&");
+ }
+}
+
/* Print an exception specification. T is the exception specification. */
static void
{
if (LAMBDA_TYPE_P (DECL_CONTEXT (t)))
name = get_identifier ("<lambda>");
+ else if (TYPE_ANONYMOUS_P (DECL_CONTEXT (t)))
+ name = get_identifier ("<constructor>");
else
name = constructor_name (DECL_CONTEXT (t));
}
/* Print out a vector of initializers (subr of dump_expr). */
static void
-dump_expr_init_vec (VEC(constructor_elt,gc) *v, int flags)
+dump_expr_init_vec (vec<constructor_elt, va_gc> *v, int flags)
{
unsigned HOST_WIDE_INT idx;
tree value;
FOR_EACH_CONSTRUCTOR_VALUE (v, idx, value)
{
dump_expr (value, flags | TFF_EXPR_IN_PARENS);
- if (idx != VEC_length (constructor_elt, v) - 1)
+ if (idx != v->length () - 1)
pp_separate_with_comma (cxx_pp);
}
}
break;
case SSA_NAME:
- if (!DECL_ARTIFICIAL (SSA_NAME_VAR (t)))
+ if (SSA_NAME_VAR (t)
+ && !DECL_ARTIFICIAL (SSA_NAME_VAR (t)))
dump_expr (SSA_NAME_VAR (t), flags);
else
pp_cxx_ws_string (cxx_pp, M_("<unknown>"));
}
pp_cxx_whitespace (cxx_pp);
pp_cxx_left_paren (cxx_pp);
- if (TYPE_P (TREE_OPERAND (t, 0)))
+ if (TREE_CODE (t) == SIZEOF_EXPR && SIZEOF_EXPR_TYPE_P (t))
+ dump_type (TREE_TYPE (TREE_OPERAND (t, 0)), flags);
+ else if (TYPE_P (TREE_OPERAND (t, 0)))
dump_type (TREE_OPERAND (t, 0), flags);
else
dump_expr (TREE_OPERAND (t, 0), flags);
dump_expr (resolve_virtual_fun_from_obj_type_ref (t), flags);
break;
+ case LAMBDA_EXPR:
+ pp_string (cxx_pp, M_("<lambda>"));
+ break;
+
/* This list is incomplete, but should suffice for now.
It is very important that `sorry' does not call
`report_error_function'. That could cause an infinite loop. */
return pp_formatted_text (cxx_pp);
}
+/* Wrap decl_as_string with options appropriate for dwarf. */
+
+const char *
+decl_as_dwarf_string (tree decl, int flags)
+{
+ const char *name;
+ /* Curiously, reinit_cxx_pp doesn't reset the flags field, so setting the flag
+ here will be adequate to get the desired behaviour. */
+ pp_c_base (cxx_pp)->flags |= pp_c_flag_gnu_v3;
+ name = decl_as_string (decl, flags);
+ /* Subsequent calls to the pretty printer shouldn't use this style. */
+ pp_c_base (cxx_pp)->flags &= ~pp_c_flag_gnu_v3;
+ return name;
+}
+
const char *
decl_as_string (tree decl, int flags)
{
return pp_formatted_text (cxx_pp);
}
+/* Wrap lang_decl_name with options appropriate for dwarf. */
+
+const char *
+lang_decl_dwarf_name (tree decl, int v, bool translate)
+{
+ const char *name;
+ /* Curiously, reinit_cxx_pp doesn't reset the flags field, so setting the flag
+ here will be adequate to get the desired behaviour. */
+ pp_c_base (cxx_pp)->flags |= pp_c_flag_gnu_v3;
+ name = lang_decl_name (decl, v, translate);
+ /* Subsequent calls to the pretty printer shouldn't use this style. */
+ pp_c_base (cxx_pp)->flags &= ~pp_c_flag_gnu_v3;
+ return name;
+}
+
/* Generate the three forms of printable names for cxx_printable_name. */
const char *
if (TREE_CODE (decl) == FUNCTION_DECL)
dump_function_name (decl, TFF_PLAIN_IDENTIFIER);
+ else if ((DECL_NAME (decl) == NULL_TREE)
+ && TREE_CODE (decl) == NAMESPACE_DECL)
+ dump_decl (decl, TFF_PLAIN_IDENTIFIER | TFF_UNQUALIFIED_NAME);
else
dump_decl (DECL_NAME (decl), TFF_PLAIN_IDENTIFIER);
t = t0;
- if (n_total >= 12)
+ if (template_backtrace_limit
+ && n_total > template_backtrace_limit)
{
- int skip = n_total - 10;
- for (n = 0; n < 5; n++)
+ int skip = n_total - template_backtrace_limit;
+ int head = template_backtrace_limit / 2;
+
+ /* Avoid skipping just 1. If so, skip 2. */
+ if (skip == 1)
+ {
+ skip = 2;
+ head = (template_backtrace_limit - 1) / 2;
+ }
+
+ for (n = 0; n < head; n++)
{
gcc_assert (t != NULL);
if (loc != t->locus)
loc = t->locus;
t = t->next;
}
- if (t != NULL && skip > 1)
+ if (t != NULL && skip > 0)
{
expanded_location xloc;
xloc = expand_location (loc);
if (context->show_column)
pp_verbatim (context->printer,
- _("%s:%d:%d: [ skipping %d instantiation contexts ]\n"),
+ _("%s:%d:%d: [ skipping %d instantiation contexts, "
+ "use -ftemplate-backtrace-limit=0 to disable ]\n"),
xloc.file, xloc.line, xloc.column, skip);
else
pp_verbatim (context->printer,
- _("%s:%d: [ skipping %d instantiation contexts ]\n"),
+ _("%s:%d: [ skipping %d instantiation contexts, "
+ "use -ftemplate-backtrace-limit=0 to disable ]\n"),
xloc.file, xloc.line, skip);
do {
{
print_instantiation_partial_context
(global_dc, current_instantiation (), input_location);
+ pp_base_newline (global_dc->printer);
diagnostic_flush_buffer (global_dc);
}
\f
void
maybe_print_constexpr_context (diagnostic_context *context)
{
- VEC(tree,heap) *call_stack = cx_error_context ();
+ vec<tree> call_stack = cx_error_context ();
unsigned ix;
tree t;
- FOR_EACH_VEC_ELT (tree, call_stack, ix, t)
+ FOR_EACH_VEC_ELT (call_stack, ix, t)
{
expanded_location xloc = expand_location (EXPR_LOCATION (t));
const char *s = expr_as_string (t, 0);
break;
case CPP0X_AUTO:
pedwarn (input_location, 0,
- "C++0x auto only available with -std=c++11 or -std=gnu++11");
+ "C++11 auto only available with -std=c++11 or -std=gnu++11");
break;
case CPP0X_SCOPED_ENUMS:
pedwarn (input_location, 0,
"only available with -std=c++11 or -std=gnu++11");
break;
case CPP0X_INLINE_NAMESPACES:
- pedwarn (input_location, OPT_pedantic,
+ pedwarn (input_location, OPT_Wpedantic,
"inline namespaces "
"only available with -std=c++11 or -std=gnu++11");
break;
"delegating constructors "
"only available with -std=c++11 or -std=gnu++11");
break;
+ case CPP0X_INHERITING_CTORS:
+ pedwarn (input_location, 0,
+ "inheriting constructors "
+ "only available with -std=c++11 or -std=gnu++11");
+ break;
+ case CPP0X_ATTRIBUTES:
+ pedwarn (input_location, 0,
+ "c++11 attributes "
+ "only available with -std=c++11 or -std=gnu++11");
+ break;
+ case CPP0X_REF_QUALIFIER:
+ pedwarn (input_location, 0,
+ "ref-qualifiers "
+ "only available with -std=c++11 or -std=gnu++11");
+ break;
default:
gcc_unreachable ();
}
{
diagnostic_info diagnostic;
va_list ap;
+ bool ret;
va_start (ap, gmsgid);
diagnostic_set_info (&diagnostic, gmsgid, &ap, location,
(cxx_dialect == cxx98) ? DK_PEDWARN : DK_WARNING);
diagnostic.option_index = opt;
+ ret = report_diagnostic (&diagnostic);
va_end (ap);
- return report_diagnostic (&diagnostic);
+ return ret;
}
/* Issue a diagnostic that NAME cannot be found in SCOPE. DECL is what