re PR target/39179 (Wrong code in c++ for const members initialized in external file)

PR target/39179
        * tree-ssa-ccp.c (get_symbol_constant_value): Don't assume zero
        value if DECL_EXTERNAL.
        * tree-sra.c (sra_walk_gimple_assign): Likewise.
        * target.h (gcc_target::binds_local_p): Clarify module.
        * tree.h (TREE_PUBLIC): Clarify module.

From-SVN: r144270
This commit is contained in:
Jason Merrill 2009-02-18 16:01:03 -05:00 committed by Jason Merrill
parent 1e80963d61
commit 98b806924d
13 changed files with 69 additions and 16 deletions

View File

@ -1,3 +1,12 @@
2009-02-18 Jason Merrill <jason@redhat.com>
PR target/39179
* tree-ssa-ccp.c (get_symbol_constant_value): Don't assume zero
value if DECL_EXTERNAL.
* tree-sra.c (sra_walk_gimple_assign): Likewise.
* target.h (gcc_target::binds_local_p): Clarify "module".
* tree.h (TREE_PUBLIC): Clarify "module".
2009-02-17 Xuepeng Guo <xuepeng.guo@intel.com>
PR target/38891

View File

@ -1,3 +1,7 @@
2009-02-18 Jason Merrill <jason@redhat.com>
* cfns.h: Tweak pathname for cfns.gperf.
2009-02-13 Jason Merrill <jason@redhat.com>
PR c++/39070

View File

@ -1,5 +1,5 @@
/* ANSI-C code produced by gperf version 3.0.1 */
/* Command-line: gperf -o -C -E -k '1-6,$' -j1 -D -N libc_name_p -L ANSI-C ../../gcc/gcc/cp/cfns.gperf */
/* Command-line: gperf -o -C -E -k '1-6,$' -j1 -D -N libc_name_p -L ANSI-C ../../gcc/cp/cfns.gperf */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
@ -28,7 +28,7 @@
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
#endif
#line 1 "../../gcc/gcc/cp/cfns.gperf"
#line 1 "../../gcc/cp/cfns.gperf"
#ifdef __GNUC__
__inline

View File

@ -44,7 +44,23 @@ cxx_print_decl (FILE *file, tree node, int indent)
if (!CODE_CONTAINS_STRUCT (TREE_CODE (node), TS_DECL_COMMON)
|| !DECL_LANG_SPECIFIC (node))
return;
if (TREE_CODE (node) == FUNCTION_DECL)
{
int flags = TFF_DECL_SPECIFIERS|TFF_RETURN_TYPE
|TFF_FUNCTION_DEFAULT_ARGUMENTS|TFF_EXCEPTION_SPECIFICATION ;
indent_to (file, indent + 3);
fprintf (file, " full-name \"%s\"", decl_as_string (node, flags));
}
else if (TREE_CODE (node) == TEMPLATE_DECL)
{
indent_to (file, indent + 3);
fprintf (file, " full-name \"%s\"",
decl_as_string (node, TFF_TEMPLATE_HEADER));
}
indent_to (file, indent + 3);
if (DECL_EXTERNAL (node) && DECL_NOT_REALLY_EXTERN (node))
fprintf (file, " not-really-extern");
if (TREE_CODE (node) == FUNCTION_DECL
&& DECL_PENDING_INLINE_INFO (node))
fprintf (file, " pending-inline-info %p",
@ -81,6 +97,9 @@ cxx_print_type (FILE *file, tree node, int indent)
case RECORD_TYPE:
case UNION_TYPE:
indent_to (file, indent + 4);
fprintf (file, "full-name \"%s\"",
type_as_string (node, TFF_CLASS_KEY_OR_ENUM));
break;
default:
@ -97,7 +116,7 @@ cxx_print_type (FILE *file, tree node, int indent)
indent_to (file, indent + 3);
if (TYPE_NEEDS_CONSTRUCTING (node))
fputs ( "needs-constructor", file);
fputs ( " needs-constructor", file);
if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (node))
fputs (" needs-destructor", file);
if (TYPE_HAS_DEFAULT_CONSTRUCTOR (node))

View File

