]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
typeck.c (build_const_cast): Tweak last change to handle templates correctly.
authorMark Mitchell <mark@codesourcery.com>
Fri, 30 Apr 1999 16:07:03 +0000 (16:07 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 30 Apr 1999 16:07:03 +0000 (16:07 +0000)
* typeck.c (build_const_cast): Tweak last change to handle
templates correctly.

From-SVN: r26712

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

index 3bb29de5a567782571bb42d49abf1e3a46397d45..584c9714d426554190321209ca02e8acfa668ae7 100644 (file)
@@ -1,5 +1,8 @@
 1999-04-30  Mark Mitchell  <mark@codesourcery.com>
 
+       * typeck.c (build_const_cast): Tweak last change to handle
+       templates correctly.
+
        * typeck.c (build_const_cast): Disallow use of const_cast to
        anything but a pointer or reference type.
 
index c01131adec3759e23be12fe6afd863e4b05f811b..ad7f552b1cb4748524a1437d85ada858ea08c2c8 100644 (file)
@@ -5633,14 +5633,6 @@ build_const_cast (type, expr)
   if (type == error_mark_node || expr == error_mark_node)
     return error_mark_node;
 
-  if (!POINTER_TYPE_P (type) && !TYPE_PTRMEMFUNC_P (type))
-    {
-      cp_error ("`%T' is not a pointer, reference, or pointer-to-member type",
-               type);
-      cp_error ("as required by const_cast");
-      return error_mark_node;
-    }
-
   if (TREE_CODE (expr) == OFFSET_REF)
     expr = resolve_offset_ref (expr);
 
@@ -5651,6 +5643,14 @@ build_const_cast (type, expr)
       return t;
     }
 
+  if (!POINTER_TYPE_P (type) && !TYPE_PTRMEMFUNC_P (type))
+    {
+      cp_error ("`%T' is not a pointer, reference, or pointer-to-member type",
+               type);
+      cp_error ("as required by const_cast");
+      return error_mark_node;
+    }
+
   if (TREE_CODE (type) != REFERENCE_TYPE)
     {
       expr = decay_conversion (expr);
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/cast1.C b/gcc/testsuite/g++.old-deja/g++.pt/cast1.C
new file mode 100644 (file)
index 0000000..e37b169
--- /dev/null
@@ -0,0 +1,7 @@
+// Build don't link:
+// Origin: Mark Mitchell <mark@codesourcery.com>
+
+template <class T>
+void f (T t) {
+  const_cast<T>(t);
+}