[Bug c++/70353] [5/6 regression] ICE on __PRETTY_FUNCTION__ in a constexpr function

2016-03-29 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70353

--- Comment #17 from Jason Merrill  ---
Author: jason
Date: Tue Mar 29 18:40:02 2016
New Revision: 234530

URL: https://gcc.gnu.org/viewcvs?rev=234530=gcc=rev
Log:
PR c++/70353

gcc/
* tree-inline.c (remap_decls): Don't add_local_decl if
cfun is null.
gcc/cp/
* decl.c (make_rtl_for_nonlocal_decl): Don't defer local statics
in constexpr functions.

Added:
trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-__func__2.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/decl.c
trunk/gcc/tree-inline.c

[Bug c++/70353] [5/6 regression] ICE on __PRETTY_FUNCTION__ in a constexpr function

2016-03-29 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70353
Bug 70353 depends on bug 70422, which changed state.

Bug 70422 Summary: [6 regression] Bootstrap comparison failure
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70422

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

[Bug c++/70353] [5/6 regression] ICE on __PRETTY_FUNCTION__ in a constexpr function

2016-03-28 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70353

--- Comment #16 from Martin Sebor  ---
I was just about commit the following patch for the failure (false positive) in
the test.

Index: gcc/testsuite/ChangeLog
===
--- gcc/testsuite/ChangeLog (revision 234510)
+++ gcc/testsuite/ChangeLog (working copy)
@@ -1,3 +1,8 @@
+2016-03-28  Martin Sebor  
+
+   * g++.dg/ext/fnname5.C: Adjust ERE pattern to anticipate any
+   whitespace character after the .string assembler directive.
+
 2016-03-28  Dominique d'Humieres  

g++.dg/ext/fnname5.C: Update the test for Darwin.
Index: gcc/testsuite/g++.dg/ext/fnname5.C
===
--- gcc/testsuite/g++.dg/ext/fnname5.C  (revision 234510)
+++ gcc/testsuite/g++.dg/ext/fnname5.C  (working copy)
@@ -29,5 +29,5 @@ main ()
 /* { dg-final { scan-assembler-not "_ZZN1A3fooEvE12__FUNCTION__" } } */
 /* { dg-final { scan-assembler-not "_ZZN1A3fooEiE12__FUNCTION__" } } */
 /* { dg-final { scan-assembler-not "_ZZN1A3fooEiE19__PRETTY_FUNCTION__" } } */
-/* { dg-final { scan-assembler ".(string|ascii) \"void A::foo\\(int\\)(.0)?\""
} } */
-/* { dg-final { scan-assembler ".(string|ascii) \"foo(.0)?\"" } } */
+/* { dg-final { scan-assembler ".(string|ascii)\[\[:space:\]\]*\"void
A::foo\\(int\\)(.0)?\"" } } */
+/* { dg-final { scan-assembler ".(string|ascii)\[\[:space:\]\]*\"foo(.0)?\"" }
} */

[Bug c++/70353] [5/6 regression] ICE on __PRETTY_FUNCTION__ in a constexpr function

2016-03-28 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70353

Jason Merrill  changed:

   What|Removed |Added

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

--- Comment #15 from Jason Merrill  ---
Reverted the fix because it broke bootstrap on some targets.

[Bug c++/70353] [5/6 regression] ICE on __PRETTY_FUNCTION__ in a constexpr function

2016-03-28 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70353

--- Comment #14 from Jason Merrill  ---
Author: jason
Date: Mon Mar 28 20:16:21 2016
New Revision: 234511

URL: https://gcc.gnu.org/viewcvs?rev=234511=gcc=rev
Log:
PR c++/70422

PR c++/64266
PR c++/70353
* decl.c, pt.c, constexpr.c: Revert last patch.

Added:
trunk/gcc/testsuite/g++.old-deja/g++.ext/pretty4.C
Removed:
trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-__func__2.C
trunk/gcc/testsuite/g++.dg/ext/fnname5.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/constexpr.c
trunk/gcc/cp/decl.c
trunk/gcc/cp/pt.c

[Bug c++/70353] [5/6 regression] ICE on __PRETTY_FUNCTION__ in a constexpr function

2016-03-25 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70353

Jason Merrill  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
  Known to work||6.0
 Resolution|--- |FIXED
  Known to fail|6.0 |

--- Comment #13 from Jason Merrill  ---
Fixed for 6, but the patch isn't really suitable for backporting since it's a
change in behavior.  Since 4.9 didn't accept the code, I'm going to close this.

[Bug c++/70353] [5/6 regression] ICE on __PRETTY_FUNCTION__ in a constexpr function

2016-03-25 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70353

--- Comment #12 from Jason Merrill  ---
Author: jason
Date: Fri Mar 25 21:29:26 2016
New Revision: 234484

URL: https://gcc.gnu.org/viewcvs?rev=234484=gcc=rev
Log:
PR c++/64266
PR c++/70353
Core issue 1962
* decl.c (cp_fname_init): Decay the initializer to pointer.
(cp_make_fname_decl): Set DECL_DECLARED_CONSTEXPR_P,
DECL_VALUE_EXPR, DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P.
Don't call cp_finish_decl.
* pt.c (tsubst_expr) [DECL_EXPR]: Set DECL_VALUE_EXPR,
DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P.  Don't call cp_finish_decl.
* constexpr.c (cxx_eval_constant_expression) [VAR_DECL]:
Handle DECL_VALUE_EXPR.

