OSDN Git Service

PR c++/9328
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 23 Jan 2003 00:17:32 +0000 (00:17 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 23 Jan 2003 00:17:32 +0000 (00:17 +0000)
* g++.dg/ext/typeof3.C: New test.

PR c++/9328
* error.c (dump_decl): For an OVERLOAD, just print the name of the
function; it doesn't make sense to try to print its type.
* semantics.c (finish_typeof): Issue errors about invalid uses.

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

gcc/cp/ChangeLog
gcc/cp/error.c
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/typeof3.C [new file with mode: 0644]

index f871077..9be5f76 100644 (file)
@@ -1,5 +1,10 @@
 2003-01-22  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/9328
+       * error.c (dump_decl): For an OVERLOAD, just print the name of the
+       function; it doesn't make sense to try to print its type.
+       * semantics.c (finish_typeof): Issue errors about invalid uses.
+
        PR c++/9298
        * parser.c (cp_parser_consume_semicolon_at_end_of_statement): New
        function.
index d9bc552..d53943f 100644 (file)
@@ -929,6 +929,25 @@ dump_decl (t, flags)
       break;
 
     case OVERLOAD:
+      if (OVL_CHAIN (t))
+       {
+         t = OVL_CURRENT (t);
+         if (DECL_CLASS_SCOPE_P (t))
+           {
+             dump_type (DECL_CONTEXT (t), flags);
+             output_add_string (scratch_buffer, "::");
+           }
+         else if (DECL_CONTEXT (t))
+           {
+             dump_decl (DECL_CONTEXT (t), flags);
+             output_add_string (scratch_buffer, "::");
+           }
+         dump_decl (DECL_NAME (t), flags);
+         break;
+       }
+      
+      /* If there's only one function, just treat it like an ordinary
+        FUNCTION_DECL.  */
       t = OVL_CURRENT (t);
       /* Fall through.  */
 
index adba8a5..19808e6 100644 (file)
@@ -2136,20 +2136,28 @@ tree
 finish_typeof (expr)
      tree expr;
 {
+  tree type;
+
   if (processing_template_decl)
     {
-      tree t;
+      type = make_aggr_type (TYPEOF_TYPE);
+      TYPE_FIELDS (type) = expr;
 
-      t = make_aggr_type (TYPEOF_TYPE);
-      TYPE_FIELDS (t) = expr;
-
-      return t;
+      return type;
     }
 
   if (TREE_CODE (expr) == OFFSET_REF)
     expr = resolve_offset_ref (expr);
 
-  return TREE_TYPE (expr);
+  type = TREE_TYPE (expr);
+
+  if (!type || type == unknown_type_node)
+    {
+      error ("type of `%E' is unknown", expr);
+      return error_mark_node;
+    }
+
+  return type;
 }
 
 /* Compute the value of the `sizeof' operator.  */
index 80d67ee..fb0a778 100644 (file)
@@ -1,3 +1,8 @@
+2003-01-22  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/9328
+       * g++.dg/ext/typeof3.C: New test.
+
 2003-01-22  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c++/2738
diff --git a/gcc/testsuite/g++.dg/ext/typeof3.C b/gcc/testsuite/g++.dg/ext/typeof3.C
new file mode 100644 (file)
index 0000000..cf78c7c
--- /dev/null
@@ -0,0 +1,4 @@
+double f(double);
+float f(float);
+void h(typeof(f) g) {} // { dg-error "" }