From 9975c380d589f4384b4600ea860ddbf0704cf83b Mon Sep 17 00:00:00 2001 From: Pablo Greco Date: Oct 05 2020 14:11:28 +0000 Subject: Backport fix for 'internal compiler error: in cxx_eval_constant_expression' Signed-off-by: Johnny Hughes --- diff --git a/SOURCES/gcc7-arm-pr81942.patch b/SOURCES/gcc7-arm-pr81942.patch new file mode 100644 index 0000000..492e380 --- /dev/null +++ b/SOURCES/gcc7-arm-pr81942.patch @@ -0,0 +1,120 @@ +From d49318d9bc3e63251aada27b322e7756eab19884 Mon Sep 17 00:00:00 2001 +From: Paolo Carlini +Date: Tue, 5 Sep 2017 13:33:44 +0000 +Subject: [PATCH] re PR c++/81942 (ICE on empty constexpr constructor with + C++14) + +/cp +2017-09-05 Paolo Carlini + + PR c++/81942 + * cp-tree.h (LABEL_DECL_CDTOR): Add and document. + * decl.c (start_preparsed_function): Set LABEL_DECL_CDTOR when + creating cdtor_label. + * constexpr.c (returns): Add the case of a constructor/destructor + returning via a LABEL_DECL_CDTOR label. + (cxx_eval_constant_expression, case [GOTO_EXPR]): Likewise. + +/testsuite +2017-09-05 Paolo Carlini + + PR c++/81942 + * g++.dg/cpp1y/constexpr-return3.C: New. + +From-SVN: r251714 +--- + gcc/cp/ChangeLog | 10 ++++++++++ + gcc/cp/constexpr.c | 8 ++++++-- + gcc/cp/cp-tree.h | 6 ++++++ + gcc/cp/decl.c | 5 ++++- + gcc/testsuite/ChangeLog | 5 +++++ + gcc/testsuite/g++.dg/cpp1y/constexpr-return3.C | 11 +++++++++++ + 6 files changed, 42 insertions(+), 3 deletions(-) + create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-return3.C + +diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c +index f3e868cff02..a5692fb3b3a 100644 +--- a/gcc/cp/constexpr.c ++++ b/gcc/cp/constexpr.c +@@ -3671,7 +3671,9 @@ static bool + returns (tree *jump_target) + { + return *jump_target +- && TREE_CODE (*jump_target) == RETURN_EXPR; ++ && (TREE_CODE (*jump_target) == RETURN_EXPR ++ || (TREE_CODE (*jump_target) == LABEL_DECL ++ && LABEL_DECL_CDTOR (*jump_target))); + } + + static bool +@@ -4554,7 +4556,9 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, + + case GOTO_EXPR: + *jump_target = TREE_OPERAND (t, 0); +- gcc_assert (breaks (jump_target) || continues (jump_target)); ++ gcc_assert (breaks (jump_target) || continues (jump_target) ++ /* Allow for jumping to a cdtor_label. */ ++ || returns (jump_target)); + break; + + case LOOP_EXPR: +diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h +index 432faa9da14..7dc20b1649b 100644 +--- a/gcc/cp/cp-tree.h ++++ b/gcc/cp/cp-tree.h +@@ -456,6 +456,7 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX]; + DECL_CONSTRAINT_VAR_P (in a PARM_DECL) + TEMPLATE_DECL_COMPLEX_ALIAS_P (in TEMPLATE_DECL) + DECL_INSTANTIATING_NSDMI_P (in a FIELD_DECL) ++ LABEL_DECL_CDTOR (in LABEL_DECL) + 3: DECL_IN_AGGR_P. + 4: DECL_C_BIT_FIELD (in a FIELD_DECL) + DECL_ANON_UNION_VAR_P (in a VAR_DECL) +@@ -3833,6 +3834,11 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter) + #define LABEL_DECL_CONTINUE(NODE) \ + DECL_LANG_FLAG_1 (LABEL_DECL_CHECK (NODE)) + ++/* Nonzero if NODE is the target for genericization of 'return' stmts ++ in constructors/destructors of targetm.cxx.cdtor_returns_this targets. */ ++#define LABEL_DECL_CDTOR(NODE) \ ++ DECL_LANG_FLAG_2 (LABEL_DECL_CHECK (NODE)) ++ + /* True if NODE was declared with auto in its return type, but it has + started compilation and so the return type might have been changed by + return type deduction; its declared return type should be found in +diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c +index d6b80c604c8..861dfcfd828 100644 +--- a/gcc/cp/decl.c ++++ b/gcc/cp/decl.c +@@ -15072,7 +15072,10 @@ start_preparsed_function (tree decl1, tree attrs, int flags) + if (DECL_DESTRUCTOR_P (decl1) + || (DECL_CONSTRUCTOR_P (decl1) + && targetm.cxx.cdtor_returns_this ())) +- cdtor_label = create_artificial_label (input_location); ++ { ++ cdtor_label = create_artificial_label (input_location); ++ LABEL_DECL_CDTOR (cdtor_label) = true; ++ } + + start_fname_decls (); + +diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-return3.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-return3.C +new file mode 100644 +index 00000000000..4cf4128e9eb +--- /dev/null ++++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-return3.C +@@ -0,0 +1,11 @@ ++// PR c++/81942 ++// { dg-do compile { target c++14 } } ++ ++class A { ++public: ++ constexpr A() { ++ return; ++ } ++}; ++ ++A mwi; +-- +2.18.4 + diff --git a/SPECS/gcc.spec b/SPECS/gcc.spec index 2060275..b3d59e8 100644 --- a/SPECS/gcc.spec +++ b/SPECS/gcc.spec @@ -95,7 +95,7 @@ Summary: GCC version 7 Name: %{?scl_prefix}gcc Version: %{gcc_version} -Release: %{gcc_release}.16%{?dist} +Release: %{gcc_release}.16%{?dist}.0.1 # libgcc, libgfortran, libgomp, libstdc++ and crtstuff have # GCC Runtime Exception. License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD @@ -307,6 +307,8 @@ Patch3028: gcc7-fortran-fpad-source.patch # specific patches for .el7 armhfp build Patch10001: gcc7-dts-arm.patch +#https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81942 +Patch10002: gcc7-arm-pr81942.patch %if 0%{?rhel} >= 7 %global nonsharedver 48 @@ -772,6 +774,7 @@ cd .. %ifarch %{arm} %patch10001 -p1 -b .arm1 +%patch10002 -p1 -b .pr81942 %endif echo 'Red Hat %{version}-%{gcc_release}' > gcc/DEV-PHASE