re PR c++/48015 ([C++0x] ICE: unexpected expression 'std::min' of kind overload)
authorJason Merrill <jason@redhat.com>
Tue, 8 Mar 2011 05:28:02 +0000 (00:28 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 8 Mar 2011 05:28:02 +0000 (00:28 -0500)
PR c++/48015
* init.c (constant_value_1): Always require init to be TREE_CONSTANT.

From-SVN: r170770

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/regress/non-const1.C [new file with mode: 0644]

index 03fe7def98315a300234251f4298e5174894ba20..a82947f205f9edfc4a4b7c21ac71973771f53e06 100644 (file)
@@ -1,5 +1,8 @@
 2011-03-07  Jason Merrill  <jason@redhat.com>
 
+       PR c++/48015
+       * init.c (constant_value_1): Always require init to be TREE_CONSTANT.
+
        PR c++/48008
        * mangle.c (write_type): Strip cv-quals from FUNCTION_TYPE here.
        (write_CV_qualifiers_for_type): Not here.
index e590118f3cfb1d3a647e192a86db431621c088c5..56f66faffdd9816f8403423f9baba87c37bfceea 100644 (file)
@@ -1760,17 +1760,15 @@ constant_value_1 (tree decl, bool integral_p)
        init = TREE_VALUE (init);
       if (!init
          || !TREE_TYPE (init)
-         || uses_template_parms (init)
-         || (integral_p
-             ? false
-             : (!TREE_CONSTANT (init)
-                /* Do not return an aggregate constant (of which
-                   string literals are a special case), as we do not
-                   want to make inadvertent copies of such entities,
-                   and we must be sure that their addresses are the
-                   same everywhere.  */
-                || TREE_CODE (init) == CONSTRUCTOR
-                || TREE_CODE (init) == STRING_CST)))
+         || !TREE_CONSTANT (init)
+         || (!integral_p
+             /* Do not return an aggregate constant (of which
+                string literals are a special case), as we do not
+                want to make inadvertent copies of such entities,
+                and we must be sure that their addresses are the
+                same everywhere.  */
+             && (TREE_CODE (init) == CONSTRUCTOR
+                 || TREE_CODE (init) == STRING_CST)))
        break;
       decl = unshare_expr (init);
     }
index f5783968966be2f21c97cfff00c93477bec6a3e7..b27cd59e5eb05a2a51398ed3a0c7b91d78c15edd 100644 (file)
@@ -1,3 +1,7 @@
+2011-03-07  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/cpp0x/regress/non-const1.C: New.
+
 2011-03-07  Jakub Jelinek  <jakub@redhat.com>
 
        PR debug/47991
diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/non-const1.C b/gcc/testsuite/g++.dg/cpp0x/regress/non-const1.C
new file mode 100644 (file)
index 0000000..7fc66a7
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/48015
+// { dg-options -std=c++0x }
+
+template <typename T> T f(T);
+template <typename T> void g()
+{
+  int const c = f (1);
+  int i = c - 0;
+}