This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][C++] Fix PR65091


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);
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]