OSDN Git Service

PR c++/11847
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 2 Sep 2003 20:54:07 +0000 (20:54 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 2 Sep 2003 20:54:07 +0000 (20:54 +0000)
* pt.c (convert_nontype_argument): Correct representation of
REFERENCE_TYPE expressions.

PR c++/11847
* g++.dg/template/class1.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@71003 138bc75d-0d04-0410-961f-82ee72b054a4

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

index e28ff5b..b24258b 100644 (file)
@@ -1,5 +1,9 @@
 2003-09-02  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/11847
+       * pt.c (convert_nontype_argument): Correct representation of
+       REFERENCE_TYPE expressions.
+
        PR c++/11808
        * cp-tree.h (KOENIG_LOOKUP_P): New macro.
        (finish_call_expr): Change prototype.
index ae47b60..f479901 100644 (file)
@@ -3209,9 +3209,12 @@ convert_nontype_argument (tree type, tree expr)
        tree type_referred_to = TREE_TYPE (type);
 
        /* If this expression already has reference type, get the
-          underling object.  */
+          underlying object.  */
        if (TREE_CODE (expr_type) == REFERENCE_TYPE) 
          {
+           if (TREE_CODE (expr) == NOP_EXPR
+               && TREE_CODE (TREE_OPERAND (expr, 0)) == ADDR_EXPR)
+             STRIP_NOPS (expr);
            my_friendly_assert (TREE_CODE (expr) == ADDR_EXPR, 20000604);
            expr = TREE_OPERAND (expr, 0);
            expr_type = TREE_TYPE (expr);
@@ -3265,7 +3268,7 @@ convert_nontype_argument (tree type, tree expr)
          }
 
        cxx_mark_addressable (expr);
-       return build1 (ADDR_EXPR, type, expr);
+       return build_nop (type, build_address (expr));
       }
       break;
 
index f2d74d8..2cac015 100644 (file)
@@ -1,5 +1,8 @@
 2003-09-02  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/11847
+       * g++.dg/template/class1.C: New test.
+
        PR c++/11808
        * g++.dg/expr/call1.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/template/class1.C b/gcc/testsuite/g++.dg/template/class1.C
new file mode 100644 (file)
index 0000000..96415fb
--- /dev/null
@@ -0,0 +1,9 @@
+extern const int a;
+
+template <const int&> class X {};
+
+template <typename> struct Y {
+    X<a> x;
+};
+
+template struct Y<int>;