Commit f2935576 by Paolo Carlini Committed by Paolo Carlini

constexpr.c (ensure_literal_type_for_constexpr_object): Use DECL_SOURCE_LOCATION in error_at calls.

/cp
2018-11-15  Paolo Carlini  <paolo.carlini@oracle.com>

	* constexpr.c (ensure_literal_type_for_constexpr_object): Use
	DECL_SOURCE_LOCATION in error_at calls.

/testsuite
2018-11-15  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/cpp0x/constexpr-diag3.C: Check locations too.
	* g++.dg/cpp0x/constexpr-ice19.C: Likewise.
	* g++.dg/cpp0x/constexpr-nonlit2.C: Likewise.
	* g++.dg/cpp1z/constexpr-lambda15.C: Likewise.
	* g++.dg/ext/constexpr-vla5.C: Likewise.
	* g++.dg/gomp/pr85134.C: Likewise.

From-SVN: r266192
parent 1ec7f492
2018-11-15 Paolo Carlini <paolo.carlini@oracle.com>
* constexpr.c (ensure_literal_type_for_constexpr_object): Use
DECL_SOURCE_LOCATION in error_at calls.
2018-11-15 Nathan Sidwell <nathan@acm.org>
DR 2336
......
......@@ -98,8 +98,9 @@ ensure_literal_type_for_constexpr_object (tree decl)
if (DECL_DECLARED_CONSTEXPR_P (decl))
{
auto_diagnostic_group d;
error ("the type %qT of %<constexpr%> variable %qD "
"is not literal", type, decl);
error_at (DECL_SOURCE_LOCATION (decl),
"the type %qT of %<constexpr%> variable %qD "
"is not literal", type, decl);
explain_non_literal_class (type);
decl = error_mark_node;
}
......@@ -108,8 +109,9 @@ ensure_literal_type_for_constexpr_object (tree decl)
if (!is_instantiation_of_constexpr (current_function_decl))
{
auto_diagnostic_group d;
error ("variable %qD of non-literal type %qT in %<constexpr%> "
"function", decl, type);
error_at (DECL_SOURCE_LOCATION (decl),
"variable %qD of non-literal type %qT in "
"%<constexpr%> function", decl, type);
explain_non_literal_class (type);
decl = error_mark_node;
}
......@@ -119,8 +121,9 @@ ensure_literal_type_for_constexpr_object (tree decl)
else if (DECL_DECLARED_CONSTEXPR_P (decl)
&& variably_modified_type_p (type, NULL_TREE))
{
error ("%<constexpr%> variable %qD has variably-modified type %qT",
decl, type);
error_at (DECL_SOURCE_LOCATION (decl),
"%<constexpr%> variable %qD has variably-modified "
"type %qT", decl, type);
decl = error_mark_node;
}
}
......
2018-11-15 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/cpp0x/constexpr-diag3.C: Check locations too.
* g++.dg/cpp0x/constexpr-ice19.C: Likewise.
* g++.dg/cpp0x/constexpr-nonlit2.C: Likewise.
* g++.dg/cpp1z/constexpr-lambda15.C: Likewise.
* g++.dg/ext/constexpr-vla5.C: Likewise.
* g++.dg/gomp/pr85134.C: Likewise.
2018-11-15 Nathan Sidwell <nathan@acm.org>
DR 2336
......
......@@ -24,7 +24,7 @@ private:
double im;
};
constexpr complex co1(0, 1); // { dg-error "not literal" }
constexpr complex co1(0, 1); // { dg-error "19:the type .const complex. of .constexpr. variable .co1. is not literal" }
constexpr double dd2 = co1.real(); // { dg-error "|in .constexpr. expansion of " }
// --------------------
......
......@@ -9,5 +9,6 @@ struct A
struct B
{
static constexpr A a {}; // { dg-error "not literal|in-class initialization" }
static constexpr A a {}; // { dg-error "22:the type .const A. of .constexpr. variable .B::a. is not literal" }
// { dg-error "in-class initialization" "" { target c++11 } .-1 }
};
......@@ -16,4 +16,4 @@ template <class T>
constexpr W<T> make_w(T& w) { return W<T>(w); }
A a;
constexpr auto w = make_w(a); // { dg-error "" }
constexpr auto w = make_w(a); // { dg-error "16:the type .const W<A>. of .constexpr. variable .w. is not literal" }
......@@ -3,7 +3,7 @@
struct S {
constexpr S(int i) {
auto f = [i]{}; // { dg-error "literal" "" { target c++14_only } }
auto f = [i]{}; // { dg-error "10:variable .f. of non-literal type" "" { target c++14_only } }
}
};
int main() {}
......
......@@ -3,5 +3,6 @@
void foo(int i)
{
constexpr char x[i] = ""; // { dg-error "" }
constexpr char x[i] = ""; // { dg-error "18:.constexpr. variable .x. has variably-modified type" }
// { dg-error "ISO C\\+\\+ forbids variable length array .x" "" { target c++11 } .-1 }
}
......@@ -5,7 +5,7 @@
void
foo (int i)
{
constexpr int x[i] = {}; // { dg-error "'constexpr' variable 'x' has variably-modified type" }
constexpr int x[i] = {}; // { dg-error "17:'constexpr' variable 'x' has variably-modified type" }
#pragma omp parallel shared(x)
;
}
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