[Bug c++/94937] [10/11 Regression] ICE with if constexpr (in cp_get_fndecl_from_callee, at cp/cvt.c:1000) since r10-2835-g14da3939da3adcef

2020-05-18 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94937

--- Comment #19 from CVS Commits  ---
The master branch has been updated by Marek Polacek :

https://gcc.gnu.org/g:bf732686c0b9c42a2fe119db774c5a65e5a97174

commit r11-473-gbf732686c0b9c42a2fe119db774c5a65e5a97174
Author: Marek Polacek 
Date:   Wed May 6 19:24:58 2020 -0400

c++: ICE with -Wall and constexpr if [PR94937]

An ICE arises here because we call cp_get_callee_fndecl_nofold in a
template, and we've got a CALL_EXPR whose CALL_EXPR_FN is a BASELINK.
This tickles the INDIRECT_TYPE_P assert in cp_get_fndecl_from_callee.

Fixed by turning the assert into a condition and returning NULL_TREE
in that case.

PR c++/94937
* cvt.c (cp_get_fndecl_from_callee): Return NULL_TREE if the
function
type is not INDIRECT_TYPE_P.
* decl.c (omp_declare_variant_finalize_one): Call
cp_get_callee_fndecl_nofold instead of looking for the function
decl
manually.

* g++.dg/cpp1z/constexpr-if34.C: New test.
* g++.dg/cpp2a/is-constant-evaluated10.C: New test.

[Bug c++/94937] [10/11 Regression] ICE with if constexpr (in cp_get_fndecl_from_callee, at cp/cvt.c:1000) since r10-2835-g14da3939da3adcef

2020-05-05 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94937

--- Comment #18 from Marek Polacek  ---
Actually it might be better to make it out to a function and use that in both
places, otherwise I'm either duplicating code or it's just too ugly.

[Bug c++/94937] [10/11 Regression] ICE with if constexpr (in cp_get_fndecl_from_callee, at cp/cvt.c:1000) since r10-2835-g14da3939da3adcef

2020-05-05 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94937

--- Comment #17 from Marek Polacek  ---
Ah, omp_declare_variant_finalize_one.  I think I'll do something similar, but
not the same: if we see a CALL_EXPR whose CALL_EXPR_FN is a BASELINK, we know
it's not the std::is_constant_evaluated call we're looking for.  Thanks.

[Bug c++/94937] [10/11 Regression] ICE with if constexpr (in cp_get_fndecl_from_callee, at cp/cvt.c:1000) since r10-2835-g14da3939da3adcef

2020-05-05 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94937

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #16 from Jakub Jelinek  ---
I remember dealing with this elsewhere (in declare variant support).
I had to do:
-  variant = cp_get_callee_fndecl_nofold (variant); 
+  variant = cp_get_callee (variant);   
+  if (variant) 
+{  
+  if (TREE_CODE (variant) == FUNCTION_DECL)
+   ;   
+  else if (TREE_TYPE (variant) && INDIRECT_TYPE_P (TREE_TYPE (variant)))   
+   variant = cp_get_fndecl_from_callee (variant, false);   
+  else 
+   variant = NULL_TREE;
+}  
because cp_get_callee_fndecl_nofold would ICE (I think exactly like this one))
when feeded during processing_template_decl with something it doesn't expect to
see.

[Bug c++/94937] [10/11 Regression] ICE with if constexpr (in cp_get_fndecl_from_callee, at cp/cvt.c:1000) since r10-2835-g14da3939da3adcef

2020-05-05 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94937

--- Comment #15 from Marek Polacek  ---
Reduced:

struct B {
  static constexpr bool foo() { return false; }
};

template
struct C {
  static void bar ()
  {
if constexpr (B::foo()) ;
  }
};

[Bug c++/94937] [10/11 Regression] ICE with if constexpr (in cp_get_fndecl_from_callee, at cp/cvt.c:1000) since r10-2835-g14da3939da3adcef

2020-05-05 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94937

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|--- |10.2
   Priority|P3  |P2

[Bug c++/94937] [10/11 Regression] ICE with if constexpr (in cp_get_fndecl_from_callee, at cp/cvt.c:1000) since r10-2835-g14da3939da3adcef

2020-05-04 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94937

--- Comment #14 from Martin Liška  ---
Created attachment 48448
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48448&action=edit
Reduced test-case

[Bug c++/94937] [10/11 Regression] ICE with if constexpr (in cp_get_fndecl_from_callee, at cp/cvt.c:1000) since r10-2835-g14da3939da3adcef

2020-05-04 Thread foss at grueninger dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94937

--- Comment #13 from Christoph  ---
I tried to help with reducing the test case, but could not achieve something
substantial.
Then I went back to our test cases and tried to pick the simples one I could
find. I removed as much code from main() as I could. The resulting test case
looks only slightly smaller (7 MiB instead of 8 MiB) but it should boil down to
a smaller test case. Not sure which route is going to lead to faster results.

[Bug c++/94937] [10/11 Regression] ICE with if constexpr (in cp_get_fndecl_from_callee, at cp/cvt.c:1000) since r10-2835-g14da3939da3adcef

2020-05-04 Thread foss at grueninger dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94937

--- Comment #12 from Christoph  ---
Created attachment 48447
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48447&action=edit
output for injection test case

[Bug c++/94937] [10/11 Regression] ICE with if constexpr (in cp_get_fndecl_from_callee, at cp/cvt.c:1000) since r10-2835-g14da3939da3adcef

2020-05-04 Thread foss at grueninger dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94937

--- Comment #11 from Christoph  ---
Created attachment 48446
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48446&action=edit
New, smaller test case (called injection)

[Bug c++/94937] [10/11 Regression] ICE with if constexpr (in cp_get_fndecl_from_callee, at cp/cvt.c:1000) since r10-2835-g14da3939da3adcef

2020-05-04 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94937

Marek Polacek  changed:

   What|Removed |Added

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

--- Comment #10 from Marek Polacek  ---
Mine.  A reduced test would be very much appreciated, thanks Martin.

[Bug c++/94937] [10/11 Regression] ICE with if constexpr (in cp_get_fndecl_from_callee, at cp/cvt.c:1000) since r10-2835-g14da3939da3adcef

2020-05-04 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94937

Martin Liška  changed:

   What|Removed |Added

Summary|ICE with if constexpr (in   |[10/11 Regression] ICE with
   |cp_get_fndecl_from_callee,  |if constexpr (in
   |at cp/cvt.c:1000)   |cp_get_fndecl_from_callee,
   ||at cp/cvt.c:1000) since
   ||r10-2835-g14da3939da3adcef
  Known to fail||10.0, 11.0
   Keywords||ice-on-valid-code
 CC||mpolacek at gcc dot gnu.org
  Known to work||9.3.0

--- Comment #8 from Martin Liška  ---
Reduced command line:
$ g++ -c -c -std=c++17 -Wall -fsyntax-only -c pr94937.ii

[Bug c++/94937] [10/11 Regression] ICE with if constexpr (in cp_get_fndecl_from_callee, at cp/cvt.c:1000) since r10-2835-g14da3939da3adcef

2020-05-04 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94937

--- Comment #9 from Martin Liška  ---
Created attachment 48444
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48444&action=edit
Semi-reduced test-case

I'll carry on with the reduction, but it goes down slowly.