diff mbox

[PR,61340] Add default label to two switches on enum ipa_ref_use

Message ID 20140603160056.GC18456@virgil.suse
State New
Headers show

Commit Message

Martin Jambor June 3, 2014, 4 p.m. UTC
Hi,

in PR 61340 it has been reported that clang warns about unhandeld enum
values in a switch (gcc does not, I guess I'll open a new PR for
that).

Fixed thusly by adding a default label with a gcc_unreachable() in
both.  The potentially unhandled enum value in both cases is
IPA_REF_ALIAS which we cannot encounter because

1) in ipa-pure-const.c we are not processing aliases and

2) in ipa-reference.c we analyze references of a function to a
   variable and that cannot be an alias.

OK for trunk?

Thanks,

Martin


2014-06-03  Martin Jambor  <mjambor@suse.cz>

	PR ipa/61340
	* ipa-pure-const.c (propagate_pure_const): Add unreachable default
	handler for switch on an ipa_ref_use enum.
	* ipa-reference.c (analyze_function): Likewise.

Comments

Jan Hubicka June 3, 2014, 7:13 p.m. UTC | #1
> Hi,
> 
> in PR 61340 it has been reported that clang warns about unhandeld enum
> values in a switch (gcc does not, I guess I'll open a new PR for
> that).
> 
> Fixed thusly by adding a default label with a gcc_unreachable() in
> both.  The potentially unhandled enum value in both cases is
> IPA_REF_ALIAS which we cannot encounter because
> 
> 1) in ipa-pure-const.c we are not processing aliases and
> 
> 2) in ipa-reference.c we analyze references of a function to a
>    variable and that cannot be an alias.
> 
> OK for trunk?

OK,
thanks!
Honza
> 
> Thanks,
> 
> Martin
> 
> 
> 2014-06-03  Martin Jambor  <mjambor@suse.cz>
> 
> 	PR ipa/61340
> 	* ipa-pure-const.c (propagate_pure_const): Add unreachable default
> 	handler for switch on an ipa_ref_use enum.
> 	* ipa-reference.c (analyze_function): Likewise.
> 
> diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
> index 0ebfe5d..b9a3d3e 100644
> --- a/gcc/ipa-pure-const.c
> +++ b/gcc/ipa-pure-const.c
> @@ -1286,6 +1286,8 @@ propagate_pure_const (void)
>  		  break;
>  		case IPA_REF_ADDR:
>  		  break;
> +		default:
> +		  gcc_unreachable ();
>  		}
>  	      better_state (&ref_state, &ref_looping,
>  			    w_l->state_previously_known,
> diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c
> index ebff60c..bc58cfa 100644
> --- a/gcc/ipa-reference.c
> +++ b/gcc/ipa-reference.c
> @@ -483,6 +483,8 @@ analyze_function (struct cgraph_node *fn)
>  	  break;
>  	case IPA_REF_ADDR:
>  	  break;
> +	default:
> +	  gcc_unreachable ();
>  	}
>      }
>  
>
diff mbox

Patch

diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
index 0ebfe5d..b9a3d3e 100644
--- a/gcc/ipa-pure-const.c
+++ b/gcc/ipa-pure-const.c
@@ -1286,6 +1286,8 @@  propagate_pure_const (void)
 		  break;
 		case IPA_REF_ADDR:
 		  break;
+		default:
+		  gcc_unreachable ();
 		}
 	      better_state (&ref_state, &ref_looping,
 			    w_l->state_previously_known,
diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c
index ebff60c..bc58cfa 100644
--- a/gcc/ipa-reference.c
+++ b/gcc/ipa-reference.c
@@ -483,6 +483,8 @@  analyze_function (struct cgraph_node *fn)
 	  break;
 	case IPA_REF_ADDR:
 	  break;
+	default:
+	  gcc_unreachable ();
 	}
     }