diff mbox

C++ PATCH for c++/61556 (constexpr member function)

Message ID 53A47DC5.1090806@redhat.com
State New
Headers show

Commit Message

Jason Merrill June 20, 2014, 6:30 p.m. UTC
Now that we're calling build_this in build_over_call, it needs to happen 
on the template path as well.

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox

Patch

commit daf445b34181c222baa792e7310fc4af2d26ec3c
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jun 19 14:29:51 2014 +0200

    	PR c++/61556
    	* call.c (build_over_call): Call build_this in template path.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index e147abd..da91433 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -6896,7 +6896,7 @@  build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
 
 	  ++nargs;
 	  alcarray = XALLOCAVEC (tree, nargs);
-	  alcarray[0] = first_arg;
+	  alcarray[0] = build_this (first_arg);
 	  FOR_EACH_VEC_SAFE_ELT (args, ix, arg)
 	    alcarray[ix + 1] = arg;
 	  argarray = alcarray;
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-template7.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-template7.C
new file mode 100644
index 0000000..e835dbf
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-template7.C
@@ -0,0 +1,32 @@ 
+// PR c++/61556
+// { dg-do compile { target c++11 } }
+
+class ValueType {
+public:
+    constexpr operator int() const {return m_ID;};
+    constexpr ValueType(const int v)
+        : m_ID(v) {}
+private:
+    int m_ID;
+};
+
+class ValueTypeEnum {
+public:
+    static constexpr ValueType doubleval = ValueType(1);
+};
+
+template <int format>
+class ValueTypeInfo {
+};
+
+template <typename Format>
+class FillFunctor {
+public:
+    FillFunctor() {
+        ValueTypeInfo<ValueTypeEnum::doubleval> v;
+    }
+};
+
+int main() {
+    ValueTypeInfo<ValueTypeEnum::doubleval> v;
+}