Hi Jason,
and sorry about the delay in following up, a few days of vacations...
On 30/06/2016 19:49, Jason Merrill wrote:
I think we should check the type before calling cxx_constant_value.
Ok, I got the point. I'm not sure however how far we want to go with
this and which kind of consistency we want to achieve (vs error messages
issued in other similar circumstances). The below certainly passes
testing on x86_64-linux.
Thanks,
Paolo.
///////////////////////
Index: cp/decl.c
===================================================================
--- cp/decl.c (revision 238239)
+++ cp/decl.c (working copy)
@@ -13585,7 +13585,9 @@ build_enumerator (tree name, tree value, tree enum
if (value != NULL_TREE)
{
- value = cxx_constant_value (value);
+ if (TREE_CODE (value) != COMPONENT_REF
+ || !is_overloaded_fn (value))
+ value = cxx_constant_value (value);
if (TREE_CODE (value) != INTEGER_CST
|| ! INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (value)))
Index: testsuite/g++.dg/cpp0x/pr71665.C
===================================================================
--- testsuite/g++.dg/cpp0x/pr71665.C (revision 0)
+++ testsuite/g++.dg/cpp0x/pr71665.C (working copy)
@@ -0,0 +1,8 @@
+// PR c++/71665
+// { dg-do compile { target c++11 } }
+
+class A
+{
+ int f ();
+ enum { a = f }; // { dg-error "enumerator value" }
+};