This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH][C++] Fix PR65091
- From: Andrea Azzarone <azzaronea at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 21 Feb 2015 13:12:42 +0100
- Subject: [PATCH][C++] Fix PR65091
- Authentication-results: sourceware.org; auth=none
Hi all,
please find attached a fix for pr 65071 "decltype(~arg) fails for
template functions". Basically we need to make sure that ~arg is
considered an expression and not a dtor.
2015-02-21 Andrea Azzarone <azzaronea@gmail.com>
PR c++/65091
* parser.c (cp_parser_decltype_expr): Make sure ~id is treated as an
expression.
--
Andrea Azzarone
Index: gcc/cp/parser.c
===================================================================
--- gcc/cp/parser.c (revision 220698)
+++ gcc/cp/parser.c (working copy)
@@ -12236,7 +12236,10 @@ cp_parser_decltype_expr (cp_parser *pars
/*declarator_p=*/false,
/*optional_p=*/false);
- if (!cp_parser_error_occurred (parser) && expr != error_mark_node)
+ if (!cp_parser_error_occurred (parser)
+ && expr
+ && expr != error_mark_node
+ && (TREE_CODE (expr) != BIT_NOT_EXPR || TYPE_P (TREE_OPERAND (expr, 0))))
{
bool non_integral_constant_expression_p = false;
tree id_expression = expr;
Index: gcc/testsuite/g++.dg/cpp0x/trailing10.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/trailing10.C (revision 0)
+++ gcc/testsuite/g++.dg/cpp0x/trailing10.C (working copy)
@@ -0,0 +1,11 @@
+// PR c++/65091
+// { dg-do compile { target c++11 } }
+
+template<typename T>
+auto foo(T x) -> decltype(~x) {
+ return ~x;
+}
+
+int bar() {
+ return foo(10);
+}