diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-03-02 16:18:25 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-03-02 16:18:25 +0000 |
commit | 2ad2700dbf70b2e49575f3f2307839a45cf2f71c (patch) | |
tree | 439173557b232012ba0a62b06779c1e702a93d2f | |
parent | 19159b3ec4b14270bfb66ca39fd9b792b2812c5b (diff) | |
download | gcc-2ad2700dbf70b2e49575f3f2307839a45cf2f71c.tar.gz |
/cp
2012-03-02 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/51989
* typeck2.c (build_x_arrow): Take a tsubst_flags_t argument and
propagate it.
* cp-tree.h (build_x_arrow): Adjust prototype.
* pt.c (tsubst_copy_and_build): Adjust call.
* parser.c (cp_parser_postfix_dot_deref_expression): Likewise.
/testsuite
2012-03-02 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/51989
* g++.dg/cpp0x/sfinae32.C: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@184796 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 2 | ||||
-rw-r--r-- | gcc/cp/parser.c | 3 | ||||
-rw-r--r-- | gcc/cp/pt.c | 2 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 23 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/sfinae32.C | 18 |
7 files changed, 50 insertions, 12 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1749cc134c7..6d73ea813e2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,14 @@ 2012-03-02 Paolo Carlini <paolo.carlini@oracle.com> + PR c++/51989 + * typeck2.c (build_x_arrow): Take a tsubst_flags_t argument and + propagate it. + * cp-tree.h (build_x_arrow): Adjust prototype. + * pt.c (tsubst_copy_and_build): Adjust call. + * parser.c (cp_parser_postfix_dot_deref_expression): Likewise. + +2012-03-02 Paolo Carlini <paolo.carlini@oracle.com> + * name-lookup.c (binding_to_template_parms_of_scope_p): Clean up. 2012-02-29 Jason Merrill <jason@redhat.com> diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index d435dbdaa0a..71573ff0b37 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5880,7 +5880,7 @@ extern void check_narrowing (tree, tree); extern tree digest_init (tree, tree, tsubst_flags_t); extern tree digest_init_flags (tree, tree, int); extern tree build_scoped_ref (tree, tree, tree *); -extern tree build_x_arrow (tree); +extern tree build_x_arrow (tree, tsubst_flags_t); extern tree build_m_component_ref (tree, tree); extern tree build_functional_cast (tree, tree, tsubst_flags_t); extern tree add_exception_specifier (tree, tree, int); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 491f48e0fcc..c6bd2906203 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -5910,7 +5910,8 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser, /* If this is a `->' operator, dereference the pointer. */ if (token_type == CPP_DEREF) - postfix_expression = build_x_arrow (postfix_expression); + postfix_expression = build_x_arrow (postfix_expression, + tf_warning_or_error); /* Check to see whether or not the expression is type-dependent. */ dependent_p = type_dependent_expression_p (postfix_expression); /* The identifier following the `->' or `.' is not qualified. */ diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c9cd953decc..8f24d6180af 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13691,7 +13691,7 @@ tsubst_copy_and_build (tree t, /* Remember that there was a reference to this entity. */ if (DECL_P (op1)) mark_used (op1); - return build_x_arrow (op1); + return build_x_arrow (op1, complain); case NEW_EXPR: { diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 7793744ae4f..a2606f17abb 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1462,7 +1462,7 @@ build_scoped_ref (tree datum, tree basetype, tree* binfo_p) delegation is detected. */ tree -build_x_arrow (tree expr) +build_x_arrow (tree expr, tsubst_flags_t complain) { tree orig_expr = expr; tree type = TREE_TYPE (expr); @@ -1486,7 +1486,7 @@ build_x_arrow (tree expr) while ((expr = build_new_op (COMPONENT_REF, LOOKUP_NORMAL, expr, NULL_TREE, NULL_TREE, - &fn, tf_warning_or_error))) + &fn, complain))) { if (expr == error_mark_node) return error_mark_node; @@ -1497,7 +1497,8 @@ build_x_arrow (tree expr) if (vec_member (TREE_TYPE (expr), types_memoized)) { - error ("circular pointer delegation detected"); + if (complain & tf_error) + error ("circular pointer delegation detected"); return error_mark_node; } @@ -1510,7 +1511,8 @@ build_x_arrow (tree expr) if (last_rval == NULL_TREE) { - error ("base operand of %<->%> has non-pointer type %qT", type); + if (complain & tf_error) + error ("base operand of %<->%> has non-pointer type %qT", type); return error_mark_node; } @@ -1530,13 +1532,16 @@ build_x_arrow (tree expr) return expr; } - return cp_build_indirect_ref (last_rval, RO_NULL, tf_warning_or_error); + return cp_build_indirect_ref (last_rval, RO_NULL, complain); } - if (types_memoized) - error ("result of %<operator->()%> yields non-pointer result"); - else - error ("base operand of %<->%> is not a pointer"); + if (complain & tf_error) + { + if (types_memoized) + error ("result of %<operator->()%> yields non-pointer result"); + else + error ("base operand of %<->%> is not a pointer"); + } return error_mark_node; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4be8f24565f..9efc01be3b3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-03-02 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/51989 + * g++.dg/cpp0x/sfinae32.C: New. + 2012-03-02 Richard Guenther <rguenther@suse.de> PR tree-optimization/52406 diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae32.C b/gcc/testsuite/g++.dg/cpp0x/sfinae32.C new file mode 100644 index 00000000000..db3bf5a21fc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae32.C @@ -0,0 +1,18 @@ +// PR c++/51989 +// { dg-options -std=c++0x } + +template <typename T> +struct is_container +{ + template <typename U, typename V = decltype(((U*)0)->begin())> + static char test(U* u); + + template <typename U> static long test(...); + + enum { value = sizeof test<T>(0) == 1 }; +}; + +int main() +{ + return is_container<void>::value; +} |