From c5ce25ce936111be5585cd18f882b0730ab2f787 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 26 Oct 2011 17:59:36 +0000 Subject: [PATCH] re PR c++/50870 ([C++0x] [4.6/4.7 Regression] ICE with decltype, operator->, and default template arguments) 2011-10-26 Paolo Carlini * typeck.c (cp_build_addr_expr_1): Use BASELINK_P. * class.c (instantiate_type): Likewise. * pt.c (convert_nontype_argument_function, uses_template_parms, tsubst_copy, resolve_nondeduced_context, type_dependent_expression_p): Likewise. * semantics.c (finish_decltype_type): Likewise. * decl2.c (mark_used): Likewise. * name-lookup.c (arg_assoc): Likewise. /cp 2011-10-26 Paolo Carlini PR c++/50870 * typeck.c (non_reference): Pass NULL_TREE through. /testsuite 2011-10-26 Paolo Carlini PR c++/50870 * g++.dg/cpp0x/decltype34.C: New. From-SVN: r180531 --- gcc/cp/ChangeLog | 16 ++++++++++++++++ gcc/cp/class.c | 2 +- gcc/cp/decl2.c | 2 +- gcc/cp/name-lookup.c | 2 +- gcc/cp/pt.c | 10 +++++----- gcc/cp/semantics.c | 2 +- gcc/cp/typeck.c | 4 ++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/decltype34.C | 19 +++++++++++++++++++ 9 files changed, 51 insertions(+), 11 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/decltype34.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2ca141d00eb7..e6a9a90affee 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,19 @@ +2011-10-26 Paolo Carlini + + * typeck.c (cp_build_addr_expr_1): Use BASELINK_P. + * class.c (instantiate_type): Likewise. + * pt.c (convert_nontype_argument_function, uses_template_parms, + tsubst_copy, resolve_nondeduced_context, type_dependent_expression_p): + Likewise. + * semantics.c (finish_decltype_type): Likewise. + * decl2.c (mark_used): Likewise. + * name-lookup.c (arg_assoc): Likewise. + +2011-10-26 Paolo Carlini + + PR c++/50870 + * typeck.c (non_reference): Pass NULL_TREE through. + 2011-10-25 Jason Merrill PR c++/50866 diff --git a/gcc/cp/class.c b/gcc/cp/class.c index ee6ca049d3f2..03521e50345d 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -6873,7 +6873,7 @@ instantiate_type (tree lhstype, tree rhs, tsubst_flags_t flags) } } - if (TREE_CODE (rhs) == BASELINK) + if (BASELINK_P (rhs)) { access_path = BASELINK_ACCESS_BINFO (rhs); rhs = BASELINK_FUNCTIONS (rhs); diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 6e5f7cc7d751..9851ece58800 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -4174,7 +4174,7 @@ mark_used (tree decl) like the DECL for the function. Otherwise, if the BASELINK is for an overloaded function, we don't know which function was actually used until after overload resolution. */ - if (TREE_CODE (decl) == BASELINK) + if (BASELINK_P (decl)) { decl = BASELINK_FUNCTIONS (decl); if (really_overloaded_fn (decl)) diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 7141c84fcf4b..7b61d68208a5 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -5329,7 +5329,7 @@ arg_assoc (struct arg_lookup *k, tree n) n = TREE_OPERAND (n, 1); while (TREE_CODE (n) == TREE_LIST) n = TREE_VALUE (n); - if (TREE_CODE (n) == BASELINK) + if (BASELINK_P (n)) n = BASELINK_FUNCTIONS (n); if (TREE_CODE (n) == FUNCTION_DECL) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 79da3730502c..7aea72d4e59e 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -5277,7 +5277,7 @@ convert_nontype_argument_function (tree type, tree expr) fn_no_ptr = fn; if (TREE_CODE (fn_no_ptr) == ADDR_EXPR) fn_no_ptr = TREE_OPERAND (fn_no_ptr, 0); - if (TREE_CODE (fn_no_ptr) == BASELINK) + if (BASELINK_P (fn_no_ptr)) fn_no_ptr = BASELINK_FUNCTIONS (fn_no_ptr); /* [temp.arg.nontype]/1 @@ -7801,7 +7801,7 @@ uses_template_parms (tree t) || EXPR_P (t) || TREE_CODE (t) == TEMPLATE_PARM_INDEX || TREE_CODE (t) == OVERLOAD - || TREE_CODE (t) == BASELINK + || BASELINK_P (t) || TREE_CODE (t) == IDENTIFIER_NODE || TREE_CODE (t) == TRAIT_EXPR || TREE_CODE (t) == CONSTRUCTOR @@ -11993,7 +11993,7 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) base, name, /*template_p=*/false); } - else if (TREE_CODE (name) == BASELINK) + else if (BASELINK_P (name)) name = tsubst_baselink (name, non_reference (TREE_TYPE (object)), args, complain, @@ -15197,7 +15197,7 @@ resolve_nondeduced_context (tree orig_expr) offset = expr; expr = TREE_OPERAND (expr, 1); } - if (TREE_CODE (expr) == BASELINK) + if (BASELINK_P (expr)) { baselink = expr; expr = BASELINK_FUNCTIONS (expr); @@ -19314,7 +19314,7 @@ type_dependent_expression_p (tree expression) if (TREE_CODE (expression) == SCOPE_REF) return false; - if (TREE_CODE (expression) == BASELINK) + if (BASELINK_P (expression)) expression = BASELINK_FUNCTIONS (expression); if (TREE_CODE (expression) == TEMPLATE_ID_EXPR) diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 84f112cd3cb7..ec38a473715f 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5115,7 +5115,7 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p, step. */ expr = TREE_OPERAND (expr, 1); - if (TREE_CODE (expr) == BASELINK) + if (BASELINK_P (expr)) /* See through BASELINK nodes to the underlying function. */ expr = BASELINK_FUNCTIONS (expr); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index e583faaca7da..068819ebe870 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -4946,7 +4946,7 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue, tsubst_flags_t complain) if (TREE_CODE (arg) == OFFSET_REF) PTRMEM_OK_P (val) = PTRMEM_OK_P (arg); } - else if (TREE_CODE (TREE_OPERAND (arg, 1)) == BASELINK) + else if (BASELINK_P (TREE_OPERAND (arg, 1))) { tree fn = BASELINK_FUNCTIONS (TREE_OPERAND (arg, 1)); @@ -8322,7 +8322,7 @@ casts_away_constness (tree t1, tree t2) tree non_reference (tree t) { - if (TREE_CODE (t) == REFERENCE_TYPE) + if (t && TREE_CODE (t) == REFERENCE_TYPE) t = TREE_TYPE (t); return t; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c7745ad1a6a1..868e4b0d204a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-10-26 Paolo Carlini + + PR c++/50870 + * g++.dg/cpp0x/decltype34.C: New. + 2011-10-26 Tom de Vries * gcc.c-torture/unsorted/HIcmp.c: Fix unaligned pointer. diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype34.C b/gcc/testsuite/g++.dg/cpp0x/decltype34.C new file mode 100644 index 000000000000..fbd15c2797d8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype34.C @@ -0,0 +1,19 @@ +// PR c++/50870 +// { dg-options "-std=gnu++0x" } + +struct impl +{ + template static T create(); +}; + +template()->impl::create())> +struct tester{}; + +tester ti; + +template()->impl::create())> +int test() { return 0; } + +int i = test(); -- 2.47.2