aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2015-01-21 16:56:34 -0500
committerJason Merrill <jason@gcc.gnu.org>2015-01-21 16:56:34 -0500
commitb85a3242397d2c63d1185bbc17386520335313cb (patch)
treeba6d1908f5d9c574858966bc7c4b29b0951e07b3
parentd2632e47fcd996a513420cb95de06940fa640d19 (diff)
downloadgcc-b85a3242397d2c63d1185bbc17386520335313cb.zip
gcc-b85a3242397d2c63d1185bbc17386520335313cb.tar.gz
gcc-b85a3242397d2c63d1185bbc17386520335313cb.tar.bz2
re PR c++/64603 (bogus error "no matching function for call to ..." with templates)
PR c++/64603 * constexpr.c (cxx_eval_constant_expression): Only shortcut constant CONSTRUCTORs. From-SVN: r219973
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/constexpr.c7
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-sizeof1.C15
3 files changed, 23 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 526742c..6e3a2e5 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2015-01-21 Jason Merrill <jason@redhat.com>
+ PR c++/64603
+ * constexpr.c (cxx_eval_constant_expression): Only shortcut
+ constant CONSTRUCTORs.
+
PR c++/64647
* constexpr.c (ensure_literal_type_for_constexpr_object): Don't
give a hard error in a template instantiation.
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index decc84d..7853d37 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -2943,9 +2943,6 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
*overflow_p = true;
return t;
}
- if (TREE_CODE (t) != NOP_EXPR
- && reduced_constant_expression_p (t))
- return fold (t);
switch (TREE_CODE (t))
{
@@ -3315,6 +3312,10 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
break;
case CONSTRUCTOR:
+ if (TREE_CONSTANT (t))
+ /* Don't re-process a constant CONSTRUCTOR, but do fold it to
+ VECTOR_CST if applicable. */
+ return fold (t);
r = cxx_eval_bare_aggregate (ctx, t, lval,
non_constant_p, overflow_p);
break;
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-sizeof1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-sizeof1.C
new file mode 100644
index 0000000..d9a032b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-sizeof1.C
@@ -0,0 +1,15 @@
+// PR c++/64603
+// { dg-do compile { target c++11 } }
+
+template <int i> constexpr int find_longest_name()
+{
+ return sizeof("Main") - 1;
+}
+
+template <int i, int l = find_longest_name<i>()> void create_all_loggers()
+{}
+
+int main()
+{
+ create_all_loggers<1>();
+}