]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/68586 (Enum template parameter wrongly rejected)
authorMarek Polacek <polacek@redhat.com>
Tue, 19 Jan 2016 14:02:40 +0000 (14:02 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Tue, 19 Jan 2016 14:02:40 +0000 (14:02 +0000)
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

gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/cp/cp-gimplify.c
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/enum30.C [new file with mode: 0644]

index 87b4cca8468986ef8a8bb58d72b1e54a1fc5d9e5..f9fce9d0e4fe4a5dcb845bd0e2129bee1c37244e 100644 (file)
@@ -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
index 6ab4696d6f368c83f92c2190c945b9608fe9b16e..6b0e5a8717f456fae51658bd357291521455de59 100644 (file)
@@ -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
index 5c4d3c1bb1f8851d7e5f39f23d254d6f04035239..3f96901583037d1a0f0dd4a7ecab33afee72c213 100644 (file)
@@ -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.
index fc9507e2331f74e40dfe647de5272e9fba377ae5..51589c3311b9ba8d038a59e6a47ac70d76056e08 100644 (file)
@@ -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);
index 187390d2359fab199c7b8217519a4cb2b35695d5..ceeef6061172361e406fafb85adbc872f558bec8 100644 (file)
@@ -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
index 9f486780fac8898d2bf2f53078941be10080d6d8..7aaebb007dc20da4980312e6b61761deb52fcad3 100644 (file)
@@ -1,3 +1,8 @@
+2016-01-19  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/68586
+       * g++.dg/cpp0x/enum30.C: New test.
+
 2016-01-19  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/69336
diff --git a/gcc/testsuite/g++.dg/cpp0x/enum30.C b/gcc/testsuite/g++.dg/cpp0x/enum30.C
new file mode 100644 (file)
index 0000000..cf0c1b5
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/68586
+// { dg-do compile { target c++11 } }
+
+enum E { x , y = 1 + (x << 1) };
+template<E> struct A {};
+A<x> a;
+
+enum E2 : int { x2 , y2 = x2 << 1 };
+template<E2> struct A2 {};
+A2<x2> a2;
+
+enum class E3 { x3 , y3 = x3 << 1 };
+template<E3> struct A3 {};
+A3<E3::x3> a3;