Hi, this one should be straightforward. Tested x86_64-linux.
Thanks, Paolo. /////////////////////////
/cp 2018-11-15 Paolo Carlini <paolo.carl...@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.carl...@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.
Index: cp/constexpr.c =================================================================== --- cp/constexpr.c (revision 266174) +++ cp/constexpr.c (working copy) @@ -98,8 +98,9 @@ ensure_literal_type_for_constexpr_object (tree dec 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 dec 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 dec 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; } } Index: testsuite/g++.dg/cpp0x/constexpr-diag3.C =================================================================== --- testsuite/g++.dg/cpp0x/constexpr-diag3.C (revision 266174) +++ testsuite/g++.dg/cpp0x/constexpr-diag3.C (working copy) @@ -24,7 +24,7 @@ struct complex // { dg-message "no .constexpr. 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 " } // -------------------- Index: testsuite/g++.dg/cpp0x/constexpr-ice19.C =================================================================== --- testsuite/g++.dg/cpp0x/constexpr-ice19.C (revision 266174) +++ testsuite/g++.dg/cpp0x/constexpr-ice19.C (working copy) @@ -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 } }; Index: testsuite/g++.dg/cpp0x/constexpr-nonlit2.C =================================================================== --- testsuite/g++.dg/cpp0x/constexpr-nonlit2.C (revision 266174) +++ testsuite/g++.dg/cpp0x/constexpr-nonlit2.C (working copy) @@ -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" } Index: testsuite/g++.dg/cpp1z/constexpr-lambda15.C =================================================================== --- testsuite/g++.dg/cpp1z/constexpr-lambda15.C (revision 266174) +++ testsuite/g++.dg/cpp1z/constexpr-lambda15.C (working copy) @@ -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() {} Index: testsuite/g++.dg/ext/constexpr-vla5.C =================================================================== --- testsuite/g++.dg/ext/constexpr-vla5.C (revision 266174) +++ testsuite/g++.dg/ext/constexpr-vla5.C (working copy) @@ -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 } } Index: testsuite/g++.dg/gomp/pr85134.C =================================================================== --- testsuite/g++.dg/gomp/pr85134.C (revision 266174) +++ testsuite/g++.dg/gomp/pr85134.C (working copy) @@ -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) ; }