]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/31671 (Non-type template of type const ref accepted as a non-const ref)
authorPaolo Carlini <paolo.carlini@oracle.com>
Fri, 11 Oct 2013 14:18:42 +0000 (14:18 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 11 Oct 2013 14:18:42 +0000 (14:18 +0000)
/cp
2013-10-11  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/31671
* pt.c (convert_nontype_argument): Set expr_type to
TREE_TYPE (probe_type).

/testsuite
2013-10-11  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/31671
* g++.dg/template/nontype26.C: New.

From-SVN: r203444

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/nontype26.C [new file with mode: 0644]

index da49d12c629b9c4e6dc3e9a92d1c689bb24a07c6..1e0c46cd45f90cbd02d64ddeac2aab9be140c348 100644 (file)
@@ -1,3 +1,9 @@
+2013-10-11  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/31671
+       * pt.c (convert_nontype_argument): Set expr_type to
+       TREE_TYPE (probe_type).
+
 2013-10-11  Jakub Jelinek  <jakub@redhat.com>
 
        * decl.c (duplicate_decls): Error out for redeclaration of UDRs.
index 5721a681a4a5c5201f288586c4bdb3845e3208ec..57b3ff04feb8521625267a3ef9f7737bb8a17960 100644 (file)
@@ -5611,7 +5611,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
                   TREE_TYPE (TREE_TYPE (addr)))))
            {
              expr = TREE_OPERAND (addr, 0);
-             expr_type = TREE_TYPE (expr);
+             expr_type = TREE_TYPE (probe_type);
            }
        }
     }
index f182ad704b5524d6d61252456b4b4264b361afb4..c27d500b211c00d300bee962073989b545f53e4b 100644 (file)
@@ -1,3 +1,8 @@
+2013-10-11  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/31671
+       * g++.dg/template/nontype26.C: New.
+
 2013-10-11  Thomas Schwinge  <thomas@codesourcery.com>
 
        * c-c++-common/cpp/openmp-define-1.c: New file.
diff --git a/gcc/testsuite/g++.dg/template/nontype26.C b/gcc/testsuite/g++.dg/template/nontype26.C
new file mode 100644 (file)
index 0000000..763d987
--- /dev/null
@@ -0,0 +1,20 @@
+// PR c++/31671
+
+template<int& i> void doit() {
+  i = 0;
+}
+
+template<const int& i> class X {
+public:
+    void foo() {
+      doit<i>();  // { dg-error "cv-qualification|no matching" }
+    }
+};
+
+int i = 0;
+
+X<i> x;
+
+int main() {
+  x.foo();
+}