Hi,

this ICE on invalid happens only in c++17 mode, when redeclaration_error_message performs an additional check which only makes sense for data members. Thus the fix is easy: avoid checking DECL_DECLARED_CONSTEXPR_P on CONST_DECLs.

Tested x86_64-linux.

Thanks, Paolo.

//////////////////////

/cp
2018-02-26  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/84533
        * decl.c (redeclaration_error_message): Don't try to use
        DECL_DECLARED_CONSTEXPR_P on CONST_DECLs.

/testsuite
2018-02-26  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/84533
        * g++.dg/cpp1z/pr84533.C: New.
Index: cp/decl.c
===================================================================
--- cp/decl.c   (revision 257983)
+++ cp/decl.c   (working copy)
@@ -2919,6 +2919,7 @@ redeclaration_error_message (tree newdecl, tree ol
         specifier is declaration rather than definition (and
         deprecated).  */
       if (cxx_dialect >= cxx17
+         && VAR_P (olddecl)
          && DECL_CLASS_SCOPE_P (olddecl)
          && DECL_DECLARED_CONSTEXPR_P (olddecl)
          && !DECL_INITIAL (newdecl))
Index: testsuite/g++.dg/cpp1z/pr84533.C
===================================================================
--- testsuite/g++.dg/cpp1z/pr84533.C    (nonexistent)
+++ testsuite/g++.dg/cpp1z/pr84533.C    (working copy)
@@ -0,0 +1,3 @@
+// { dg-options "-std=c++17" }
+
+enum E { e, e };  // { dg-error "redefinition" }

Reply via email to