OSDN Git Service

Fix PR debug/49130
authordodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 7 Jun 2011 11:12:50 +0000 (11:12 +0000)
committerdodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 7 Jun 2011 11:12:50 +0000 (11:12 +0000)
gcc/c-family/

* c-pretty-print.c (pp_c_integer_constant): Consider the canonical
type when using pointer comparison to compare types.

gcc/testsuite/

* g++.dg/debug/dwarf2/integer-typedef.C: New test.

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

gcc/c-family/ChangeLog
gcc/c-family/c-pretty-print.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/dwarf2/integer-typedef.C [new file with mode: 0644]

index 38a6d55..f0592f5 100644 (file)
@@ -1,3 +1,9 @@
+2011-06-07  Dodji Seketeli  <dodji@redhat.com>
+
+       PR debug/49130
+       * c-pretty-print.c (pp_c_integer_constant): Consider the canonical
+       type when using pointer comparison to compare types.
+
 2011-06-02  Jonathan Wakely  <jwakely.gcc@gmail.com>
 
        * c.opt: Add -Wdelete-non-virtual-dtor.
index e418903..1be3dd4 100644 (file)
@@ -1,5 +1,5 @@
 /* Subroutines common to both C and C++ pretty-printers.
-   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
    Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
 
@@ -901,7 +901,12 @@ pp_c_string_literal (c_pretty_printer *pp, tree s)
 static void
 pp_c_integer_constant (c_pretty_printer *pp, tree i)
 {
-  tree type = TREE_TYPE (i);
+  /* We are going to compare the type of I to other types using
+     pointer comparison so we need to use its canonical type.  */
+  tree type =
+    TYPE_CANONICAL (TREE_TYPE (i))
+    ? TYPE_CANONICAL (TREE_TYPE (i))
+    : TREE_TYPE (i);
 
   if (TREE_INT_CST_HIGH (i) == 0)
     pp_wide_integer (pp, TREE_INT_CST_LOW (i));
index a83814a..1795690 100644 (file)
@@ -1,3 +1,8 @@
+2011-06-07  Dodji Seketeli  <dodji@redhat.com>
+
+       PR debug/49130
+       * g++.dg/debug/dwarf2/integer-typedef.C: New test.
+
 2011-06-07  Andrew Stubbs  <ams@codesourcery.com>
 
        * gcc.target/arm/smlatb-1.c: New file.
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/integer-typedef.C b/gcc/testsuite/g++.dg/debug/dwarf2/integer-typedef.C
new file mode 100644 (file)
index 0000000..42b3c99
--- /dev/null
@@ -0,0 +1,28 @@
+// Origin: PR debug/49130
+// { dg-options "-g -dA" }
+
+typedef long unsigned int size_t;
+static const size_t foo = 2048;
+
+template<size_t size>
+struct S
+{
+  void f(size_t);
+};
+
+template<size_t size>
+inline void
+S<size>::f(size_t)
+{
+  size_t i = size;
+}
+
+int
+main()
+{
+  S<foo> s1;
+  s1.f(10);
+}
+
+// { dg-final {scan-assembler-times "\[^\n\r\]*DW_AT_name: \"S<2048ul>\"" 1 } }
+// { dg-final {scan-assembler-times "\[^\n\r\]*DW_AT_MIPS_linkage_name: \"_ZN1SILm2048EE1fEm\"" 1 } }