aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2018-11-15 18:03:54 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2018-11-15 18:03:54 +0000
commitf2935576e990ec5e383138622515d393f7227500 (patch)
tree6985e4eb0695abf80facd9d4a827adbe790cf449
parent1ec7f4929a286da7aa03d413a0fe99c9c36be915 (diff)
downloadgcc-f2935576e990ec5e383138622515d393f7227500.zip
gcc-f2935576e990ec5e383138622515d393f7227500.tar.gz
gcc-f2935576e990ec5e383138622515d393f7227500.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/constexpr.c15
-rw-r--r--gcc/testsuite/ChangeLog9
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-diag3.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-ice19.C3
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-nonlit2.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/constexpr-lambda15.C2
-rw-r--r--gcc/testsuite/g++.dg/ext/constexpr-vla5.C3
-rw-r--r--gcc/testsuite/g++.dg/gomp/pr85134.C2
9 files changed, 31 insertions, 12 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index d6ee781..6d87c29 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+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
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index a50e186..c9e1e0c 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -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;
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2842a7b..24ea36e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+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
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-diag3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag3.C
index fc5a721..e54b26c7 100644
--- a/gcc/testsuite/g++.dg/cpp0x/constexpr-diag3.C
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag3.C
@@ -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 " }
// --------------------
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ice19.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ice19.C
index f62a0d9..6475c39 100644
--- a/gcc/testsuite/g++.dg/cpp0x/constexpr-ice19.C
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ice19.C
@@ -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 }
};
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-nonlit2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-nonlit2.C
index 2d712b6..0717f06 100644
--- a/gcc/testsuite/g++.dg/cpp0x/constexpr-nonlit2.C
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-nonlit2.C
@@ -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" }
diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda15.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda15.C
index 358d4aa..0420ebb 100644
--- a/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda15.C
+++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-lambda15.C
@@ -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() {}
diff --git a/gcc/testsuite/g++.dg/ext/constexpr-vla5.C b/gcc/testsuite/g++.dg/ext/constexpr-vla5.C
index 565d40a..5f19d3c 100644
--- a/gcc/testsuite/g++.dg/ext/constexpr-vla5.C
+++ b/gcc/testsuite/g++.dg/ext/constexpr-vla5.C
@@ -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 }
}
diff --git a/gcc/testsuite/g++.dg/gomp/pr85134.C b/gcc/testsuite/g++.dg/gomp/pr85134.C
index 9872ae5..01f5574 100644
--- a/gcc/testsuite/g++.dg/gomp/pr85134.C
+++ b/gcc/testsuite/g++.dg/gomp/pr85134.C
@@ -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)
;
}