]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport:
authorVolker Reichelt <reichelt@netcologne.de>
Wed, 2 Jan 2008 23:40:41 +0000 (23:40 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Wed, 2 Jan 2008 23:40:41 +0000 (23:40 +0000)
2007-09-18  Paolo Carlini  <pcarlini@suse.de>

PR c++/33463
* cxx-pretty-print.c (pp_cxx_postfix_expression): Split
out case TYPEID_EXPR to...
(pp_cxx_typeid_expression): ... here; use pp_cxx_left_paren
and pp_cxx_right_paren.
* cxx-pretty-print.h (pp_cxx_typeid_expression): Declare.
* error.c (dump_expr): Use it.

* g++.dg/rtti/typeid6.C: New.

From-SVN: r131265

gcc/cp/ChangeLog
gcc/cp/cxx-pretty-print.c
gcc/cp/cxx-pretty-print.h
gcc/cp/error.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/rtti/typeid6.C [new file with mode: 0644]

index 08525af70462671571afabec548907708be7fa7d..b4f6477c03dbdf2eef42e03aa364156b433936e0 100644 (file)
@@ -1,3 +1,16 @@
+2008-01-02  Volker Reichelt  <reichelt@netcologne.de>
+
+       Backport:
+       2007-09-18  Paolo Carlini  <pcarlini@suse.de>
+       PR c++/33463
+       * cxx-pretty-print.c (pp_cxx_postfix_expression): Split
+       out case TYPEID_EXPR to...
+       (pp_cxx_typeid_expression): ... here; use pp_cxx_left_paren
+       and pp_cxx_right_paren.
+       * cxx-pretty-print.h (pp_cxx_typeid_expression): Declare.
+       * error.c (dump_expr): Use it.
+
 2007-12-10  Simon Martin  <simartin@users.sourceforge.net>
 
        PR c++/34059
index 01200e53e8ea269a0266d99f32fea76cded49f9d..1047010950283bc870770eb32c486502e791b484 100644 (file)
@@ -512,14 +512,7 @@ pp_cxx_postfix_expression (cxx_pretty_printer *pp, tree t)
       break;
 
     case TYPEID_EXPR:
-      t = TREE_OPERAND (t, 0);
-      pp_cxx_identifier (pp, "typeid");
-      pp_left_paren (pp);
-      if (TYPE_P (t))
-       pp_cxx_type_id (pp, t);
-      else
-       pp_cxx_expression (pp, t);
-      pp_right_paren (pp);
+      pp_cxx_typeid_expression (pp, t);
       break;
 
     case PSEUDO_DTOR_EXPR:
@@ -1968,6 +1961,19 @@ pp_cxx_declaration (cxx_pretty_printer *pp, tree t)
     }
 }
 
+void
+pp_cxx_typeid_expression (cxx_pretty_printer *pp, tree t)
+{
+  t = TREE_OPERAND (t, 0);
+  pp_cxx_identifier (pp, "typeid");
+  pp_cxx_left_paren (pp);
+  if (TYPE_P (t))
+    pp_cxx_type_id (pp, t);
+  else
+    pp_cxx_expression (pp, t);
+  pp_cxx_right_paren (pp);
+}
+
 \f
 typedef c_pretty_print_fn pp_fun;
 
index 7acf7b50d7ef3dfa353cb8fae5e504abdd30547f..5b6272416557b6bc883dfe9eb4be8450c3cf5bc5 100644 (file)
@@ -69,6 +69,7 @@ void pp_cxx_separate_with (cxx_pretty_printer *, int);
 
 void pp_cxx_declaration (cxx_pretty_printer *, tree);
 void pp_cxx_canonical_template_parameter (cxx_pretty_printer *, tree);
+void pp_cxx_typeid_expression (cxx_pretty_printer *, tree);
 
 
 #endif /* GCC_CXX_PRETTY_PRINT_H */
index f371b48d1d66d59b3396864d65c357cd97cf7719..60cdc1a509b8e150eaed753e06dfdb1be72f0a3b 100644 (file)
@@ -1893,6 +1893,10 @@ dump_expr (tree t, int flags)
       dump_expr (TREE_OPERAND (t, 0), flags);
       break;
 
+    case TYPEID_EXPR:
+      pp_cxx_typeid_expression (cxx_pp, t);
+      break;
+
       /*  This list is incomplete, but should suffice for now.
          It is very important that `sorry' does not call
          `report_error_function'.  That could cause an infinite loop.  */
index a107af2e4b2256c478dbf45ff0f2f73d0f10996c..c053dc4c327d137e911005a05f7fc9fb6d1f3290 100644 (file)
@@ -1,3 +1,11 @@
+2008-01-02  Volker Reichelt  <reichelt@netcologne.de>
+
+       Backport:
+       2007-09-18  Paolo Carlini  <pcarlini@suse.de>
+       PR c++/33463
+       * g++.dg/rtti/typeid6.C: New.
+
 2007-12-26  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        PR c++/33640
diff --git a/gcc/testsuite/g++.dg/rtti/typeid6.C b/gcc/testsuite/g++.dg/rtti/typeid6.C
new file mode 100644 (file)
index 0000000..18709b4
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/33463
+
+namespace std
+{
+  class type_info {};
+}
+
+template<int> void foo()
+{
+  !typeid(void); // { dg-error "!typeid\\(void\\)|candidates" }
+}