From: Paolo Carlini Date: Thu, 15 Nov 2018 18:03:54 +0000 (+0000) Subject: constexpr.c (ensure_literal_type_for_constexpr_object): Use DECL_SOURCE_LOCATION... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f2935576e990ec5e383138622515d393f7227500;p=gcc.git constexpr.c (ensure_literal_type_for_constexpr_object): Use DECL_SOURCE_LOCATION in error_at calls. /cp 2018-11-15 Paolo Carlini * constexpr.c (ensure_literal_type_for_constexpr_object): Use DECL_SOURCE_LOCATION in error_at calls. /testsuite 2018-11-15 Paolo Carlini * 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d6ee781d730..6d87c293dd6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-11-15 Paolo Carlini + + * constexpr.c (ensure_literal_type_for_constexpr_object): Use + DECL_SOURCE_LOCATION in error_at calls. + 2018-11-15 Nathan Sidwell DR 2336 diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index a50e186148d..c9e1e0cbdcb 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 % variable %qD " - "is not literal", type, decl); + error_at (DECL_SOURCE_LOCATION (decl), + "the type %qT of % 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 % " - "function", decl, type); + error_at (DECL_SOURCE_LOCATION (decl), + "variable %qD of non-literal type %qT in " + "% 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 ("% variable %qD has variably-modified type %qT", - decl, type); + error_at (DECL_SOURCE_LOCATION (decl), + "% variable %qD has variably-modified " + "type %qT", decl, type); decl = error_mark_node; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2842a7b2b89..24ea36ec912 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2018-11-15 Paolo Carlini + + * 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 DR 2336 diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-diag3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag3.C index fc5a7210853..e54b26c7f6a 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 f62a0d995c2..6475c39b806 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 2d712b64a52..0717f06a977 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-nonlit2.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-nonlit2.C @@ -16,4 +16,4 @@ template constexpr W make_w(T& w) { return W(w); } A a; -constexpr auto w = make_w(a); // { dg-error "" } +constexpr auto w = make_w(a); // { dg-error "16:the type .const W. 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 358d4aaed8f..0420ebb2531 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 565d40ab077..5f19d3c4fd7 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 9872ae53a92..01f5574fcc7 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) ; }