From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- gcc/testsuite/g++.dg/cpp0x/trailing1.C | 117 +++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/trailing1.C (limited to 'gcc/testsuite/g++.dg/cpp0x/trailing1.C') diff --git a/gcc/testsuite/g++.dg/cpp0x/trailing1.C b/gcc/testsuite/g++.dg/cpp0x/trailing1.C new file mode 100644 index 000000000..f637857b4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/trailing1.C @@ -0,0 +1,117 @@ +// Tests for late-specified return type. +// { dg-options "-std=c++0x -fabi-version=5" } + +auto f() -> int +{ + return 0; +} + +template +auto add(T t, U u) -> decltype (t+u) +{ + return t+u; +} + +template +decltype(T()+U()) add2(T t, U u) +{ + return t+u; +} + +template +U ag (T, U) +{ + return U(); +} + +template +auto add3(T t, U u) -> decltype (ag(t,u)) +{ + return ag(t,u); +} + +template +decltype(*(T*)0+*(U*)0) add4(T t, U u) +{ + return t+u; +} + +template +struct A +{ + T f() {} + template + T g() {} + template + struct B + { + int MEM; + }; +}; + +template +auto f(T* t) -> decltype (t->f()) +{ + return t->f(); +} + +template +auto g(T t) -> decltype (t.f()) +{ + return t.f(); +} + +template +auto h(T t, U u) -> decltype (t.template g()) +{ + return t.template g(); +} + +struct D { }; +struct C: public A::B +{ +}; + +template +auto k(T t, U u, V v) -> decltype (t.U::template B::MEM) +{ + return t.U::template B::MEM; +} + +template +auto l(T t) -> decltype (t) +{ + return t; +} + +template +auto m(T t) -> decltype (u) +{ + return t; +} + +A a, *p; + +int main() +{ + // { dg-final { scan-assembler "_Z3addIidEDTplfp_fp0_ET_T0_" } } + auto i = add(1, 2.0); + // { dg-final { scan-assembler "_Z4add4IidEDTpldecvPT_Li0EdecvPT0_Li0EES0_S2_" } } + auto i4 = add4(1, 2.0); + // { dg-final { scan-assembler "_Z4add2IidEDTplcvT__EcvT0__EES0_S1_" } } + auto i2 = add2(1, 2.0); + // { dg-final { scan-assembler "_Z4add3IidEDTcl2agfp_fp0_EET_T0_" } } + auto i3 = add3(1, 2.0); + // { dg-final { scan-assembler "_Z1fI1AIiEEDTclptfp_1fEEPT_" } } + f(p); + // { dg-final { scan-assembler "_Z1gI1AIiEEDTcldtfp_1fEET_" } } + g(a); + // { dg-final { scan-assembler "_Z1hI1AIiEdEDTcldtfp_1gIT0_EEET_S2_" } } + h(a,1.0); + // { dg-final { scan-assembler "_Z1kI1C1AIiE1DEDtdtfp_srNT0_1BIT1_EE3MEMET_S4_S6_" } } + k( C(), A(), D() ); + // { dg-final { scan-assembler "_Z1lIiEDtfp_ET_" } } + l(1); + // { dg-final { scan-assembler "_Z1mIiLi1EEDtT0_ET_" } } + m(1); +} -- cgit v1.2.3