aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2008-12-17 14:08:14 -0500
committerJason Merrill <jason@gcc.gnu.org>2008-12-17 14:08:14 -0500
commita77f94e24084115b80f1eb05836d7538b3500c36 (patch)
tree2fc764010bfc532f00bb2946a496b9d1884f5ed0 /gcc/testsuite/g++.dg
parent3aea2d1ce29ba8a41d54857de2c5bcf1a4dce254 (diff)
downloadgcc-a77f94e24084115b80f1eb05836d7538b3500c36.zip
gcc-a77f94e24084115b80f1eb05836d7538b3500c36.tar.gz
gcc-a77f94e24084115b80f1eb05836d7538b3500c36.tar.bz2
semantics.c (describable_type): New function.
gcc/cp: * semantics.c (describable_type): New function. (finish_decltype_type): Use it for dependent exprs. * cp-tree.h: Declare it. * mangle.c (write_type) [DECLTYPE_TYPE]: Set skip_evaluation. (write_expression): If skip_evaluation, use type stubs. * tree.c (cp_tree_equal): Handle PARM_DECLs from different declarations of a function. * init.c (build_new): Do auto deduction if type is describable. * decl.c (cp_finish_decl): Likewise. * parser.c (cp_parser_omp_for_loop): Likewise. gcc/testsuite: * g++.dg/cpp0x/auto6.C: Test more stuff. * g++.dg/cpp0x/auto12.C: New test. libiberty: * cp-demangle.c (d_expression): Handle rvalue stubs too. [DEMANGLE_COMPONENT_CAST]: Update mangling. (d_print_comp): Avoid extra ", " with empty template argument packs. Remove handling for obsolete T() mangling. From-SVN: r142799
Diffstat (limited to 'gcc/testsuite/g++.dg')
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/auto12.C52
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/auto6.C29
2 files changed, 79 insertions, 2 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto12.C b/gcc/testsuite/g++.dg/cpp0x/auto12.C
new file mode 100644
index 0000000..94652cb5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/auto12.C
@@ -0,0 +1,52 @@
+// More auto/decltype mangling tests.
+// { dg-options "-std=c++0x" }
+
+template <class T>
+struct B
+{
+ static int i;
+};
+
+int&& x();
+
+template <class T>
+struct A
+{
+ static int i;
+ static int &ir;
+ static int &&irr;
+ template <class U>
+ auto f(U u) -> decltype (u + i);
+ template <class U>
+ auto fr(U u) -> decltype (u + ir);
+ template <class U>
+ auto frr(U u) -> decltype (u + irr);
+ template <class U>
+ auto g(U u) -> decltype (u + sizeof (i));
+ template <class U>
+ auto h(U u) -> decltype (u + B<U>::i);
+ template <class U>
+ auto j(U u) -> decltype (u + x());
+};
+
+template<class T> template<class U>
+auto A<T>::f(U u) -> decltype (u + i)
+{
+ return u + i;
+}
+
+int main()
+{
+ // { dg-final { scan-assembler "_ZN1AIiE1fIiEEDTplsTT_sTiES2_" } }
+ A<int>().f(1);
+ // { dg-final { scan-assembler "_ZN1AIiE2frIiEEDTplsTT_sTiES2_" } }
+ A<int>().fr(1);
+ // { dg-final { scan-assembler "_ZN1AIiE3frrIiEEDTplsTT_sTiES2_" } }
+ A<int>().frr(1);
+ // { dg-final { scan-assembler "_ZN1AIiE1gIiEEDTplsTT_sRjES2_" } }
+ A<int>().g(1);
+ // { dg-final { scan-assembler "_ZN1AIiE1hIiEEDTplsTT_sr1BIS2_E1iES2_" } }
+ A<int>().h(1);
+ // { dg-final { scan-assembler "_ZN1AIiE1jIiEEDTplsTT_sRiES2_" } }
+ A<int>().j(1);
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto6.C b/gcc/testsuite/g++.dg/cpp0x/auto6.C
index d2bcfed..7d659c7 100644
--- a/gcc/testsuite/g++.dg/cpp0x/auto6.C
+++ b/gcc/testsuite/g++.dg/cpp0x/auto6.C
@@ -30,6 +30,12 @@ auto add3(T t, U u) -> decltype (ag(t,u))
return ag(t,u);
}
+template<class T, class U>
+decltype(*(T*)0+*(U*)0) add4(T t, U u)
+{
+ return t+u;
+}
+
template <class T>
struct A
{
@@ -72,13 +78,28 @@ auto k(T t, U u, V v) -> decltype (t.U::template B<V>::MEM)
return t.U::template B<V>::MEM;
}
+// For these two examples we can elide the 'decltype' and just mangle the type.
+template <class T>
+auto l(T t) -> decltype (t)
+{
+ return t;
+}
+
+template <class T, T u>
+auto m(T t) -> decltype (u)
+{
+ return t;
+}
+
A<int> a, *p;
int main()
{
- // { dg-final { scan-assembler "_Z3addIidEDTplsTT_sTT0_ES0_S1_" } }
+ // { dg-final { scan-assembler "_Z3addIidEDTplsTT_sTT0_ES0_S1_" } }
auto i = add(1, 2.0);
- // { dg-final { scan-assembler "_Z4add2IidEDTplcvT_vcvT0_vES0_S1_" } }
+ // { dg-final { scan-assembler "_Z4add4IidEDTplsTT_sTT0_ES0_S1_" } }
+ auto i4 = add4(1, 2.0);
+ // { dg-final { scan-assembler "_Z4add2IidEDTplsRT_sRT0_ES0_S1_" } }
auto i2 = add2(1, 2.0);
// { dg-final { scan-assembler "_Z4add3IidEDTclL_Z2agEsTT_sTT0_EES0_S1_" } }
auto i3 = add3(1, 2.0);
@@ -90,4 +111,8 @@ int main()
h(a,1.0);
// { dg-final { scan-assembler "_Z1kI1C1AIiE1DEDtdtsTT_srNT0_1BIT1_EE3MEMES4_S5_S7_" } }
k( C(), A<int>(), D() );
+ // { dg-final { scan-assembler "_Z1lIiET_S0_" } }
+ l(1);
+ // { dg-final { scan-assembler "_Z1mIiLi1EET_S0_" } }
+ m<int,1>(1);
}