diff options
author | Jason Merrill <jason@redhat.com> | 2009-02-18 16:01:03 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2009-02-18 16:01:03 -0500 |
commit | 98b806924df9a7bb913cc5cc2d2e7fdc7e2a5de0 (patch) | |
tree | 0f64524f372d342649161f19523537146008f861 | |
parent | 1e80963d6176df27cd61f268ec14392cda8a309a (diff) | |
download | gcc-98b806924df9a7bb913cc5cc2d2e7fdc7e2a5de0.zip gcc-98b806924df9a7bb913cc5cc2d2e7fdc7e2a5de0.tar.gz gcc-98b806924df9a7bb913cc5cc2d2e7fdc7e2a5de0.tar.bz2 |
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
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/cfns.h | 4 | ||||
-rw-r--r-- | gcc/cp/ptree.c | 21 | ||||
-rw-r--r-- | gcc/target.h | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/init/const7.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/opt/const6.C | 14 | ||||
-rw-r--r-- | gcc/tree-pretty-print.c | 6 | ||||
-rw-r--r-- | gcc/tree-sra.c | 1 | ||||
-rw-r--r-- | gcc/tree-ssa-ccp.c | 3 | ||||
-rw-r--r-- | gcc/tree.h | 4 | ||||
-rw-r--r-- | gcc/varasm.c | 10 |
13 files changed, 69 insertions, 16 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ac325e0..8f44f45 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d9d6866..3ca03d3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 diff --git a/gcc/cp/cfns.h b/gcc/cp/cfns.h index 82cdef7..e6d43d8 100644 --- a/gcc/cp/cfns.h +++ b/gcc/cp/cfns.h @@ -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 diff --git a/gcc/cp/ptree.c b/gcc/cp/ptree.c index c91cb15..2452abc 100644 --- a/gcc/cp/ptree.c +++ b/gcc/cp/ptree.c @@ -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)) diff --git a/gcc/target.h b/gcc/target.h index 21c46ad..10aaf4c 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -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, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 60b17cd..f052878 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 ... diff --git a/gcc/testsuite/g++.dg/init/const7.C b/gcc/testsuite/g++.dg/init/const7.C index 348bd58..18d0462 100644 --- a/gcc/testsuite/g++.dg/init/const7.C +++ b/gcc/testsuite/g++.dg/init/const7.C @@ -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" } } diff --git a/gcc/testsuite/g++.dg/opt/const6.C b/gcc/testsuite/g++.dg/opt/const6.C new file mode 100644 index 0000000..1a5c79b --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/const6.C @@ -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; +} diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index ff45ecc..e01433b 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -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, "("); diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index 01c0e12..abcca2b 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -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); diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index ef6890c..4627265 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -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; @@ -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) diff --git a/gcc/varasm.c b/gcc/varasm.c index 7fed300..083cf09 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -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: |