[Bug c/77946] -Wimplicit-fallthrough=1 ICE: tree check: expected tree that contains ‘decl with visibility’ structure, have ‘label_decl’

2016-10-13 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77946

Jakub Jelinek  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #11 from Jakub Jelinek  ---
Fixed.

[Bug c/77946] -Wimplicit-fallthrough=1 ICE: tree check: expected tree that contains ‘decl with visibility’ structure, have ‘label_decl’

2016-10-13 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77946

--- Comment #10 from Jakub Jelinek  ---
Author: jakub
Date: Thu Oct 13 10:42:36 2016
New Revision: 241094

URL: https://gcc.gnu.org/viewcvs?rev=241094=gcc=rev
Log:
PR c/77946
* tree.h (FALLTHROUGH_LABEL_P): Use private_flag instead of
public_flag.
* varasm.c (default_binds_local_p_3): Formatting fix.

* c-c++-common/Wimplicit-fallthrough-34.c: New test.

Added:
trunk/gcc/testsuite/c-c++-common/Wimplicit-fallthrough-34.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree.h
trunk/gcc/varasm.c

[Bug c/77946] -Wimplicit-fallthrough=1 ICE: tree check: expected tree that contains ‘decl with visibility’ structure, have ‘label_decl’

2016-10-12 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77946

Jakub Jelinek  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |jakub at gcc dot gnu.org

--- Comment #9 from Jakub Jelinek  ---
Created attachment 39789
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39789=edit
gcc7-pr77946.patch

I already have it.

[Bug c/77946] -Wimplicit-fallthrough=1 ICE: tree check: expected tree that contains ‘decl with visibility’ structure, have ‘label_decl’

2016-10-12 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77946

--- Comment #8 from Marek Polacek  ---
(In reply to Jakub Jelinek from comment #5)
> I think my preference would be to try TREE_PRIVATE bit for it instead.

I can do it.

[Bug c/77946] -Wimplicit-fallthrough=1 ICE: tree check: expected tree that contains ‘decl with visibility’ structure, have ‘label_decl’

2016-10-12 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77946

--- Comment #7 from Markus Trippelsdorf  ---
(In reply to Jakub Jelinek from comment #6)
> (In reply to Marek Polacek from comment #4)
> > (In reply to Jakub Jelinek from comment #3)
> > > Thanks.  More reduced (that fails even with -Wimplicit-fallthrough):
> > 
> > Did you mean without?
> 
> No, I meant with, but that it will ICE with any level from 1 to 4 that way.

But only with -O0.

[Bug c/77946] -Wimplicit-fallthrough=1 ICE: tree check: expected tree that contains ‘decl with visibility’ structure, have ‘label_decl’

2016-10-12 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77946

--- Comment #6 from Jakub Jelinek  ---
(In reply to Marek Polacek from comment #4)
> (In reply to Jakub Jelinek from comment #3)
> > Thanks.  More reduced (that fails even with -Wimplicit-fallthrough):
> 
> Did you mean without?

No, I meant with, but that it will ICE with any level from 1 to 4 that way.

[Bug c/77946] -Wimplicit-fallthrough=1 ICE: tree check: expected tree that contains ‘decl with visibility’ structure, have ‘label_decl’

2016-10-12 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77946

--- Comment #5 from Jakub Jelinek  ---
The problem is that varasm.c uses TREE_PUBLIC on all decls, but it now means
something different on LABEL_DECLs.  So either we tweak it:
--- gcc/varasm.c.jj 2016-10-09 13:19:09.0 +0200
+++ gcc/varasm.c2016-10-12 09:57:21.499076633 +0200
@@ -6847,7 +6847,7 @@ default_binds_local_p_3 (const_tree exp,
 bool extern_protected_data, bool common_local_p)
 {
   /* A non-decl is an entry in the constant pool.  */
-  if (!DECL_P (exp))
+  if (!DECL_P (exp) || TREE_CODE (exp) == LABEL_DECL)
 return true;

   /* Weakrefs may not bind locally, even though the weakref itself is always
@@ -6856,8 +6856,8 @@ default_binds_local_p_3 (const_tree exp,
  FIXME: We can resolve the weakref case more curefuly by looking at the
  weakref alias.  */
   if (lookup_attribute ("weakref", DECL_ATTRIBUTES (exp))
-  || (TREE_CODE (exp) == FUNCTION_DECL
-  && lookup_attribute ("ifunc", DECL_ATTRIBUTES (exp
+  || (TREE_CODE (exp) == FUNCTION_DECL
+ && lookup_attribute ("ifunc", DECL_ATTRIBUTES (exp
 return false;

   /* Static variables are always local.  */
@@ -6972,7 +6972,7 @@ decl_binds_to_current_def_p (const_tree
   gcc_assert (DECL_P (decl));
   if (!targetm.binds_local_p (decl))
 return false;
-  if (!TREE_PUBLIC (decl))
+  if (!TREE_PUBLIC (decl) || TREE_CODE (decl) == LABEL_DECL)
 return true;

   /* When resolution is available, just use it.  */

and wait for other spots that should change, or we choose a different flag.
I think my preference would be to try TREE_PRIVATE bit for it instead.

[Bug c/77946] -Wimplicit-fallthrough=1 ICE: tree check: expected tree that contains ‘decl with visibility’ structure, have ‘label_decl’

2016-10-12 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77946

Marek Polacek  changed:

   What|Removed |Added

 CC||mpolacek at gcc dot gnu.org

--- Comment #4 from Marek Polacek  ---
(In reply to Jakub Jelinek from comment #3)
> Thanks.  More reduced (that fails even with -Wimplicit-fallthrough):

Did you mean without?

[Bug c/77946] -Wimplicit-fallthrough=1 ICE: tree check: expected tree that contains ‘decl with visibility’ structure, have ‘label_decl’

2016-10-12 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77946

Jakub Jelinek  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2016-10-12
 Ever confirmed|0   |1

--- Comment #3 from Jakub Jelinek  ---
Thanks.  More reduced (that fails even with -Wimplicit-fallthrough):
void
foo (void)
{
  static void *p = &
  goto *p;
  /*FALLTHRU*/
  lab:;
}

[Bug c/77946] -Wimplicit-fallthrough=1 ICE: tree check: expected tree that contains ‘decl with visibility’ structure, have ‘label_decl’

2016-10-12 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77946

--- Comment #2 from Markus Trippelsdorf  ---
(In reply to Jakub Jelinek from comment #1)
> Try -save-temps with -C or -CC ?

Thanks, that works.

int a;
void fn1() {
  static int *b[] = {[0] = &_IND_B, 0};
  goto *b[a]; /**/
LD_IND_B: /*   */;
}

[Bug c/77946] -Wimplicit-fallthrough=1 ICE: tree check: expected tree that contains ‘decl with visibility’ structure, have ‘label_decl’

2016-10-12 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77946

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek  ---
Try -save-temps with -C or -CC ?