aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2016-01-19 14:02:40 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2016-01-19 14:02:40 +0000
commit1e2970064a996338c20f55b4b900ac678d0ceb94 (patch)
treedecf75e7e87bfbaae21783d477ba29dfa48b91bb /gcc/cp
parentc8012fbce973bebc5cf2a9905ebfa9fbaec1afa0 (diff)
downloadgcc-1e2970064a996338c20f55b4b900ac678d0ceb94.zip
gcc-1e2970064a996338c20f55b4b900ac678d0ceb94.tar.gz
gcc-1e2970064a996338c20f55b4b900ac678d0ceb94.tar.bz2
re PR c++/68586 (Enum template parameter wrongly rejected)
PR c++/68586 * constexpr.c (clear_cv_cache): New. * cp-gimplify.c (clear_fold_cache): New. * cp-tree.h (clear_cv_cache, clear_fold_cache): Declare. * decl.c (finish_enum_value_list): Call them. * g++.dg/cpp0x/enum30.C: New test. From-SVN: r232562
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/constexpr.c8
-rw-r--r--gcc/cp/cp-gimplify.c8
-rw-r--r--gcc/cp/cp-tree.h2
-rw-r--r--gcc/cp/decl.c5
5 files changed, 31 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 87b4cca..f9fce9d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2016-01-19 Marek Polacek <polacek@redhat.com>
+
+ PR c++/68586
+ * constexpr.c (clear_cv_cache): New.
+ * cp-gimplify.c (clear_fold_cache): New.
+ * cp-tree.h (clear_cv_cache, clear_fold_cache): Declare.
+ * decl.c (finish_enum_value_list): Call them.
+
2016-01-18 Patrick Palka <ppalka@gcc.gnu.org>
PR c++/11858
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 6ab4696..6b0e5a8 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -4027,6 +4027,14 @@ maybe_constant_value (tree t, tree decl)
return ret;
}
+/* Dispose of the whole CV_CACHE. */
+
+void
+clear_cv_cache (void)
+{
+ gt_cleare_cache (cv_cache);
+}
+
/* Like maybe_constant_value but first fully instantiate the argument.
Note: this is equivalent to instantiate_non_dependent_expr_sfinae
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 5c4d3c1..3f96901 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -1896,6 +1896,14 @@ c_fully_fold (tree x, bool /*in_init*/, bool */*maybe_const*/)
static GTY((cache, deletable)) cache_map fold_cache;
+/* Dispose of the whole FOLD_CACHE. */
+
+void
+clear_fold_cache (void)
+{
+ gt_cleare_cache (fold_cache);
+}
+
/* This function tries to fold an expression X.
To avoid combinatorial explosion, folding results are kept in fold_cache.
If we are processing a template or X is invalid, we don't fold at all.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index fc9507e..51589c3 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -6819,6 +6819,7 @@ extern bool cxx_omp_privatize_by_reference (const_tree);
extern bool cxx_omp_disregard_value_expr (tree, bool);
extern void cp_fold_function (tree);
extern tree cp_fully_fold (tree);
+extern void clear_fold_cache (void);
/* in name-lookup.c */
extern void suggest_alternatives_for (location_t, tree);
@@ -6919,6 +6920,7 @@ extern bool var_in_constexpr_fn (tree);
extern void explain_invalid_constexpr_fn (tree);
extern vec<tree> cx_error_context (void);
extern tree fold_sizeof_expr (tree);
+extern void clear_cv_cache (void);
/* In c-family/cilk.c */
extern bool cilk_valid_spawn (tree);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 187390d..ceeef60 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -13392,6 +13392,11 @@ finish_enum_value_list (tree enumtype)
/* Finish debugging output for this type. */
rest_of_type_compilation (enumtype, namespace_bindings_p ());
+
+ /* Each enumerator now has the type of its enumeration. Clear the cache
+ so that this change in types doesn't confuse us later on. */
+ clear_cv_cache ();
+ clear_fold_cache ();
}
/* Finishes the enum type. This is called only the first time an