P1064R0 - Allowing Virtual Function Calls in Constant Expressions
authorMarek Polacek <polacek@redhat.com>
Tue, 18 Sep 2018 19:16:28 +0000 (19:16 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Tue, 18 Sep 2018 19:16:28 +0000 (19:16 +0000)
commitbf8d83098ffafe1273b11eb5f4a596f96c90c42e
tree69c54203512e9f57ce7c3840298da4c7fe1adf99
parente8db6cd5fb1ad254329e426dcc8e958c02e2284f
P1064R0 - Allowing Virtual Function Calls in Constant Expressions

P1064R0 - Allowing Virtual Function Calls in Constant Expressions
* call.c (build_over_call): No longer check if we're outside a template
function.
* class.c (build_vtbl_initializer): Build vtable's constructor with
indexes.
* constexpr.c (cxx_eval_constant_expression): Don't ignore _vptr's
initializer.  Handle OBJ_TYPE_REF.
(potential_constant_expression_1): Handle OBJ_TYPE_REF.
* decl.c (maybe_commonize_var): Bail out for any DECL_ARTIFICIAL.
(initialize_artificial_var): Mark the variable as constexpr.
(grokdeclarator): Change error to pedwarn.  Only warn when
pedantic and not C++2a.

* gimple-fold.c (gimple_get_virt_method_for_vtable): Adjust assert.

* g++.dg/cpp0x/constexpr-virtual5.C: Adjust dg-error.
* g++.dg/cpp2a/constexpr-virtual1.C: New test.
* g++.dg/cpp2a/constexpr-virtual2.C: New test.
* g++.dg/cpp2a/constexpr-virtual3.C: New test.
* g++.dg/cpp2a/constexpr-virtual4.C: New test.
* g++.dg/cpp2a/constexpr-virtual5.C: New test.
* g++.dg/cpp2a/constexpr-virtual6.C: New test.
* g++.dg/cpp2a/constexpr-virtual7.C: New test.
* g++.dg/cpp2a/constexpr-virtual8.C: New test.
* g++.dg/cpp2a/constexpr-virtual9.C: New test.
* g++.dg/diagnostic/virtual-constexpr.C: Skip for C++2a.  Use
-pedantic-errors.  Adjust dg-error.

From-SVN: r264408
19 files changed:
gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/class.c
gcc/cp/constexpr.c
gcc/cp/decl.c
gcc/gimple-fold.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-virtual5.C
gcc/testsuite/g++.dg/cpp2a/constexpr-virtual1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/constexpr-virtual2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/constexpr-virtual3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/constexpr-virtual4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/constexpr-virtual5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/constexpr-virtual6.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/constexpr-virtual7.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/constexpr-virtual8.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/constexpr-virtual9.C [new file with mode: 0644]
gcc/testsuite/g++.dg/diagnostic/virtual-constexpr.C