Commit f5fc32e4 by Paolo Carlini Committed by Paolo Carlini

init.c (build_new): Use cp_expr_loc_or_input_loc in two places.

/cp
2019-10-03  Paolo Carlini  <paolo.carlini@oracle.com>

	* init.c (build_new): Use cp_expr_loc_or_input_loc in two places.
	* name-lookup.c (do_pushdecl): Use DECL_SOURCE_LOCATION.
	(push_class_level_binding_1): Likewise.
	(set_decl_namespace): Likewise.

/testsuite
2019-10-03  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/diagnostic/integral-array-size-1.C: New.
	* g++.dg/cpp0x/alias-decl-1.C: Test location(s) too.
	* g++.dg/init/new43.C: Likewise.
	* g++.dg/lookup/friend12.C: Likewise.
	* g++.dg/lookup/pr79766.C: Likewise.
	* g++.dg/lookup/pr84375.C: Likewise.
	* g++.dg/other/new-size-type.C: Likewise.

From-SVN: r276496
parent 775eaa4d
2019-10-03 Paolo Carlini <paolo.carlini@oracle.com>
* init.c (build_new): Use cp_expr_loc_or_input_loc in two places.
* name-lookup.c (do_pushdecl): Use DECL_SOURCE_LOCATION.
(push_class_level_binding_1): Likewise.
(set_decl_namespace): Likewise.
2019-10-03 Jakub Jelinek <jakub@redhat.com>
* constexpr.c (cxx_eval_constant_expression) <case CLEANUP_STMT>: If
......
......@@ -3754,7 +3754,8 @@ build_new (vec<tree, va_gc> **placement, tree type, tree nelts,
if (!build_expr_type_conversion (WANT_INT | WANT_ENUM, nelts, false))
{
if (complain & tf_error)
permerror (input_location, "size in array new must have integral type");
permerror (cp_expr_loc_or_input_loc (nelts),
"size in array new must have integral type");
else
return error_mark_node;
}
......@@ -3769,7 +3770,8 @@ build_new (vec<tree, va_gc> **placement, tree type, tree nelts,
less than zero. ... If the expression is a constant expression,
the program is ill-fomed. */
if (TREE_CODE (cst_nelts) == INTEGER_CST
&& !valid_array_size_p (input_location, cst_nelts, NULL_TREE,
&& !valid_array_size_p (cp_expr_loc_or_input_loc (nelts),
cst_nelts, NULL_TREE,
complain & tf_error))
return error_mark_node;
......
......@@ -3080,8 +3080,9 @@ do_pushdecl (tree decl, bool is_friend)
/* In a local class, a friend function declaration must
find a matching decl in the innermost non-class scope.
[class.friend/11] */
error ("friend declaration %qD in local class without "
"prior local declaration", decl);
error_at (DECL_SOURCE_LOCATION (decl),
"friend declaration %qD in local class without "
"prior local declaration", decl);
/* Don't attempt to push it. */
return error_mark_node;
}
......@@ -4451,9 +4452,9 @@ push_class_level_binding_1 (tree name, tree x)
tree scope = context_for_name_lookup (x);
if (TYPE_P (scope) && same_type_p (scope, current_class_type))
{
error ("%qD has the same name as the class in which it is "
"declared",
x);
error_at (DECL_SOURCE_LOCATION (x),
"%qD has the same name as the class in which it is "
"declared", x);
return false;
}
}
......@@ -4757,7 +4758,8 @@ set_decl_namespace (tree decl, tree scope, bool friendp)
/* Writing "N::i" to declare something directly in "N" is invalid. */
if (CP_DECL_CONTEXT (decl) == current_namespace
&& at_namespace_scope_p ())
error ("explicit qualification in declaration of %qD", decl);
error_at (DECL_SOURCE_LOCATION (decl),
"explicit qualification in declaration of %qD", decl);
return;
}
......
2019-10-03 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/diagnostic/integral-array-size-1.C: New.
* g++.dg/cpp0x/alias-decl-1.C: Test location(s) too.
* g++.dg/init/new43.C: Likewise.
* g++.dg/lookup/friend12.C: Likewise.
* g++.dg/lookup/pr79766.C: Likewise.
* g++.dg/lookup/pr84375.C: Likewise.
* g++.dg/other/new-size-type.C: Likewise.
2019-10-03 Jakub Jelinek <jakub@redhat.com>
* g++.dg/ext/constexpr-attr-cleanup1.C: New test.
......
......@@ -12,5 +12,5 @@ template<class U> struct Ptr<U*> {}; // { dg-error "specialization" }
struct A {
using A = int; // { dg-error "11:ISO C\\+\\+ forbids nested type .A." }
// { dg-error "same name as" "" { target c++11 } .-1 }
// { dg-error "11:.using A = int. has the same name as" "" { target c++11 } .-1 }
};
template<typename T>
void foo(T a)
{
new int[a]; // { dg-error "11:size in array new must have integral type" }
}
template void foo(float);
......@@ -5,6 +5,6 @@ void foo()
extern void bar (int); // not the bar we are looking for
struct A
{
friend void bar(); // { dg-error "without prior local declaration" }
friend void bar(); // { dg-error "17:friend declaration .void bar\\(\\). in local class without prior local declaration" }
};
}
......@@ -24,6 +24,6 @@ void ::R () // OK -> Z::R
void S ();
void ::S () // { dg-error "explicit qualification" }
void ::S () // { dg-error "6:explicit qualification" }
{
}
......@@ -4,6 +4,6 @@ void foo()
{
struct A
{
friend void A(); // { dg-error "local class without prior local" }
friend void A(); // { dg-error "17:friend declaration .void A\\(\\). in local class without prior local" }
};
}
......@@ -5,5 +5,5 @@
const char*
foo()
{
return new char[~static_cast<size_t>(0)];// { dg-error "exceeds maximum object size" }
return new char[~static_cast<size_t>(0)];// { dg-error "21:exceeds maximum object size" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment