diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2014-03-11 17:34:32 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2014-03-11 17:34:32 +0000 |
commit | 5af1876c657286423edbf631be14a36ce2dcaeaa (patch) | |
tree | 815b5a91ba62eb93aca7edda95961ff3478f1fef /gcc | |
parent | 06dce00742a8f1c917c3b9113eafca0883b3e7a4 (diff) | |
download | gcc-5af1876c657286423edbf631be14a36ce2dcaeaa.zip gcc-5af1876c657286423edbf631be14a36ce2dcaeaa.tar.gz gcc-5af1876c657286423edbf631be14a36ce2dcaeaa.tar.bz2 |
re PR c++/60389 ([c++11] ICE with inheriting constructors and wrong usage of constexpr)
/cp
2014-03-11 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/60389
* method.c (get_inherited_ctor): New.
* cp-tree.h (get_inherited_ctor): Declare it.
* semantics.c (is_valid_constexpr_fn): Use it.
/testsuite
2014-03-11 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/60389
* g++.dg/cpp0x/inh-ctor19.C: New.
From-SVN: r208491
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 1 | ||||
-rw-r--r-- | gcc/cp/method.c | 19 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 32 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/inh-ctor19.C | 14 |
6 files changed, 68 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4aa90ee..4848b54 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2014-03-11 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/60389 + * method.c (get_inherited_ctor): New. + * cp-tree.h (get_inherited_ctor): Declare it. + * semantics.c (is_valid_constexpr_fn): Use it. + 2014-03-10 Jason Merrill <jason@redhat.com> PR c++/60367 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 45e4d82..e9fe86e 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5476,6 +5476,7 @@ extern tree get_copy_ctor (tree, tsubst_flags_t); extern tree get_copy_assign (tree); extern tree get_default_ctor (tree); extern tree get_dtor (tree, tsubst_flags_t); +extern tree get_inherited_ctor (tree); extern tree locate_ctor (tree); extern tree implicitly_declare_fn (special_function_kind, tree, bool, tree, tree); diff --git a/gcc/cp/method.c b/gcc/cp/method.c index c3940f2..d72b564 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -971,6 +971,25 @@ get_copy_assign (tree type) return fn; } +/* Locate the inherited constructor of constructor CTOR. */ + +tree +get_inherited_ctor (tree ctor) +{ + gcc_assert (DECL_INHERITED_CTOR_BASE (ctor)); + + push_deferring_access_checks (dk_no_check); + tree fn = locate_fn_flags (DECL_INHERITED_CTOR_BASE (ctor), + complete_ctor_identifier, + FUNCTION_FIRST_USER_PARMTYPE (ctor), + LOOKUP_NORMAL|LOOKUP_SPECULATIVE, + tf_none); + pop_deferring_access_checks (); + if (fn == error_mark_node) + return NULL_TREE; + return fn; +} + /* Subroutine of synthesized_method_walk. Update SPEC_P, TRIVIAL_P and DELETED_P or give an error message MSG with argument ARG. */ diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index fcd8409..1c9e153 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -7438,19 +7438,31 @@ retrieve_constexpr_fundef (tree fun) static bool is_valid_constexpr_fn (tree fun, bool complain) { - tree parm = FUNCTION_FIRST_USER_PARM (fun); bool ret = true; - for (; parm != NULL; parm = TREE_CHAIN (parm)) - if (!literal_type_p (TREE_TYPE (parm))) - { - ret = false; - if (complain) + + if (DECL_INHERITED_CTOR_BASE (fun) + && TREE_CODE (fun) == TEMPLATE_DECL) + { + ret = false; + if (complain) + error ("inherited constructor %qD is not constexpr", + get_inherited_ctor (fun)); + } + else + { + for (tree parm = FUNCTION_FIRST_USER_PARM (fun); + parm != NULL_TREE; parm = TREE_CHAIN (parm)) + if (!literal_type_p (TREE_TYPE (parm))) { - error ("invalid type for parameter %d of constexpr " - "function %q+#D", DECL_PARM_INDEX (parm), fun); - explain_non_literal_class (TREE_TYPE (parm)); + ret = false; + if (complain) + { + error ("invalid type for parameter %d of constexpr " + "function %q+#D", DECL_PARM_INDEX (parm), fun); + explain_non_literal_class (TREE_TYPE (parm)); + } } - } + } if (!DECL_CONSTRUCTOR_P (fun)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 241f619..a350342 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-03-11 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/60389 + * g++.dg/cpp0x/inh-ctor19.C: New. + 2014-03-11 Richard Biener <rguenther@suse.de> PR tree-optimization/60429 diff --git a/gcc/testsuite/g++.dg/cpp0x/inh-ctor19.C b/gcc/testsuite/g++.dg/cpp0x/inh-ctor19.C new file mode 100644 index 0000000..7a22f88 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/inh-ctor19.C @@ -0,0 +1,14 @@ +// PR c++/60389 +// { dg-do compile { target c++11 } } + +struct A +{ + template<typename...T> A(T...) {} +}; + +struct B : A +{ + using A::A; // { dg-error "inherited" } +}; + +constexpr B b; // { dg-error "literal" } |