From: Jason Merrill Date: Mon, 1 Aug 2011 21:02:07 +0000 (-0400) Subject: re PR c++/49932 ([C++0x] ICE on instantiating decltype(expr)::type with template) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4bbff96e369cf96ee1c6bd3fd9f7728c08e05da8;p=gcc.git re PR c++/49932 ([C++0x] ICE on instantiating decltype(expr)::type with template) PR c++/49932 gcc/cp/ * mangle.c (write_prefix): Handle decltype. libiberty/ * cp-demangle.c (d_prefix): Handle decltype. From-SVN: r177074 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6dda726a1a0..4ce77d41553 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2011-08-01 Jason Merrill + PR c++/49932 + * mangle.c (write_prefix): Handle decltype. + PR c++/49924 * semantics.c (cxx_eval_vec_init_1): Fix logic. diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 4a83c9adb2e..eb3f144b561 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -952,6 +952,7 @@ write_nested_name (const tree decl) /* ::= ::= ::= + ::= ::= # empty ::= */ @@ -968,6 +969,12 @@ write_prefix (const tree node) MANGLE_TRACE_TREE ("prefix", node); + if (TREE_CODE (node) == DECLTYPE_TYPE) + { + write_type (node); + return; + } + if (find_substitution (node)) return; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e3626441401..4ff8a1010d4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2011-08-01 Jason Merrill + PR c++/49932 + * g++.dg/abi/mangle49.C: New. + PR c++/49924 * g++.dg/cpp0x/constexpr-array4.C: New. diff --git a/gcc/testsuite/g++.dg/abi/mangle49.C b/gcc/testsuite/g++.dg/abi/mangle49.C new file mode 100644 index 00000000000..a258dc2d443 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/mangle49.C @@ -0,0 +1,22 @@ +// PR c++/49932 +// { dg-options "-std=c++0x -fabi-version=0" } + +template < typename T > +auto +f1( T x ) // ICE on here + -> typename decltype( x )::type {} + +template < typename T > +typename decltype( T() )::type +f2( T x ) {} // ICE on here + +struct S { typedef void type; }; + +void g() +{ + f1( S() ); + f2( S() ); +} + +// { dg-final { scan-assembler "_Z2f1I1SENDtfp_E4typeET_" } } +// { dg-final { scan-assembler "_Z2f2I1SENDTcvT__EE4typeES1_" } } diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 2c5b761020c..b88399e9e36 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,9 @@ +2011-08-01 Jason Merrill + + PR c++/49932 + * cp-demangle.c (d_prefix): Handle decltype. + * testsuite/demangle-expected: Test it. + 2011-07-26 H.J. Lu * testsuite/demangle-expected: Remove an extra line. diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index f41856be6d0..d67a9e74e65 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -1280,6 +1280,7 @@ d_nested_name (struct d_info *di) /* ::= ::= ::= + ::= ::= ::= @@ -1308,10 +1309,19 @@ d_prefix (struct d_info *di) here. */ comb_type = DEMANGLE_COMPONENT_QUAL_NAME; - if (IS_DIGIT (peek) + if (peek == 'D') + { + char peek2 = d_peek_next_char (di); + if (peek2 == 'T' || peek2 == 't') + /* Decltype. */ + dc = cplus_demangle_type (di); + else + /* Destructor name. */ + dc = d_unqualified_name (di); + } + else if (IS_DIGIT (peek) || IS_LOWER (peek) || peek == 'C' - || peek == 'D' || peek == 'U' || peek == 'L') dc = d_unqualified_name (di); diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected index f9e84473c0b..3737cfd7bdb 100644 --- a/libiberty/testsuite/demangle-expected +++ b/libiberty/testsuite/demangle-expected @@ -3901,6 +3901,10 @@ java resource java/util/iso4217.properties --format=gnu-v3 _Z3addIidEDTplfp_fp0_ET_T0_ decltype ({parm#1}+{parm#2}) add(int, double) +# decltype scope test +--format=gnu-v3 +_Z1fI1SENDtfp_E4typeET_ +decltype ({parm#1})::type f(S) # decltype/fn call test --format=gnu-v3 _Z4add3IidEDTclL_Z1gEfp_fp0_EET_T0_