re PR c++/23959 (-Wswitch-default reports missing default in a template that has one)

2005-10-16  Andrew Pinski  <pinskia@physics.uc.edu>

        PR c++/23959
        * decl.c (pop_switch): Only call c_do_switch_warnings
        when not processing templates.

2005-10-16  Andrew Pinski  <pinskia@physics.uc.edu>

        PR c++/23959
        * g++.dg/warn/Wswitch-default-1.C: New test.
        * g++.dg/warn/Wswitch-default-2.C: New test.

From-SVN: r105466
This commit is contained in:
Andrew Pinski 2005-10-16 21:13:11 +00:00 committed by Andrew Pinski
parent 5bf8b82d52
commit dddf9a0a08
5 changed files with 59 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2005-10-16 Andrew Pinski <pinskia@physics.uc.edu>
PR c++/23959
* decl.c (pop_switch): Only call c_do_switch_warnings
when not processing templates.
2005-10-16 Mark Mitchell <mark@codesourcery.com>
PR c++/22173

View File

@ -2415,9 +2415,10 @@ pop_switch (void)
switch_location = EXPR_LOCATION (cs->switch_stmt);
else
switch_location = input_location;
c_do_switch_warnings (cs->cases, switch_location,
SWITCH_STMT_TYPE (cs->switch_stmt),
SWITCH_STMT_COND (cs->switch_stmt));
if (!processing_template_decl)
c_do_switch_warnings (cs->cases, switch_location,
SWITCH_STMT_TYPE (cs->switch_stmt),
SWITCH_STMT_COND (cs->switch_stmt));
splay_tree_delete (cs->cases);
switch_stack = switch_stack->next;

View File

@ -1,3 +1,9 @@
2005-10-16 Andrew Pinski <pinskia@physics.uc.edu>
PR c++/23959
* g++.dg/warn/Wswitch-default-1.C: New test.
* g++.dg/warn/Wswitch-default-2.C: New test.
2005-10-16 Mark Mitchell <mark@codesourcery.com>
PR c++/22173

View File

@ -0,0 +1,22 @@
// PR C++/21123
/* { dg-do compile } */
/* { dg-options "-Wswitch-default" } */
template <typename ArrayType>
void foo( )
{
int i = 0;
switch ( i ) /* { dg-bogus "switch missing default case" } */
{
case 9:
default:
break;
}
}
void f()
{
foo<int>();
}

View File

@ -0,0 +1,21 @@
// PR C++/21123
/* { dg-do compile } */
/* { dg-options "-Wswitch-default" } */
template <typename ArrayType>
void foo( )
{
int i = 0;
switch ( i ) /* { dg-warning "switch missing default case" } */
{
case 9:
break;
}
}
void f()
{
foo<int>();
}