Commit c7a918f1 by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/55081 (Non-optimized static array elements initialization)

	PR c++/55081
	* typeck2.c (store_init_value): Call fold_non_dependent_expr
	and maybe_constant_init even for C++98.

	* g++.dg/opt/pr55081.C: New test.

From-SVN: r192862
parent 73f41491
2012-10-26 Jakub Jelinek <jakub@redhat.com>
PR c++/55081
* typeck2.c (store_init_value): Call fold_non_dependent_expr
and maybe_constant_init even for C++98.
2012-10-26 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/54984
......
......@@ -709,11 +709,9 @@ store_init_value (tree decl, tree init, VEC(tree,gc)** cleanups, int flags)
/* In C++0x constant expression is a semantic, not syntactic, property.
In C++98, make sure that what we thought was a constant expression at
template definition time is still constant. */
if ((cxx_dialect >= cxx0x
|| DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl))
&& (decl_maybe_constant_var_p (decl)
|| TREE_STATIC (decl)))
template definition time is still constant and otherwise perform this
as optimization, e.g. to fold SIZEOF_EXPRs in the initializer. */
if (decl_maybe_constant_var_p (decl) || TREE_STATIC (decl))
{
bool const_init;
value = fold_non_dependent_expr (value);
......
2012-10-26 Jakub Jelinek <jakub@redhat.com>
PR c++/55081
* g++.dg/opt/pr55081.C: New test.
PR debug/54970
PR debug/54971
* gcc.dg/guality/pr54970.c: New test.
......
// PR c++/55081
// { dg-do compile }
struct R { int field; } r;
__UINTPTR_TYPE__ *
foo ()
{
static __UINTPTR_TYPE__ array[] = {
sizeof (char),
(reinterpret_cast <__UINTPTR_TYPE__>(&r.field)
- reinterpret_cast <__UINTPTR_TYPE__>(&r)) + 1
};
return array;
}
// { dg-final { scan-assembler-not "_ZGVZ3foovE5array" } }
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