|
Pablo Greco |
9975c3 |
From d49318d9bc3e63251aada27b322e7756eab19884 Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
9975c3 |
From: Paolo Carlini <paolo.carlini@oracle.com>
|
|
Pablo Greco |
9975c3 |
Date: Tue, 5 Sep 2017 13:33:44 +0000
|
|
Pablo Greco |
9975c3 |
Subject: [PATCH] re PR c++/81942 (ICE on empty constexpr constructor with
|
|
Pablo Greco |
9975c3 |
C++14)
|
|
Pablo Greco |
9975c3 |
|
|
Pablo Greco |
9975c3 |
/cp
|
|
Pablo Greco |
9975c3 |
2017-09-05 Paolo Carlini <paolo.carlini@oracle.com>
|
|
Pablo Greco |
9975c3 |
|
|
Pablo Greco |
9975c3 |
PR c++/81942
|
|
Pablo Greco |
9975c3 |
* cp-tree.h (LABEL_DECL_CDTOR): Add and document.
|
|
Pablo Greco |
9975c3 |
* decl.c (start_preparsed_function): Set LABEL_DECL_CDTOR when
|
|
Pablo Greco |
9975c3 |
creating cdtor_label.
|
|
Pablo Greco |
9975c3 |
* constexpr.c (returns): Add the case of a constructor/destructor
|
|
Pablo Greco |
9975c3 |
returning via a LABEL_DECL_CDTOR label.
|
|
Pablo Greco |
9975c3 |
(cxx_eval_constant_expression, case [GOTO_EXPR]): Likewise.
|
|
Pablo Greco |
9975c3 |
|
|
Pablo Greco |
9975c3 |
/testsuite
|
|
Pablo Greco |
9975c3 |
2017-09-05 Paolo Carlini <paolo.carlini@oracle.com>
|
|
Pablo Greco |
9975c3 |
|
|
Pablo Greco |
9975c3 |
PR c++/81942
|
|
Pablo Greco |
9975c3 |
* g++.dg/cpp1y/constexpr-return3.C: New.
|
|
Pablo Greco |
9975c3 |
|
|
Pablo Greco |
9975c3 |
From-SVN: r251714
|
|
Pablo Greco |
9975c3 |
---
|
|
Pablo Greco |
9975c3 |
gcc/cp/ChangeLog | 10 ++++++++++
|
|
Pablo Greco |
9975c3 |
gcc/cp/constexpr.c | 8 ++++++--
|
|
Pablo Greco |
9975c3 |
gcc/cp/cp-tree.h | 6 ++++++
|
|
Pablo Greco |
9975c3 |
gcc/cp/decl.c | 5 ++++-
|
|
Pablo Greco |
9975c3 |
gcc/testsuite/ChangeLog | 5 +++++
|
|
Pablo Greco |
9975c3 |
gcc/testsuite/g++.dg/cpp1y/constexpr-return3.C | 11 +++++++++++
|
|
Pablo Greco |
9975c3 |
6 files changed, 42 insertions(+), 3 deletions(-)
|
|
Pablo Greco |
9975c3 |
create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-return3.C
|
|
Pablo Greco |
9975c3 |
|
|
Pablo Greco |
9975c3 |
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
|
|
Pablo Greco |
9975c3 |
index f3e868cff02..a5692fb3b3a 100644
|
|
Pablo Greco |
9975c3 |
--- a/gcc/cp/constexpr.c
|
|
Pablo Greco |
9975c3 |
+++ b/gcc/cp/constexpr.c
|
|
Pablo Greco |
9975c3 |
@@ -3671,7 +3671,9 @@ static bool
|
|
Pablo Greco |
9975c3 |
returns (tree *jump_target)
|
|
Pablo Greco |
9975c3 |
{
|
|
Pablo Greco |
9975c3 |
return *jump_target
|
|
Pablo Greco |
9975c3 |
- && TREE_CODE (*jump_target) == RETURN_EXPR;
|
|
Pablo Greco |
9975c3 |
+ && (TREE_CODE (*jump_target) == RETURN_EXPR
|
|
Pablo Greco |
9975c3 |
+ || (TREE_CODE (*jump_target) == LABEL_DECL
|
|
Pablo Greco |
9975c3 |
+ && LABEL_DECL_CDTOR (*jump_target)));
|
|
Pablo Greco |
9975c3 |
}
|
|
Pablo Greco |
9975c3 |
|
|
Pablo Greco |
9975c3 |
static bool
|
|
Pablo Greco |
9975c3 |
@@ -4554,7 +4556,9 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
|
|
Pablo Greco |
9975c3 |
|
|
Pablo Greco |
9975c3 |
case GOTO_EXPR:
|
|
Pablo Greco |
9975c3 |
*jump_target = TREE_OPERAND (t, 0);
|
|
Pablo Greco |
9975c3 |
- gcc_assert (breaks (jump_target) || continues (jump_target));
|
|
Pablo Greco |
9975c3 |
+ gcc_assert (breaks (jump_target) || continues (jump_target)
|
|
Pablo Greco |
9975c3 |
+ /* Allow for jumping to a cdtor_label. */
|
|
Pablo Greco |
9975c3 |
+ || returns (jump_target));
|
|
Pablo Greco |
9975c3 |
break;
|
|
Pablo Greco |
9975c3 |
|
|
Pablo Greco |
9975c3 |
case LOOP_EXPR:
|
|
Pablo Greco |
9975c3 |
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
|
|
Pablo Greco |
9975c3 |
index 432faa9da14..7dc20b1649b 100644
|
|
Pablo Greco |
9975c3 |
--- a/gcc/cp/cp-tree.h
|
|
Pablo Greco |
9975c3 |
+++ b/gcc/cp/cp-tree.h
|
|
Pablo Greco |
9975c3 |
@@ -456,6 +456,7 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
|
|
Pablo Greco |
9975c3 |
DECL_CONSTRAINT_VAR_P (in a PARM_DECL)
|
|
Pablo Greco |
9975c3 |
TEMPLATE_DECL_COMPLEX_ALIAS_P (in TEMPLATE_DECL)
|
|
Pablo Greco |
9975c3 |
DECL_INSTANTIATING_NSDMI_P (in a FIELD_DECL)
|
|
Pablo Greco |
9975c3 |
+ LABEL_DECL_CDTOR (in LABEL_DECL)
|
|
Pablo Greco |
9975c3 |
3: DECL_IN_AGGR_P.
|
|
Pablo Greco |
9975c3 |
4: DECL_C_BIT_FIELD (in a FIELD_DECL)
|
|
Pablo Greco |
9975c3 |
DECL_ANON_UNION_VAR_P (in a VAR_DECL)
|
|
Pablo Greco |
9975c3 |
@@ -3833,6 +3834,11 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
|
|
Pablo Greco |
9975c3 |
#define LABEL_DECL_CONTINUE(NODE) \
|
|
Pablo Greco |
9975c3 |
DECL_LANG_FLAG_1 (LABEL_DECL_CHECK (NODE))
|
|
Pablo Greco |
9975c3 |
|
|
Pablo Greco |
9975c3 |
+/* Nonzero if NODE is the target for genericization of 'return' stmts
|
|
Pablo Greco |
9975c3 |
+ in constructors/destructors of targetm.cxx.cdtor_returns_this targets. */
|
|
Pablo Greco |
9975c3 |
+#define LABEL_DECL_CDTOR(NODE) \
|
|
Pablo Greco |
9975c3 |
+ DECL_LANG_FLAG_2 (LABEL_DECL_CHECK (NODE))
|
|
Pablo Greco |
9975c3 |
+
|
|
Pablo Greco |
9975c3 |
/* True if NODE was declared with auto in its return type, but it has
|
|
Pablo Greco |
9975c3 |
started compilation and so the return type might have been changed by
|
|
Pablo Greco |
9975c3 |
return type deduction; its declared return type should be found in
|
|
Pablo Greco |
9975c3 |
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
|
|
Pablo Greco |
9975c3 |
index d6b80c604c8..861dfcfd828 100644
|
|
Pablo Greco |
9975c3 |
--- a/gcc/cp/decl.c
|
|
Pablo Greco |
9975c3 |
+++ b/gcc/cp/decl.c
|
|
Pablo Greco |
9975c3 |
@@ -15072,7 +15072,10 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
|
|
Pablo Greco |
9975c3 |
if (DECL_DESTRUCTOR_P (decl1)
|
|
Pablo Greco |
9975c3 |
|| (DECL_CONSTRUCTOR_P (decl1)
|
|
Pablo Greco |
9975c3 |
&& targetm.cxx.cdtor_returns_this ()))
|
|
Pablo Greco |
9975c3 |
- cdtor_label = create_artificial_label (input_location);
|
|
Pablo Greco |
9975c3 |
+ {
|
|
Pablo Greco |
9975c3 |
+ cdtor_label = create_artificial_label (input_location);
|
|
Pablo Greco |
9975c3 |
+ LABEL_DECL_CDTOR (cdtor_label) = true;
|
|
Pablo Greco |
9975c3 |
+ }
|
|
Pablo Greco |
9975c3 |
|
|
Pablo Greco |
9975c3 |
start_fname_decls ();
|
|
Pablo Greco |
9975c3 |
|
|
Pablo Greco |
9975c3 |
diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-return3.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-return3.C
|
|
Pablo Greco |
9975c3 |
new file mode 100644
|
|
Pablo Greco |
9975c3 |
index 00000000000..4cf4128e9eb
|
|
Pablo Greco |
9975c3 |
--- /dev/null
|
|
Pablo Greco |
9975c3 |
+++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-return3.C
|
|
Pablo Greco |
9975c3 |
@@ -0,0 +1,11 @@
|
|
Pablo Greco |
9975c3 |
+// PR c++/81942
|
|
Pablo Greco |
9975c3 |
+// { dg-do compile { target c++14 } }
|
|
Pablo Greco |
9975c3 |
+
|
|
Pablo Greco |
9975c3 |
+class A {
|
|
Pablo Greco |
9975c3 |
+public:
|
|
Pablo Greco |
9975c3 |
+ constexpr A() {
|
|
Pablo Greco |
9975c3 |
+ return;
|
|
Pablo Greco |
9975c3 |
+ }
|
|
Pablo Greco |
9975c3 |
+};
|
|
Pablo Greco |
9975c3 |
+
|
|
Pablo Greco |
9975c3 |
+A mwi;
|
|
Pablo Greco |
9975c3 |
--
|
|
Pablo Greco |
9975c3 |
2.18.4
|
|
Pablo Greco |
9975c3 |
|