Commit eba9e839 by Marek Polacek Committed by Marek Polacek

re PR c++/69688 (-Wsign-compare causes bogus error: size of array ‘uc_code’ is…

re PR c++/69688 (-Wsign-compare causes bogus error: size of array ‘uc_code’ is not an integral constant-expression)

	PR c++/69688
	* constexpr.c (clear_cv_and_fold_caches): Renamed from clear_cv_cache.
	Call clear_fold_cache.
	* cp-tree.h: Adjust declaration.
	* decl.c (finish_enum_value_list): Call clear_cv_and_fold_caches
	rather than clear_cv_cache and clear_fold_cache.
	* typeck2.c (store_init_value): Call clear_cv_and_fold_caches.

	* g++.dg/init/const12.C: New test.

From-SVN: r233220
parent 2158532f
2016-02-08 Marek Polacek <polacek@redhat.com>
PR c++/69688
* constexpr.c (clear_cv_and_fold_caches): Renamed from clear_cv_cache.
Call clear_fold_cache.
* cp-tree.h: Adjust declaration.
* decl.c (finish_enum_value_list): Call clear_cv_and_fold_caches
rather than clear_cv_cache and clear_fold_cache.
* typeck2.c (store_init_value): Call clear_cv_and_fold_caches.
2016-02-08 Jason Merrill <jason@redhat.com> 2016-02-08 Jason Merrill <jason@redhat.com>
* cp-tree.h (CONV_FOLD, CONV_BACKEND_CONVERT): New. * cp-tree.h (CONV_FOLD, CONV_BACKEND_CONVERT): New.
......
...@@ -4098,12 +4098,13 @@ maybe_constant_value (tree t, tree decl) ...@@ -4098,12 +4098,13 @@ maybe_constant_value (tree t, tree decl)
return ret; return ret;
} }
/* Dispose of the whole CV_CACHE. */ /* Dispose of the whole CV_CACHE and FOLD_CACHE. */
void void
clear_cv_cache (void) clear_cv_and_fold_caches (void)
{ {
gt_cleare_cache (cv_cache); gt_cleare_cache (cv_cache);
clear_fold_cache ();
} }
/* Like maybe_constant_value but first fully instantiate the argument. /* Like maybe_constant_value but first fully instantiate the argument.
......
...@@ -6922,7 +6922,7 @@ extern bool var_in_constexpr_fn (tree); ...@@ -6922,7 +6922,7 @@ extern bool var_in_constexpr_fn (tree);
extern void explain_invalid_constexpr_fn (tree); extern void explain_invalid_constexpr_fn (tree);
extern vec<tree> cx_error_context (void); extern vec<tree> cx_error_context (void);
extern tree fold_sizeof_expr (tree); extern tree fold_sizeof_expr (tree);
extern void clear_cv_cache (void); extern void clear_cv_and_fold_caches (void);
/* In c-family/cilk.c */ /* In c-family/cilk.c */
extern bool cilk_valid_spawn (tree); extern bool cilk_valid_spawn (tree);
......
...@@ -13414,8 +13414,7 @@ finish_enum_value_list (tree enumtype) ...@@ -13414,8 +13414,7 @@ finish_enum_value_list (tree enumtype)
/* Each enumerator now has the type of its enumeration. Clear the cache /* Each enumerator now has the type of its enumeration. Clear the cache
so that this change in types doesn't confuse us later on. */ so that this change in types doesn't confuse us later on. */
clear_cv_cache (); clear_cv_and_fold_caches ();
clear_fold_cache ();
} }
/* Finishes the enum type. This is called only the first time an /* Finishes the enum type. This is called only the first time an
......
...@@ -837,6 +837,9 @@ store_init_value (tree decl, tree init, vec<tree, va_gc>** cleanups, int flags) ...@@ -837,6 +837,9 @@ store_init_value (tree decl, tree init, vec<tree, va_gc>** cleanups, int flags)
/* Handle aggregate NSDMI in non-constant initializers, too. */ /* Handle aggregate NSDMI in non-constant initializers, too. */
value = replace_placeholders (value, decl); value = replace_placeholders (value, decl);
/* DECL may change value; purge caches. */
clear_cv_and_fold_caches ();
/* If the initializer is not a constant, fill in DECL_INITIAL with /* If the initializer is not a constant, fill in DECL_INITIAL with
the bits that are constant, and then return an expression that the bits that are constant, and then return an expression that
will perform the dynamic initialization. */ will perform the dynamic initialization. */
......
2016-02-08 Marek Polacek <polacek@redhat.com>
PR c++/69688
* g++.dg/init/const12.C: New test.
2016-02-08 Bernd Schmidt <bschmidt@redhat.com> 2016-02-08 Bernd Schmidt <bschmidt@redhat.com>
PR target/60410 PR target/60410
......
// PR c++/69688
// { dg-do compile }
// { dg-options "-Wsign-compare" }
struct S
{
static const int s;
static const char c[];
static wchar_t w[];
S ()
{
for (int i = 0; i < s; i++)
w[i] = 0;
}
};
const char S::c[] = "x";
const int S::s = sizeof (S::c) - 1;
wchar_t S::w[S::s];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment