location_t location;
error ("label %q+D used but not defined", label);
- location = input_location; /* FIXME want (input_filename, (line)0) */
+ location = input_location;
+ /* FIXME want (LOCATION_FILE (input_location), (line)0) */
/* Avoid crashing later. */
define_label (location, DECL_NAME (label));
}
if (TREE_CODE (TREE_TYPE (newdecl)) == METHOD_TYPE)
t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2);
- for (; t1 && t1 != void_list_node;
- t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2), i++)
- if (TREE_PURPOSE (t1) && TREE_PURPOSE (t2))
- {
- if (1 == simple_cst_equal (TREE_PURPOSE (t1),
- TREE_PURPOSE (t2)))
+ if (TREE_CODE (TREE_TYPE (newdecl)) == METHOD_TYPE
+ && CLASSTYPE_TEMPLATE_INFO (CP_DECL_CONTEXT (newdecl)))
+ {
+ /* C++11 8.3.6/6.
+ Default arguments for a member function of a class template
+ shall be specified on the initial declaration of the member
+ function within the class template. */
+ for (; t2 && t2 != void_list_node; t2 = TREE_CHAIN (t2))
+ if (TREE_PURPOSE (t2))
{
- permerror (input_location, "default argument given for parameter %d of %q#D",
- i, newdecl);
- permerror (input_location, "after previous specification in %q+#D", olddecl);
+ permerror (input_location,
+ "redeclaration of %q#D may not have default "
+ "arguments", newdecl);
+ break;
}
- else
+ }
+ else
+ {
+ for (; t1 && t1 != void_list_node;
+ t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2), i++)
+ if (TREE_PURPOSE (t1) && TREE_PURPOSE (t2))
{
- error ("default argument given for parameter %d of %q#D",
- i, newdecl);
- error ("after previous specification in %q+#D",
- olddecl);
+ if (1 == simple_cst_equal (TREE_PURPOSE (t1),
+ TREE_PURPOSE (t2)))
+ {
+ permerror (input_location,
+ "default argument given for parameter %d "
+ "of %q#D", i, newdecl);
+ permerror (input_location,
+ "after previous specification in %q+#D",
+ olddecl);
+ }
+ else
+ {
+ error ("default argument given for parameter %d "
+ "of %q#D", i, newdecl);
+ error ("after previous specification in %q+#D",
+ olddecl);
+ }
}
- }
+ }
}
}
location_t switch_location;
/* Emit warnings as needed. */
- switch_location = EXPR_LOC_OR_HERE (cs->switch_stmt);
+ switch_location = EXPR_LOC_OR_LOC (cs->switch_stmt, input_location);
if (!processing_template_decl)
c_do_switch_warnings (cs->cases, switch_location,
SWITCH_STMT_TYPE (cs->switch_stmt),
error ("multiple types in one declaration");
else if (declspecs->redefined_builtin_type)
{
- if (!in_system_header)
+ if (!in_system_header_at (input_location))
permerror (declspecs->locations[ds_redefined_builtin_type_spec],
"redeclaration of C++ built-in type %qT",
declspecs->redefined_builtin_type);
/* Anonymous unions are objects, so they can have specifiers. */;
SET_ANON_AGGR_TYPE_P (declared_type);
- if (TREE_CODE (declared_type) != UNION_TYPE && !in_system_header)
+ if (TREE_CODE (declared_type) != UNION_TYPE
+ && !in_system_header_at (input_location))
pedwarn (input_location, OPT_Wpedantic, "ISO C++ prohibits anonymous structs");
}
/* We try to defer namespace-scope static constants so that they are
not emitted into the object file unnecessarily. */
- filename = input_filename;
+ filename = LOCATION_FILE (input_location);
if (!DECL_VIRTUAL_P (decl)
&& TREE_READONLY (decl)
&& DECL_INITIAL (decl) != NULL_TREE
indicated by the state of complain), so that
another substitution can be found. */
return error_mark_node;
- else if (in_system_header)
+ else if (in_system_header_at (input_location))
/* Allow them in system headers because glibc uses them. */;
else if (name)
pedwarn (input_location, OPT_Wpedantic, "ISO C++ forbids zero-size array %qD", name);
stabilize_vla_size (itype);
- if (cxx_dialect >= cxx1y)
+ if (cxx_dialect >= cxx1y && flag_exceptions)
{
/* If the VLA bound is larger than half the address space,
or less than zero, throw std::bad_array_length. */
LE_EXPR rather than LT_EXPR. */
tree t = fold_build2 (PLUS_EXPR, TREE_TYPE (itype), itype,
build_one_cst (TREE_TYPE (itype)));
- t = fold_build2 (COMPOUND_EXPR, TREE_TYPE (t),
- ubsan_instrument_vla (input_location, t), t);
+ t = ubsan_instrument_vla (input_location, t);
finish_expr_stmt (t);
}
}
if (type_was_error_mark_node)
/* We've already issued an error, don't complain more. */;
- else if (in_system_header || flag_ms_extensions)
+ else if (in_system_header_at (input_location) || flag_ms_extensions)
/* Allow it, sigh. */;
else if (! is_main)
permerror (input_location, "ISO C++ forbids declaration of %qs with no type", name);
error ("%<__int128%> is not supported by this target");
explicit_int128 = false;
}
- else if (pedantic && ! in_system_header)
+ else if (pedantic && ! in_system_header_at (input_location))
pedwarn (input_location, OPT_Wpedantic,
"ISO C++ does not support %<__int128%> for %qs", name);
}
if (decl_context != TYPENAME)
{
- /* A cv-qualifier-seq shall only be part of the function type
- for a non-static member function. A ref-qualifier shall only
- .... /same as above/ [dcl.fct] */
- if ((type_memfn_quals (type) != TYPE_UNQUALIFIED
- || type_memfn_rqual (type) != REF_QUAL_NONE)
- && (current_class_type == NULL_TREE || staticp) )
- {
- error (staticp
- ? G_("qualified function types cannot be used to "
- "declare static member functions")
- : G_("qualified function types cannot be used to "
- "declare free functions"));
- type = TYPE_MAIN_VARIANT (type);
- }
-
/* The qualifiers on the function type become the qualifiers on
the non-static member function. */
memfn_quals |= type_memfn_quals (type);
{
/* C++ allows static class members. All other work
for this is done by grokfield. */
- decl = build_lang_decl_loc (declarator->id_loc,
+ decl = build_lang_decl_loc (declarator
+ ? declarator->id_loc
+ : input_location,
VAR_DECL, unqualified_id, type);
set_linkage_for_static_data_member (decl);
/* Even if there is an in-class initialization, DECL