diff mbox series

[C++] PR 84533 ("[7/8 Regression] ICE with duplicate enum value")

Message ID 224352b4-659b-ee37-fc6b-bfbecda3d7b4@oracle.com
State New
Headers show
Series [C++] PR 84533 ("[7/8 Regression] ICE with duplicate enum value") | expand

Commit Message

Paolo Carlini Feb. 26, 2018, 10:19 a.m. UTC
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.carlini@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.carlini@oracle.com>

	PR c++/84533
	* g++.dg/cpp1z/pr84533.C: New.

Comments

Jason Merrill Feb. 26, 2018, 2:10 p.m. UTC | #1
OK.

On Mon, Feb 26, 2018 at 5:19 AM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> 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.
>
> //////////////////////
>
diff mbox series

Patch

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" }