[Bug c++/91505] [10 Regression] ICE in DECL_FUNCTION_CODE, at tree.h:3896

2019-08-21 Thread rsandifo at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91505

rsandifo at gcc dot gnu.org  changed:

   What|Removed |Added

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

--- Comment #9 from rsandifo at gcc dot gnu.org  
---
Fixed on trunk.

[Bug c++/91505] [10 Regression] ICE in DECL_FUNCTION_CODE, at tree.h:3896

2019-08-21 Thread rsandifo at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91505

--- Comment #8 from rsandifo at gcc dot gnu.org  
---
Author: rsandifo
Date: Wed Aug 21 13:59:31 2019
New Revision: 274799

URL: https://gcc.gnu.org/viewcvs?rev=274799=gcc=rev
Log:
[C++] Protect call to copy_attributes_to_builtin (PR91505)

copy_attributes_to_builtin only handles BUILT_IN_NORMAL, but C++ was
calling it immediately after the:

  if (DECL_BUILT_IN_CLASS (newdecl) == BUILT_IN_NORMAL)

block.  The corresponding C code calls it inside the block instead.

2019-08-21  Richard Sandiford  

gcc/cp/
PR c++/91505
* decl.c (duplicate_decls): Call copy_attributes_to_builtin inside
the BUILT_IN_NORMAL block rather than afterward.

gcc/testsuite/
PR c++/91505
* g++.target/i386/crc32-4.C: New test.

Added:
trunk/gcc/testsuite/g++.target/i386/crc32-4.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/decl.c
trunk/gcc/testsuite/ChangeLog

[Bug c++/91505] [10 Regression] ICE in DECL_FUNCTION_CODE, at tree.h:3896

2019-08-21 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91505

--- Comment #7 from Marek Polacek  ---
(In reply to Andrew Pinski from comment #4)
> >This should fix it:
> 
> Except it is wrong.
> builtin_decl_explicit should be only used with BUILT_IN_NORMAL class.

I wish it would say so then; it only checks BUILTIN_VALID_P.

(In reply to rsand...@gcc.gnu.org from comment #6)
> Yeah, the C++ frontend calls copy_attributes_to_builtin outside
> the BUILT_IN_NORMAL block, whereas the C frontend calls it inside.

Good catch.  Thanks for fixing it.

[Bug c++/91505] [10 Regression] ICE in DECL_FUNCTION_CODE, at tree.h:3896

2019-08-21 Thread rsandifo at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91505

rsandifo at gcc dot gnu.org  changed:

   What|Removed |Added

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

--- Comment #6 from rsandifo at gcc dot gnu.org  
---
Yeah, the C++ frontend calls copy_attributes_to_builtin outside
the BUILT_IN_NORMAL block, whereas the C frontend calls it inside.

Testing a patch.

[Bug c++/91505] [10 Regression] ICE in DECL_FUNCTION_CODE, at tree.h:3896

2019-08-21 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91505

Richard Biener  changed:

   What|Removed |Added

 CC||rsandifo at gcc dot gnu.org

--- Comment #5 from Richard Biener  ---
Yep, the fix is likely in the caller.

[Bug c++/91505] [10 Regression] ICE in DECL_FUNCTION_CODE, at tree.h:3896

2019-08-20 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91505

--- Comment #4 from Andrew Pinski  ---
>This should fix it:

Except it is wrong.
builtin_decl_explicit should be only used with BUILT_IN_NORMAL class.

[Bug c++/91505] [10 Regression] ICE in DECL_FUNCTION_CODE, at tree.h:3896

2019-08-20 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91505

--- Comment #3 from Marek Polacek  ---
This should fix it:
diff --git a/gcc/attribs.c b/gcc/attribs.c
index b89be5834de..90055a612b9 100644
--- a/gcc/attribs.c
+++ b/gcc/attribs.c
@@ -1525,7 +1525,15 @@ duplicate_one_attribute (tree *attrs, tree attr, const
char *name)
 void
 copy_attributes_to_builtin (tree decl)
 {
-  tree b = builtin_decl_explicit (DECL_FUNCTION_CODE (decl));
+  int fcode;
+  if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
+fcode = DECL_FUNCTION_CODE (decl);
+  else if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_MD)
+fcode = DECL_MD_FUNCTION_CODE (decl);
+  else
+fcode = DECL_FE_FUNCTION_CODE (decl);
+
+  tree b = builtin_decl_explicit (static_cast(fcode));
   if (b)
 duplicate_one_attribute (_ATTRIBUTES (b),
 DECL_ATTRIBUTES (decl), "omp declare simd");

[Bug c++/91505] [10 Regression] ICE in DECL_FUNCTION_CODE, at tree.h:3896

2019-08-20 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91505

--- Comment #2 from Marek Polacek  ---
Started with r274404.

[Bug c++/91505] [10 Regression] ICE in DECL_FUNCTION_CODE, at tree.h:3896

2019-08-20 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91505

Marek Polacek  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-08-20
 CC||mpolacek at gcc dot gnu.org
   Target Milestone|--- |10.0
 Ever confirmed|0   |1

--- Comment #1 from Marek Polacek  ---
Confirmed.