diff options
author | Fabien Chêne <fabien@gcc.gnu.org> | 2010-06-06 11:35:45 +0200 |
---|---|---|
committer | Fabien Chêne <fabien@gcc.gnu.org> | 2010-06-06 11:35:45 +0200 |
commit | 640c2adff1e62150e851e5fb5053042155e551b1 (patch) | |
tree | 461a898815c74c89f82fb574a07170de48c18e3f /gcc | |
parent | 389caea850371e30cb1b886e3e484571873a2c85 (diff) | |
download | gcc-640c2adff1e62150e851e5fb5053042155e551b1.zip gcc-640c2adff1e62150e851e5fb5053042155e551b1.tar.gz gcc-640c2adff1e62150e851e5fb5053042155e551b1.tar.bz2 |
Fix PR c++/44086
From-SVN: r160337
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/class.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/decltype4.C | 1 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/init/pr44086.C | 15 |
5 files changed, 37 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d75030e..6572ac0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2010-06-05 Fabien Chêne <fabien@gcc.gnu.org> + + PR c++/44086 + * class.c (check_field_decls): Move the call to + check_bitfield_decl before trying to set the + CLASSTYPE_READONLY_FIELDS_NEED_INIT flag. + 2010-06-05 Steven Bosscher <steven@gcc.gnu.org> * typeck.c: Update include path for moved files. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 2ee7792..c6da4cd 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -3092,6 +3092,14 @@ check_field_decls (tree t, tree *access_decls, if (! zero_init_p (type)) CLASSTYPE_NON_ZERO_INIT_P (t) = 1; + /* We set DECL_C_BIT_FIELD in grokbitfield. + If the type and width are valid, we'll also set DECL_BIT_FIELD. */ + if (! DECL_C_BIT_FIELD (x) || ! check_bitfield_decl (x)) + check_field_decl (x, t, + cant_have_const_ctor_p, + no_const_asn_ref_p, + &any_default_members); + /* If any field is const, the structure type is pseudo-const. */ if (CP_TYPE_CONST_P (type)) { @@ -3120,14 +3128,6 @@ check_field_decls (tree t, tree *access_decls, if (constructor_name_p (DECL_NAME (x), t) && TYPE_HAS_USER_CONSTRUCTOR (t)) permerror (input_location, "field %q+#D with same name as class", x); - - /* We set DECL_C_BIT_FIELD in grokbitfield. - If the type and width are valid, we'll also set DECL_BIT_FIELD. */ - if (! DECL_C_BIT_FIELD (x) || ! check_bitfield_decl (x)) - check_field_decl (x, t, - cant_have_const_ctor_p, - no_const_asn_ref_p, - &any_default_members); } /* Effective C++ rule 11: if a class has dynamic memory held by pointers, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e84da19..4400b9a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2010-06-05 Fabien Chêne <fabien@gcc.gnu.org> + + PR c++/44086 + * g++.dg/init/pr44086.C: New. + * g++.dg/cpp0x/decltype4.C: Adjust. + 2010-06-05 Paul Thomas <pault@gcc.gnu.org> PR fortran/43945 diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype4.C b/gcc/testsuite/g++.dg/cpp0x/decltype4.C index 23a3434..32fbc2b 100644 --- a/gcc/testsuite/g++.dg/cpp0x/decltype4.C +++ b/gcc/testsuite/g++.dg/cpp0x/decltype4.C @@ -62,6 +62,7 @@ void wibble() { } struct B { + B () : bit(), cbit() {} int bit : 2; const int cbit : 3; diff --git a/gcc/testsuite/g++.dg/init/pr44086.C b/gcc/testsuite/g++.dg/init/pr44086.C new file mode 100644 index 0000000..e3304f4 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/pr44086.C @@ -0,0 +1,15 @@ +// PR c++/44086 +// { dg-do compile } + +struct A +{ + int const i : 2; // { dg-message "should be initialized" } +}; + +void f() +{ + A a; // { dg-error "uninitialized const" } + new A; // { dg-error "uninitialized const" } + A(); + new A(); +} |