diff options
| author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-04-06 15:59:14 +0000 |
|---|---|---|
| committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-04-06 15:59:14 +0000 |
| commit | 301679fe652bb5a88ea5ab5506fde196d76b239f (patch) | |
| tree | 435bbbe81ab3ca81ec3ffb6b655d016f38641b5a | |
| parent | 6f29a6e64648fe98e92714b75aa43e6fff2f172b (diff) | |
| download | ppe42-gcc-301679fe652bb5a88ea5ab5506fde196d76b239f.tar.gz ppe42-gcc-301679fe652bb5a88ea5ab5506fde196d76b239f.zip | |
PR c++/6179
* method.c (implicitly_declare_fn): Pass unqualified type to
synthesize_exception_spec.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@51954 138bc75d-0d04-0410-961f-82ee72b054a4
| -rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
| -rw-r--r-- | gcc/cp/method.c | 13 | ||||
| -rw-r--r-- | gcc/testsuite/g++.dg/eh/synth1.C | 27 |
3 files changed, 40 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cd2e9193ef0..6f2a6abff11 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2002-04-06 Jason Merrill <jason@redhat.com> + + PR c++/6179 + * method.c (implicitly_declare_fn): Pass unqualified type to + synthesize_exception_spec. + 2002-04-04 Neil Booth <neil@daikokuya.demon.co.uk> * cp-lang.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Redefine. diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 35e40ebbac6..830771e4267 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -770,8 +770,9 @@ synthesize_method (fndecl) /* Use EXTRACTOR to locate the relevant function called for each base & class field of TYPE. CLIENT allows additional information to be passed - to EXTRACTOR. Generates the union of all exceptions generated by - those functions. */ + to EXTRACTOR. Generates the union of all exceptions generated by those + functions. Note that we haven't updated TYPE_FIELDS and such of any + variants yet, so we need to look at the main one. */ static tree synthesize_exception_spec (type, extractor, client) @@ -783,7 +784,7 @@ synthesize_exception_spec (type, extractor, client) tree fields = TYPE_FIELDS (type); int i, n_bases = CLASSTYPE_N_BASECLASSES (type); tree binfos = TYPE_BINFO_BASETYPES (type); - + for (i = 0; i != n_bases; i++) { tree base = BINFO_TYPE (TREE_VEC_ELT (binfos, i)); @@ -962,7 +963,7 @@ implicitly_declare_fn (kind, type, const_p) case sfk_assignment_operator: { struct copy_data data; - tree argtype; + tree argtype = type; has_parm = 1; data.name = NULL; @@ -978,10 +979,10 @@ implicitly_declare_fn (kind, type, const_p) if (const_p) { data.quals = TYPE_QUAL_CONST; - type = build_qualified_type (type, TYPE_QUAL_CONST); + argtype = build_qualified_type (argtype, TYPE_QUAL_CONST); } - argtype = build_reference_type (type); + argtype = build_reference_type (argtype); args = build_tree_list (hash_tree_chain (argtype, NULL_TREE), get_identifier ("_ctor_arg")); args = tree_cons (NULL_TREE, args, void_list_node); diff --git a/gcc/testsuite/g++.dg/eh/synth1.C b/gcc/testsuite/g++.dg/eh/synth1.C new file mode 100644 index 00000000000..ac3cab8b166 --- /dev/null +++ b/gcc/testsuite/g++.dg/eh/synth1.C @@ -0,0 +1,27 @@ +// PR c++/6179 + +// Bug: we tried to look at the fields of 'const A' to determine the proper +// exception specification for the synthesized copy constructor, but +// TYPE_FIELDS hadn't been set yet, so we incorrectly got a throw() spec. + +struct B +{ + B () {} + B (const B&) { throw 1; } +}; + +struct A; +void f (const A &) {} +struct A +{ + B b; +}; + +int main () +{ + A a; + try + { A a2 (a); } + catch (...) + { } +} |

