diff options
author | Jonathan Wakely <jwakely.gcc@gmail.com> | 2011-05-23 08:15:16 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2011-05-23 09:15:16 +0100 |
commit | c11e39b0bdfc580582012fe56f0cce1b84f064f4 (patch) | |
tree | 3b87380a633beb61c227f25ea2c76e0edc6884d4 /gcc/cp/init.c | |
parent | bc69f7ffb57a35be61feb20e4a7b4300c8d1de24 (diff) | |
download | gcc-c11e39b0bdfc580582012fe56f0cce1b84f064f4.zip gcc-c11e39b0bdfc580582012fe56f0cce1b84f064f4.tar.gz gcc-c11e39b0bdfc580582012fe56f0cce1b84f064f4.tar.bz2 |
re PR c++/18016 (Warn about member variables initialized with itself)
2011-05-23 Jonathan Wakely <jwakely.gcc@gmail.com>
PR c++/18016
* init.c (perform_member_init): Check for self-initialization.
From-SVN: r174058
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r-- | gcc/cp/init.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 7d7adbe..5f30275 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -501,6 +501,17 @@ perform_member_init (tree member, tree init) if (decl == error_mark_node) return; + if (warn_init_self && init && TREE_CODE (init) == TREE_LIST + && TREE_CHAIN (init) == NULL_TREE) + { + tree val = TREE_VALUE (init); + if (TREE_CODE (val) == COMPONENT_REF && TREE_OPERAND (val, 1) == member + && TREE_OPERAND (val, 0) == current_class_ref) + warning_at (DECL_SOURCE_LOCATION (current_function_decl), + OPT_Wuninitialized, "%qD is initialized with itself", + member); + } + if (init == void_type_node) { /* mem() means value-initialization. */ |