From ba42c30445cef0aef15405d92361a536e12ae865 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Wed, 7 Oct 2020 04:56:41 -0700 Subject: [PATCH] c++: Adding exception specs can changed dependentness Making an exception variant can cause a non-dependent function type to become dependent (since c++17 eh-specs are part of the type). The same is (possibly?) true for adding a late return type. Fixed thusly. My upcoming local extern-decl changes have a test case that covers this (which was how I found it). gcc/cp/ * tree.c (build_cp_fntype_variant): Clear TYPE_DEPENDENT_P_VALID if necessary. --- gcc/cp/tree.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 8b7c6798ee9..074fa0c025e 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2638,6 +2638,9 @@ build_cp_fntype_variant (tree type, cp_ref_qualifier rqual, /* Need to build a new variant. */ v = build_variant_type_copy (type); + if (!TYPE_DEPENDENT_P (v)) + /* We no longer know that it's not type-dependent. */ + TYPE_DEPENDENT_P_VALID (v) = false; TYPE_RAISES_EXCEPTIONS (v) = raises; TYPE_HAS_LATE_RETURN_TYPE (v) = late; switch (rqual) -- 2.30.2