aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-fold.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2018-09-18 19:16:28 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2018-09-18 19:16:28 +0000
commitbf8d83098ffafe1273b11eb5f4a596f96c90c42e (patch)
tree69c54203512e9f57ce7c3840298da4c7fe1adf99 /gcc/gimple-fold.c
parente8db6cd5fb1ad254329e426dcc8e958c02e2284f (diff)
downloadgcc-bf8d83098ffafe1273b11eb5f4a596f96c90c42e.zip
gcc-bf8d83098ffafe1273b11eb5f4a596f96c90c42e.tar.gz
gcc-bf8d83098ffafe1273b11eb5f4a596f96c90c42e.tar.bz2
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
Diffstat (limited to 'gcc/gimple-fold.c')
-rw-r--r--gcc/gimple-fold.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 362ab59..1e84722 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -6988,12 +6988,13 @@ gimple_get_virt_method_for_vtable (HOST_WIDE_INT token,
access_index = offset / BITS_PER_UNIT / elt_size;
gcc_checking_assert (offset % (elt_size * BITS_PER_UNIT) == 0);
- /* This code makes an assumption that there are no
- indexed fileds produced by C++ FE, so we can directly index the array. */
+ /* The C++ FE can now produce indexed fields, and we check if the indexes
+ match. */
if (access_index < CONSTRUCTOR_NELTS (init))
{
fn = CONSTRUCTOR_ELT (init, access_index)->value;
- gcc_checking_assert (!CONSTRUCTOR_ELT (init, access_index)->index);
+ tree idx = CONSTRUCTOR_ELT (init, access_index)->index;
+ gcc_checking_assert (!idx || tree_to_uhwi (idx) == access_index);
STRIP_NOPS (fn);
}
else