@ -626,7 +626,7 @@ struct gcc_target
bool (* in_small_data_p) (const_tree);
/* True if EXP names an object for which name resolution must resolve
to the current module. */
to the current executable or shared library. */
bool (* binds_local_p) (const_tree);
/* Modify and return the identifier of a DECL's external name,

View File

@ -1,3 +1,8 @@
2009-02-18 Jason Merrill <jason@redhat.com>
PR target/39179
* g++.dg/opt/const6.C: New test.
2009-02-18 H.J. Lu <hongjiu.lu@intel.com>
* gcc.dg/callabi/callabi.exp: Moved to ...

View File

@ -9,5 +9,5 @@ short offsets[1] = {
// This ensures that we get a dump whether or not the bug is present.
void fn() { }
// { dg-final { scan-tree-dump-not "initialization" "gimple" { xfail *-*-* } } }
// { dg-final { scan-tree-dump-not "initialization" "gimple" } }
// { dg-final { cleanup-tree-dump "gimple" } }

View File

@ -0,0 +1,14 @@
// PR target/39179
// Make sure that we don't optimize away the load from K::k.
// { dg-options "-O2" }
// { dg-final { scan-assembler _ZN1K1kE } }
struct K {
static const unsigned k;
};
extern "C" void abort (void);
int main() {
if ( K::k != 1 )
abort ();
return 1;
}

View File

@ -2585,18 +2585,20 @@ print_call_name (pretty_printer *buffer, const_tree node)
if (TREE_CODE (op0) == NON_LVALUE_EXPR)
op0 = TREE_OPERAND (op0, 0);
again:
switch (TREE_CODE (op0))
{
case VAR_DECL:
case PARM_DECL:
case FUNCTION_DECL:
dump_function_name (buffer, op0);
break;
case ADDR_EXPR:
case INDIRECT_REF:
case NOP_EXPR:
dump_generic_node (buffer, TREE_OPERAND (op0, 0), 0, 0, false);
break;
op0 = TREE_OPERAND (op0, 0);
goto again;
case COND_EXPR:
pp_string (buffer, "(");

View File

@ -1008,6 +1008,7 @@ sra_walk_gimple_assign (gimple stmt, gimple_stmt_iterator *gsi,
we'd been passed the constructor directly. Invoke INIT. */
else if (TREE_CODE (rhs) == VAR_DECL
&& TREE_STATIC (rhs)
&& !DECL_EXTERNAL (rhs)
&& TREE_READONLY (rhs)
&& targetm.binds_local_p (rhs))
fns->init (lhs_elt, DECL_INITIAL (rhs), gsi);

View File

@ -287,10 +287,11 @@ get_symbol_constant_value (tree sym)
have zero as the initializer if they may not be
overridden at link or run time. */
if (!val
&& !DECL_EXTERNAL (sym)
&& targetm.binds_local_p (sym)
&& (INTEGRAL_TYPE_P (TREE_TYPE (sym))
|| SCALAR_FLOAT_TYPE_P (TREE_TYPE (sym))))
return fold_convert (TREE_TYPE (sym), integer_zero_node);
return fold_convert (TREE_TYPE (sym), integer_zero_node);
}
return NULL_TREE;

View File

@ -1195,9 +1195,9 @@ extern void omp_clause_range_check_failed (const_tree, const char *, int,
(CONSTANT_CLASS_P (EXPR) && TREE_OVERFLOW (EXPR))
/* In a VAR_DECL, FUNCTION_DECL, NAMESPACE_DECL or TYPE_DECL,
nonzero means name is to be accessible from outside this module.
nonzero means name is to be accessible from outside this translation unit.
In an IDENTIFIER_NODE, nonzero means an external declaration
accessible from outside this module was previously seen
accessible from outside this translation unit was previously seen
for this name in an inner scope. */
#define TREE_PUBLIC(NODE) ((NODE)->base.public_flag)

View File

@ -4316,12 +4316,10 @@ initializer_constant_valid_p (tree value, tree endtype)
}
/* Support narrowing pointer differences. */
if (TREE_CODE (value) == POINTER_PLUS_EXPR)
{
ret = narrowing_initializer_constant_valid_p (value, endtype);
if (ret != NULL_TREE)
return ret;
}
ret = narrowing_initializer_constant_valid_p (value, endtype);
if (ret != NULL_TREE)
return ret;
break;
case MINUS_EXPR: