diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-06-17 20:01:46 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-06-17 20:01:46 +0000 |
commit | 98683d85d94c1382b91b56f17c5f2a36bbfc3908 (patch) | |
tree | 81fe3c5382f90ca9d828af92253a0a05f55ef1c9 | |
parent | 0e6099f1aeabec3850f05942d6b58486ea6b1666 (diff) | |
download | gcc-98683d85d94c1382b91b56f17c5f2a36bbfc3908.tar.gz |
/cp
2016-06-17 Paolo Carlini <paolo.carlini@oracle.com>
* decl.c (validate_constexpr_redeclaration): Change pair of errors
to error + inform.
* error.c (dump_function_decl): Save the constexpr specifier too.
/testsuite
2016-06-17 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/cpp0x/constexpr-specialization.C: Adjust for dg-message
vs dg-error; test constexpr specifier too.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@237564 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 7 | ||||
-rw-r--r-- | gcc/cp/error.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/constexpr-specialization.C | 8 |
5 files changed, 25 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 166ec2d6f03..8ff9630e866 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2016-06-17 Paolo Carlini <paolo.carlini@oracle.com> + + * decl.c (validate_constexpr_redeclaration): Change pair of errors + to error + inform. + * error.c (dump_function_decl): Save the constexpr specifier too. + 2016-06-17 Jakub Jelinek <jakub@redhat.com> * tree.c (builtin_valid_in_constant_expr_p): Test for diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 59abd15cf29..c86a131d489 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1281,8 +1281,11 @@ validate_constexpr_redeclaration (tree old_decl, tree new_decl) && DECL_TEMPLATE_SPECIALIZATION (new_decl)) return true; - error ("redeclaration %q+D differs in %<constexpr%>", new_decl); - error ("from previous declaration %q+D", old_decl); + error_at (DECL_SOURCE_LOCATION (new_decl), + "redeclaration %qD differs in %<constexpr%> " + "from previous declaration", new_decl); + inform (DECL_SOURCE_LOCATION (old_decl), + "previous declaration %qD", old_decl); return false; } return true; diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 7d70f892b3c..d5a7d0f9efd 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1486,6 +1486,7 @@ dump_function_decl (cxx_pretty_printer *pp, tree t, int flags) int show_return = flags & TFF_RETURN_TYPE || flags & TFF_DECL_SPECIFIERS; int do_outer_scope = ! (flags & TFF_UNQUALIFIED_NAME); tree exceptions; + bool constexpr_p; flags &= ~(TFF_UNQUALIFIED_NAME | TFF_TEMPLATE_NAME); if (TREE_CODE (t) == TEMPLATE_DECL) @@ -1495,6 +1496,9 @@ dump_function_decl (cxx_pretty_printer *pp, tree t, int flags) emitting an error about incompatible specifications. */ exceptions = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (t)); + /* Likewise for the constexpr specifier, in case t is a specialization. */ + constexpr_p = DECL_DECLARED_CONSTEXPR_P (t); + /* Pretty print template instantiations only. */ if (DECL_USE_TEMPLATE (t) && DECL_TEMPLATE_INFO (t) && flag_pretty_templates) @@ -1529,7 +1533,7 @@ dump_function_decl (cxx_pretty_printer *pp, tree t, int flags) else if (DECL_VIRTUAL_P (t)) pp_cxx_ws_string (pp, "virtual"); - if (DECL_DECLARED_CONSTEXPR_P (t)) + if (constexpr_p) pp_cxx_ws_string (pp, "constexpr"); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cb950cd5c5f..e717ea0851b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2016-06-17 Paolo Carlini <paolo.carlini@oracle.com> + * g++.dg/cpp0x/constexpr-specialization.C: Adjust for dg-message + vs dg-error; test constexpr specifier too. + +2016-06-17 Paolo Carlini <paolo.carlini@oracle.com> + * g++.dg/cpp0x/defaulted31.C: Adjust for dg-message vs dg-error. 2016-06-17 Christophe Lyon <christophe.lyon@linaro.org> diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-specialization.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-specialization.C index 80f56a19615..64d8f4ec266 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-specialization.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-specialization.C @@ -3,10 +3,10 @@ template<typename T> constexpr int foo(T); template<> int foo(int); -template<> int foo(int); // { dg-error "previous" } -template<> constexpr int foo(int); // { dg-error "redeclaration" } +template<> int foo(int); // { dg-message "previous declaration 'int foo" } +template<> constexpr int foo(int); // { dg-error "redeclaration 'constexpr int foo" } template<typename T> int bar(T); template<> constexpr int bar(int); -template<> constexpr int bar(int); // { dg-error "previous" } -template<> int bar(int); // { dg-error "redeclaration" } +template<> constexpr int bar(int); // { dg-message "previous declaration 'constexpr int bar" } +template<> int bar(int); // { dg-error "redeclaration 'int bar" } |