public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-5505] c++: direct enum init from type-dep elt [PR112515]
@ 2023-11-15 17:24 Patrick Palka
0 siblings, 0 replies; only message in thread
From: Patrick Palka @ 2023-11-15 17:24 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:b126f3ffbef59b0b08c2c2a664133d7d6f5ca235
commit r14-5505-gb126f3ffbef59b0b08c2c2a664133d7d6f5ca235
Author: Patrick Palka <ppalka@redhat.com>
Date: Wed Nov 15 12:24:38 2023 -0500
c++: direct enum init from type-dep elt [PR112515]
The NON_DEPENDENT_EXPR removal exposed that is_direct_enum_init can be
called in a template context on a CONSTRUCTOR that isn't type-dependent
but whose element is.
PR c++/112515
gcc/cp/ChangeLog:
* decl.cc (is_direct_enum_init): Check type-dependence of the
single element.
gcc/testsuite/ChangeLog:
* g++.dg/template/non-dependent30.C: New test.
Diff:
---
gcc/cp/decl.cc | 1 +
gcc/testsuite/g++.dg/template/non-dependent30.C | 9 +++++++++
2 files changed, 10 insertions(+)
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index d2ed46b1453..b8e1098d482 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -6614,6 +6614,7 @@ is_direct_enum_init (tree type, tree init)
&& CONSTRUCTOR_NELTS (init) == 1
/* DR 2374: The single element needs to be implicitly
convertible to the underlying type of the enum. */
+ && !type_dependent_expression_p (CONSTRUCTOR_ELT (init, 0)->value)
&& can_convert_arg (ENUM_UNDERLYING_TYPE (type),
TREE_TYPE (CONSTRUCTOR_ELT (init, 0)->value),
CONSTRUCTOR_ELT (init, 0)->value,
diff --git a/gcc/testsuite/g++.dg/template/non-dependent30.C b/gcc/testsuite/g++.dg/template/non-dependent30.C
new file mode 100644
index 00000000000..32d48e44c09
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/non-dependent30.C
@@ -0,0 +1,9 @@
+// PR c++/112515
+// { dg-do compile { target c++11 } }
+
+enum E : int { };
+
+template<class T>
+E f(T t) {
+ return E{t.e};
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-11-15 17:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-15 17:24 [gcc r14-5505] c++: direct enum init from type-dep elt [PR112515] Patrick Palka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).