mangle.c (write_type): Handle 'auto'.
authorJason Merrill <jason@redhat.com>
Wed, 21 Mar 2012 04:04:39 +0000 (00:04 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 21 Mar 2012 04:04:39 +0000 (00:04 -0400)
gcc/cp/
* mangle.c (write_type): Handle 'auto'.
* init.c (build_new): Don't do auto deduction where it might
affect template mangling.
libiberty/
* cp-demangle.c (cplus_demangle_type): Handle 'auto'.

From-SVN: r185595

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/cp/mangle.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/auto32.C [new file with mode: 0644]
libiberty/ChangeLog
libiberty/cp-demangle.c
libiberty/testsuite/demangle-expected

index 5fbf3f57a45f1f2a7d31636e50102760f27837bd..8dcc4462d04959165fc36a2b544c5991cda74652 100644 (file)
@@ -1,5 +1,9 @@
 2012-03-20  Jason Merrill  <jason@redhat.com>
 
+       * mangle.c (write_type): Handle 'auto'.
+       * init.c (build_new): Don't do auto deduction where it might
+       affect template mangling.
+
        PR c++/52510
        * decl.c (reshape_init_class): Handle repeated reshaping.
        * search.c (lookup_field_1): Add sanity check.
index 1b2a1ef15ae530e0263d006c54f2099632f4ed02..bcb5ab7a23bece4a0d36cf265837a567b696eecf 100644 (file)
@@ -2774,7 +2774,9 @@ build_new (VEC(tree,gc) **placement, tree type, tree nelts,
   if (type == error_mark_node)
     return error_mark_node;
 
-  if (nelts == NULL_TREE && VEC_length (tree, *init) == 1)
+  if (nelts == NULL_TREE && VEC_length (tree, *init) == 1
+      /* Don't do auto deduction where it might affect mangling.  */
+      && (!processing_template_decl || at_function_scope_p ()))
     {
       tree auto_node = type_uses_auto (type);
       if (auto_node)
index 5d6beb5d5782674a62f03fc8b36334478f3e9cf4..1536828a32cbfc3ff89a51bb373769ca2744c355 100644 (file)
@@ -1933,6 +1933,13 @@ write_type (tree type)
              break;
 
            case TEMPLATE_TYPE_PARM:
+             if (is_auto (type))
+               {
+                 write_identifier ("Da");
+                 ++is_builtin_type;
+                 break;
+               }
+             /* else fall through.  */
            case TEMPLATE_PARM_INDEX:
              write_template_param (type);
              break;
index cca054e87f70e85435b46fddc9cdcab1476936cb..71f1fe7ed773fd6af94a6352d9a21fe8757fcdfe 100644 (file)
@@ -1,3 +1,7 @@
+2012-03-20  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/cpp0x/auto32.C: New.
+
 2012-03-20  Georg-Johann Lay  <avr@gjlay.de>
 
        PR testsuite/52641
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto32.C b/gcc/testsuite/g++.dg/cpp0x/auto32.C
new file mode 100644 (file)
index 0000000..2aad34e
--- /dev/null
@@ -0,0 +1,9 @@
+// { dg-do compile { target c++11 } }
+
+// { dg-final { scan-assembler "_Z1fIiEDTnw_Dapifp_EET_" } }
+template <class T> auto f(T t) -> decltype (new auto(t));
+
+int main()
+{
+  f(1);
+}
index 97bdfed4cc6d7add41b8b41e1471b5f5b4a31205..add9ff9d1a7cdb1f78f79e8d6849a6560ee8f19a 100644 (file)
@@ -1,3 +1,7 @@
+2012-03-20  Jason Merrill  <jason@redhat.com>
+
+       * cp-demangle.c (cplus_demangle_type): Handle 'auto'.
+
 2012-03-07  Jason Merrill  <jason@redhat.com>
 
        * cp-demangle.c (cplus_demangle_operators): Add li.
index 2b3d1820c6089ca55b489e6124e41bb1d6585360..d95b56c71a9cae2bb3b9842c28885ca8173b9a20 100644 (file)
@@ -2270,6 +2270,11 @@ cplus_demangle_type (struct d_info *di)
                             cplus_demangle_type (di), NULL);
          can_subst = 1;
          break;
+
+       case 'a':
+         /* auto */
+         ret = d_make_name (di, "auto", 4);
+         break;
          
        case 'f':
          /* 32-bit decimal floating point */
index 036c481351377e32d62fb0aeb132f4e7bce58d16..d489692f0b646ece74615ce0ad6c30c6aab84cc9 100644 (file)
@@ -4075,6 +4075,12 @@ decltype (new int{}) f1<int>(int)
 --format=gnu-v3
 _Zli2_wPKc
 operator"" _w(char const*)
+--format=gnu-v3
+_Z1fIiEDTnw_Dapifp_EET_
+decltype (new auto({parm#1})) f<int>(int)
+--format=gnu-v3
+_Z1fIiERDaRKT_S1_
+auto& f<int>(int const&, int)
 #
 # Ada (GNAT) tests.
 #