Added:
trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-__func__2.C
trunk/gcc/testsuite/g++.dg/ext/fnname5.C
Removed:
trunk/gcc/testsuite/g++.old-deja/g++.ext/pretty4.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/constexpr.c
trunk/gcc/cp/decl.c
trunk/gcc/cp/pt.c

[Bug c++/70353] [5/6 regression] ICE on __PRETTY_FUNCTION__ in a constexpr function

2016-03-24 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70353

Jason Merrill  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC||jason at gcc dot gnu.org,
   ||mliska at suse dot cz
   Assignee|unassigned at gcc dot gnu.org  |jason at gcc dot gnu.org

--- Comment #11 from Jason Merrill  ---
Core issue 1962 talks about changing __func__ et al to be const char * rather
than array; Martin was investigating that change but it fell off my radar. 
I'll look at finishing up his patch.

[Bug c++/70353] [5/6 regression] ICE on __PRETTY_FUNCTION__ in a constexpr function

2016-03-24 Thread ppalka at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70353

Patrick Palka  changed:

   What|Removed |Added

 CC||ppalka at gcc dot gnu.org

--- Comment #10 from Patrick Palka  ---
It's a hack, but we could pull the STRING_CST out from the artificial VAR_DECL
during constexpr evaluation to avoid referring to __func__'s symbol.

--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -3354,6 +3354,11 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx,
tree t,

 case VAR_DECL:
 case CONST_DECL:
+  if (VAR_P (t)
+ && DECL_ARTIFICIAL (t)
+ && TREE_STATIC (t)
+ && TREE_CODE (DECL_INITIAL (t)) == STRING_CST)
+   return DECL_INITIAL (t);
   /* We used to not check lval for CONST_DECL, but darwin.c uses
 CONST_DECL for aggregate constants.  */
   if (lval)

[Bug c++/70353] [5/6 regression] ICE on __PRETTY_FUNCTION__ in a constexpr function

2016-03-23 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70353

Jakub Jelinek  changed:

   What|Removed |Added

 CC||hubicka at gcc dot gnu.org,
   ||jakub at gcc dot gnu.org

--- Comment #9 from Jakub Jelinek  ---
The reason for the ICE is that __PRETTY_FUNCTION__/__FUNCTION__/__func__ are
TREE_STATIC (artificial) VAR_DECLs in the context of the corresponding
constexpr function, because of the TREE_STATIC we don't want to remap it, and
constexpr.c calls copy_fn with NULL cfun (most other callers of inlining APIs
have cfun non-NULL and usually cfun->decl matching id->dst_fn).
For the ICE, I guess we can do something like:
--- gcc/tree-inline.c.jj2016-03-16 18:50:47.0 +0100
+++ gcc/tree-inline.c   2016-03-23 16:27:08.723926525 +0100
@@ -614,9 +614,11 @@ remap_decls (tree decls, vec DINFO_LEVEL_TERSE)
  && !DECL_IGNORED_P (old_var)
But, that is insufficient, as e.g. for the #c8 testcase we then get unresolved
external symbol, because the definition of the static var is never emitted.

[Bug c++/70353] [5/6 regression] ICE on __PRETTY_FUNCTION__ in a constexpr function

2016-03-23 Thread mrlika at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70353

--- Comment #8 from Andriy Lysnevych  ---
Smaller test case:

constexpr const char* ce ()
{
   return __func__;
}

const char* c = ce ();

[Bug c++/70353] [5/6 regression] ICE on __PRETTY_FUNCTION__ in a constexpr function

2016-03-23 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70353

Richard Biener  changed:

   What|Removed |Added

   Keywords||ice-on-valid-code
   Priority|P3  |P2

[Bug c++/70353] [5/6 regression] ICE on __PRETTY_FUNCTION__ in a constexpr function

2016-03-22 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70353

--- Comment #7 from Martin Sebor  ---
I haven't had time to debug it beyond observing in the debugger that
remap_decls() defined in tree-inline.c calls add_local_decl() with the first
argument of null.  The argument is cfun (function*).

Both __func__ and __FUNCTION__ also trigger the same ICE.

[Bug c++/70353] [5/6 regression] ICE on __PRETTY_FUNCTION__ in a constexpr function

2016-03-22 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70353

Martin Sebor  changed:

   What|Removed |Added

Summary|static_assert + assert +|[5/6 regression] ICE on
   |c++14 crashes GCC   |__PRETTY_FUNCTION__ in a
   ||constexpr function

--- Comment #6 from Martin Sebor  ---
GCC 4.9 doesn't crash on the code so technically this could be considered a
regression.  Although 4.9 doesn't support C++ 14 constexpr functions consisting
of more than just a return statement, one might say it's not regression.  But
the 5.x and 5.0 both ICE even on the test C++ 11 case below, so I think
considering this a regression would be appropriate.  I've taken the liberty to
do that and also to adjust the Summary to better reflect the root cause of the
ICE.

$ cat v.c && /home/msebor/build/gcc-4.9.3/gcc/xgcc
-B/home/msebor/build/gcc-4.9.3/gcc -S -Wall -Wextra -Wpedantic -std=c++14 -xc++
v.c
constexpr int f () {
return __PRETTY_FUNCTION__ [0];
}

constexpr int i = f ();
v.c: In function ‘constexpr int f()’:
v.c:3:1: error: body of constexpr function ‘constexpr int f()’ not a
return-statement
 }
 ^
v.c: At global scope:
v.c:5:22: error: ‘constexpr int f()’ called in a constant expression
 constexpr int i = f ();
  ^