re PR c++/47200 ([C++0x] ICE: in adjust_temp_type, at cp/semantics.c:5821 with missin...
authorJason Merrill <jason@redhat.com>
Wed, 2 Mar 2011 18:18:31 +0000 (13:18 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 2 Mar 2011 18:18:31 +0000 (13:18 -0500)
PR c++/47200
* semantics.c (cxx_bind_parameters_in_call): Don't call
adjust_temp_type on non-constant args.

From-SVN: r170620

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-non-const-arg2.C [new file with mode: 0644]

index 1a522e7a9797834adffef9890caa445e8eabfc85..2a5244f364e903e22ea869fb18cf908044093037 100644 (file)
@@ -1,5 +1,9 @@
 2011-03-01  Jason Merrill  <jason@redhat.com>
 
+       PR c++/47200
+       * semantics.c (cxx_bind_parameters_in_call): Don't call
+       adjust_temp_type on non-constant args.
+
        PR c++/47851
        * call.c (standard_conversion): Provide requested cv-quals on
        class rvalue conversion.
index a33a7edd314f7d30d325aa889b1588149bb809d7..6b3e9149a8015d2eb105659091a53dba387db21f 100644 (file)
@@ -5906,6 +5906,9 @@ cxx_bind_parameters_in_call (const constexpr_call *old_call, tree t,
       /* Just discard ellipsis args after checking their constantitude.  */
       if (!parms)
        continue;
+      if (*non_constant_p)
+       /* Don't try to adjust the type of non-constant args.  */
+       goto next;
 
       /* Make sure the binding has the same type as the parm.  */
       if (TREE_CODE (type) != REFERENCE_TYPE)
index ebe736c457b1cef08cd6c5dfc99a4aeedfa0d1d4..1ac00aa9f661f846050146e9ea72e56c5f6f0ad0 100644 (file)
@@ -1,3 +1,7 @@
+2011-03-01  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/cpp0x/constexpr-non-const-arg2.C: New.
+
 2011-03-02  Richard Sandiford  <richard.sandiford@linaro.org>
 
        PR rtl-optimization/47925
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-non-const-arg2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-non-const-arg2.C
new file mode 100644 (file)
index 0000000..20e05c3
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/47200
+// { dg-options "-std=c++0x -w" }
+
+template < int > struct duration
+{
+  constexpr int count ();
+  static constexpr duration min ();
+};
+
+constexpr int
+f (duration < 0 > d, duration < 0 > )
+{
+  return d.count ();
+}
+
+static_assert (f (duration < 0 >::min (), duration < 0 > ()), ""); // { dg-error "non-constant|before its definition" }