diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-06-19 15:32:43 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-06-19 15:32:43 +0000 |
commit | 1a7c0ccb66f80bda54058561162b5446b9d9d1c9 (patch) | |
tree | fe9acae7789cd322367a02a4039509a1a001b489 | |
parent | 843bd2fa78007c193692f6382edf3b6b5c2d3a62 (diff) | |
download | gcc-1a7c0ccb66f80bda54058561162b5446b9d9d1c9.tar.gz |
./:
* ggc-page.c (ggc_pch_write_object): Initialize emptyBytes.
* sdbout.c (sdb_debug_hooks): Initialize non-SDB_DEBUGGING_INFO
version.
* c-decl.c (finish_decl): If -Wc++-compat, warn about
uninitialized const.
testsuite/:
* gcc.dg/Wcxx-compat-17.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148710 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/c-decl.c | 8 | ||||
-rw-r--r-- | gcc/ggc-page.c | 2 | ||||
-rw-r--r-- | gcc/sdbout.c | 34 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Wcxx-compat-17.c | 21 |
6 files changed, 75 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c6a39f15718..bab05f5bf79 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,14 @@ 2009-06-19 Ian Lance Taylor <iant@google.com> + * ggc-page.c (ggc_pch_write_object): Initialize emptyBytes. + * sdbout.c (sdb_debug_hooks): Initialize non-SDB_DEBUGGING_INFO + version. + + * c-decl.c (finish_decl): If -Wc++-compat, warn about + uninitialized const. + +2009-06-19 Ian Lance Taylor <iant@google.com> + * dse.c (struct store_info): Rename bitmap field to bmap. Change all uses. diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 57cf389dc73..8234e0124ea 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -4352,6 +4352,14 @@ finish_decl (tree decl, location_t init_loc, tree init, push_cleanup (decl, cleanup, false); } } + + if (warn_cxx_compat + && TREE_CODE (decl) == VAR_DECL + && TREE_READONLY (decl) + && !DECL_EXTERNAL (decl) + && DECL_INITIAL (decl) == NULL_TREE) + warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat, + "uninitialized const %qD is invalid in C++", decl); } /* Given a parsed parameter declaration, decode it into a PARM_DECL. */ diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c index 4f872b294f1..744355e3de3 100644 --- a/gcc/ggc-page.c +++ b/gcc/ggc-page.c @@ -2165,7 +2165,7 @@ ggc_pch_write_object (struct ggc_pch_data *d ATTRIBUTE_UNUSED, size_t size, bool is_string ATTRIBUTE_UNUSED) { unsigned order; - static const char emptyBytes[256]; + static const char emptyBytes[256] = { 0 }; if (size < NUM_SIZE_LOOKUP) order = size_lookup[size]; diff --git a/gcc/sdbout.c b/gcc/sdbout.c index 0e1cf18dfb2..dbcba690436 100644 --- a/gcc/sdbout.c +++ b/gcc/sdbout.c @@ -1,6 +1,6 @@ /* Output sdb-format symbol table information from GNU compiler. Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008 + 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc. This file is part of GCC. @@ -1698,7 +1698,37 @@ sdbout_init (const char *input_file_name ATTRIBUTE_UNUSED) #else /* SDB_DEBUGGING_INFO */ /* This should never be used, but its address is needed for comparisons. */ -const struct gcc_debug_hooks sdb_debug_hooks; +const struct gcc_debug_hooks sdb_debug_hooks = +{ + 0, /* init */ + 0, /* finish */ + 0, /* define */ + 0, /* undef */ + 0, /* start_source_file */ + 0, /* end_source_file */ + 0, /* begin_block */ + 0, /* end_block */ + 0, /* ignore_block */ + 0, /* source_line */ + 0, /* begin_prologue */ + 0, /* end_prologue */ + 0, /* end_epilogue */ + 0, /* begin_function */ + 0, /* end_function */ + 0, /* function_decl */ + 0, /* global_decl */ + 0, /* type_decl */ + 0, /* imported_module_or_decl */ + 0, /* deferred_inline_function */ + 0, /* outlining_inline_function */ + 0, /* label */ + 0, /* handle_pch */ + 0, /* var_location */ + 0, /* switch_text_section */ + 0, /* set_name */ + 0 /* start_end_main_source_file */ +}; + #endif /* SDB_DEBUGGING_INFO */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index db6c860c175..fec4369b18a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2009-06-19 Ian Lance Taylor <iant@google.com> + * gcc.dg/Wcxx-compat-17.c: New testcase. + +2009-06-19 Ian Lance Taylor <iant@google.com> + * gcc.dg/Wcxx-compat-15.c: New testcase. 2009-06-19 Ian Lance Taylor <iant@google.com> diff --git a/gcc/testsuite/gcc.dg/Wcxx-compat-17.c b/gcc/testsuite/gcc.dg/Wcxx-compat-17.c new file mode 100644 index 00000000000..78760d641ff --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wcxx-compat-17.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ +const int v1; /* { dg-warning "invalid in C\[+\]\[+\]" } */ +const char * const v2; /* { dg-warning "invalid in C\[+\]\[+\]" } */ +struct s { int f1; int f2; }; +const struct s v3; /* { dg-warning "invalid in C\[+\]\[+\]" } */ +const int v4 = 1; +const char * const v5 = 0; +const struct s v6 = { 0, 0 }; +const struct s v7 = { 0 }; +void +f() +{ + const int v11; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + const char * const v12; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + const struct s v13; /* { dg-warning "invalid in C\[+\]\[+\]" } */ + const int v14 = 1; + const char * const v15 = 0; + const struct s v16 = { 0, 0 }; + const struct s v17 = { 0 }; +} |