From: Marek Polacek Date: Thu, 4 Aug 2016 07:47:50 +0000 (+0000) Subject: re PR c++/70229 (error: constexpr constructor does not have empty body) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a00084346a299e8154ede732c6d4d3ae56d1f66f;p=gcc.git re PR c++/70229 (error: constexpr constructor does not have empty body) PR c++/70229 * constexpr.c (check_constexpr_ctor_body_1): Allow typedef declarations. * g++.dg/cpp0x/constexpr-ctor19.C: New test. From-SVN: r239115 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 38ae4437786..2a993701fd6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2016-08-04 Marek Polacek + + PR c++/70229 + * constexpr.c (check_constexpr_ctor_body_1): Allow typedef + declarations. + 2016-08-01 Jason Merrill * mangle.c (mangle_decl): Warn about mangled name change even if diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index edade489401..41665c5a36e 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -425,7 +425,8 @@ check_constexpr_ctor_body_1 (tree last, tree list) switch (TREE_CODE (list)) { case DECL_EXPR: - if (TREE_CODE (DECL_EXPR_DECL (list)) == USING_DECL) + if (TREE_CODE (DECL_EXPR_DECL (list)) == USING_DECL + || TREE_CODE (DECL_EXPR_DECL (list)) == TYPE_DECL) return true; return false; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index df48f68924d..b5d8ee5dc33 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-08-04 Marek Polacek + + PR c++/70229 + * g++.dg/cpp0x/constexpr-ctor19.C: New test. + 2016-08-04 Richard Biener PR middle-end/71984 diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor19.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor19.C new file mode 100644 index 00000000000..f5ef053e0c4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor19.C @@ -0,0 +1,42 @@ +// PR c++/70229 +// { dg-do compile { target c++11 } } + +template +class S { + constexpr S (void) { + typedef int T; + } +}; + +template +class S2 { + constexpr S2 (void) { + ; + } +}; + +template +class S3 { + constexpr S3 (void) { + typedef enum { X } E; + } // { dg-error "does not have empty body" "" { target c++11_only } } +}; + +template +class S4 { + constexpr S4 (void) { + typedef struct { int j; } U; + } // { dg-error "does not have empty body" "" { target c++11_only } } +}; + +struct V +{ + int i; +}; + +template +class S5 { + constexpr S5 (void) { + typedef V W; + } +};