User account creation filtered due to spam.

Bug 44311

Summary: [C++0x] no error with switch over enum class and integer case
Product: gcc Reporter: Jörg Richter <joerg.richter>
Component: c++Assignee: Jason Merrill <jason>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs, jason
Priority: P3    
Version: 4.5.0   
Target Milestone: 4.6.1   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2011-05-25 05:32:34

Description Jörg Richter 2010-05-28 12:28:09 UTC
$ cat t.cc
enum class A { Val0, Val1 };

void foo( A a )
{
  switch( a )
  {
    case A::Val0: break;
    case 1: break;
  }
}

$ g++ -std=c++0x -c template.cc
<works>

I think there should be a compile error in line 8.
Comment 1 Jason Merrill 2011-05-25 20:02:45 UTC
Author: jason
Date: Wed May 25 20:02:41 2011
New Revision: 174231

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174231
Log:
	PR c++/44311
	* decl.c (case_conversion): New.
	(finish_case_label): Use it.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-switch2.C
    trunk/gcc/testsuite/g++.dg/cpp0x/enum15.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
    trunk/gcc/testsuite/ChangeLog
Comment 2 Jason Merrill 2011-05-25 20:30:26 UTC
Author: jason
Date: Wed May 25 20:30:21 2011
New Revision: 174237

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174237
Log:
	PR c++/44311
	* decl.c (case_conversion): New.
	(finish_case_label): Use it.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/constexpr-switch2.C
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/enum15.C
Modified:
    branches/gcc-4_6-branch/gcc/cp/ChangeLog
    branches/gcc-4_6-branch/gcc/cp/decl.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Comment 3 Jason Merrill 2011-05-26 03:07:34 UTC
Fixed for 4.6.1.