pt.c (convert_nontype_argument): STRIP_NOPS where appropriate.
authorMark Mitchell <mmitchell@usa.net>
Thu, 26 Mar 1998 10:32:04 +0000 (10:32 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 26 Mar 1998 10:32:04 +0000 (10:32 +0000)
Thu Mar 26 10:25:52 1998  Mark Mitchell  <mmitchell@usa.net>
* pt.c (convert_nontype_argument): STRIP_NOPS where appropriate.

From-SVN: r18841

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.old-deja/g++.pt/nontype3.C [new file with mode: 0644]

index a7ad337..6ca4d8d 100644 (file)
@@ -1,3 +1,7 @@
+Thu Mar 26 10:25:52 1998  Mark Mitchell  <mmitchell@usa.net>
+
+       * pt.c (convert_nontype_argument): STRIP_NOPS where appropriate.
+
 Thu Mar 26 10:24:05 1998  Mark Mitchell  <mmitchell@usa.net>
 
        * call.c (build_object_call): Complain about ambiguous operator(),
index 7685f48..3c72a44 100644 (file)
@@ -1861,8 +1861,10 @@ convert_nontype_argument (type, expr)
           || expr_type == unknown_type_node)
     {
       tree referent;
+      tree e = expr;
+      STRIP_NOPS (e);
 
-      if (TREE_CODE (expr) != ADDR_EXPR)
+      if (TREE_CODE (e) != ADDR_EXPR)
        {
        bad_argument:
          cp_error ("`%E' is not a valid template argument", expr);
@@ -1874,7 +1876,7 @@ convert_nontype_argument (type, expr)
          return NULL_TREE;
        }
 
-      referent = TREE_OPERAND (expr, 0);
+      referent = TREE_OPERAND (e, 0);
       STRIP_NOPS (referent);
       
       if (TREE_CODE (referent) == STRING_CST)
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/nontype3.C b/gcc/testsuite/g++.old-deja/g++.pt/nontype3.C
new file mode 100644 (file)
index 0000000..d6f3394
--- /dev/null
@@ -0,0 +1,28 @@
+// Build don't link:
+
+enum E { e };
+
+template <const E* ep>
+struct S1
+{
+  static char* s;
+};
+
+template <int D>
+struct S2 {};
+
+template <>
+struct S2<1>
+{
+  static E es[1];
+};
+
+struct S3
+{
+  typedef S1<S2<1>::es> S3_Type;
+};
+
+E S2<1>::es[1] = {e};
+
+template <>
+char* S1<S2<1>::es>::s = "abc";