re PR c++/58080 (internal compiler error, decltype in function declaration (for SFINA...
authorPaolo Carlini <paolo.carlini@oracle.com>
Mon, 5 Aug 2013 22:03:52 +0000 (22:03 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 5 Aug 2013 22:03:52 +0000 (22:03 +0000)
/c-family
2013-08-05  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/58080
* c-common.c (pointer_int_sum): Add bool parameter.
* c-common.h (pointer_int_sum): Adjust declaration.

/cp
2013-08-05  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/58080
* typeck.c (cp_pointer_int_sum): Add tsubst_flags_t parameter.
(cp_build_binary_op): Adjust.

/testsuite
2013-08-05  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/58080
* g++.dg/cpp0x/pr58080.C: New.

From-SVN: r201512

gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/c-family/c-common.h
gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/pr58080.C [new file with mode: 0644]

index b83c5363637d0c8a5624496d5e4996cd66e53b1f..823c0f79b5aec555a60cf8cafa5df71501756601 100644 (file)
@@ -1,3 +1,9 @@
+2013-08-05  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/58080
+       * c-common.c (pointer_int_sum): Add bool parameter.
+       * c-common.h (pointer_int_sum): Adjust declaration.
+
 2013-08-05  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
        * c-pretty-print.c (print_c_tree): Simplify.  Use non-static local
index 2c806abe47033161879b9462c34cc037275a4b12..5d1a1c6c2ce7c87cac65b581d22c88b3529c5d8f 100644 (file)
@@ -4284,7 +4284,7 @@ shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr,
 
 tree
 pointer_int_sum (location_t loc, enum tree_code resultcode,
-                tree ptrop, tree intop)
+                tree ptrop, tree intop, bool complain)
 {
   tree size_exp, ret;
 
@@ -4293,14 +4293,20 @@ pointer_int_sum (location_t loc, enum tree_code resultcode,
 
   if (TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE)
     {
-      pedwarn (loc, OPT_Wpointer_arith,
-              "pointer of type %<void *%> used in arithmetic");
+      if (complain && warn_pointer_arith)
+       pedwarn (loc, OPT_Wpointer_arith,
+                "pointer of type %<void *%> used in arithmetic");
+      else if (!complain)
+       return error_mark_node;
       size_exp = integer_one_node;
     }
   else if (TREE_CODE (TREE_TYPE (result_type)) == FUNCTION_TYPE)
     {
-      pedwarn (loc, OPT_Wpointer_arith,
-              "pointer to a function used in arithmetic");
+      if (complain && warn_pointer_arith)
+       pedwarn (loc, OPT_Wpointer_arith,
+                "pointer to a function used in arithmetic");
+      else if (!complain)
+       return error_mark_node;
       size_exp = integer_one_node;
     }
   else
index dc430c3859c895b18a13ba0d1a9eefeed354f643..cc09dbc008fc85557a4db241c10b8b641ddea766 100644 (file)
@@ -790,7 +790,8 @@ extern tree shorten_binary_op (tree result_type, tree op0, tree op1, bool bitwis
    and, if so, perhaps change them both back to their original type.  */
 extern tree shorten_compare (tree *, tree *, tree *, enum tree_code *);
 
-extern tree pointer_int_sum (location_t, enum tree_code, tree, tree);
+extern tree pointer_int_sum (location_t, enum tree_code, tree, tree,
+                            bool = true);
 
 /* Add qualifiers to a type, in the fashion for C.  */
 extern tree c_build_qualified_type (tree, int);
index a52cbc9c9a98296b865ff635a5261f60cff49956..f85fd3f1b32c51c8ebaa779ade803d389bd07c5f 100644 (file)
@@ -1,3 +1,9 @@
+2013-08-05  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/58080
+       * typeck.c (cp_pointer_int_sum): Add tsubst_flags_t parameter.
+       (cp_build_binary_op): Adjust.
+
 2013-08-04  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
        * cxx-pretty-print.h (pp_c_base): Remove.
index 6f330559adf06793833b86e7ff899cd0aed9848f..e09c325d51bac4c262221f866659c19212dfedf1 100644 (file)
@@ -43,7 +43,7 @@ static tree pfn_from_ptrmemfunc (tree);
 static tree delta_from_ptrmemfunc (tree);
 static tree convert_for_assignment (tree, tree, impl_conv_rhs, tree, int,
                                    tsubst_flags_t, int);
-static tree cp_pointer_int_sum (enum tree_code, tree, tree);
+static tree cp_pointer_int_sum (enum tree_code, tree, tree, tsubst_flags_t);
 static tree rationalize_conditional_expr (enum tree_code, tree, 
                                          tsubst_flags_t);
 static int comp_ptr_ttypes_real (tree, tree, int);
@@ -4064,7 +4064,8 @@ cp_build_binary_op (location_t location,
            }
          return cp_pointer_int_sum (code,
                                     ptr_operand, 
-                                    int_operand);
+                                    int_operand,
+                                    complain);
        }
       common = 1;
       break;
@@ -4894,7 +4895,8 @@ build_x_vec_perm_expr (location_t loc,
    of pointer PTROP and integer INTOP.  */
 
 static tree
-cp_pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop)
+cp_pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop,
+                   tsubst_flags_t complain)
 {
   tree res_type = TREE_TYPE (ptrop);
 
@@ -4906,7 +4908,8 @@ cp_pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop)
   complete_type (TREE_TYPE (res_type));
 
   return pointer_int_sum (input_location, resultcode, ptrop,
-                         fold_if_not_in_template (intop));
+                         fold_if_not_in_template (intop),
+                         complain & tf_warning_or_error);
 }
 
 /* Return a tree for the difference of pointers OP0 and OP1.
index 403a2685cf5f5f65da18fab786febe29733aa44a..92aff7a9f5116067a44516a790eee08d87efce7f 100644 (file)
@@ -1,3 +1,8 @@
+2013-08-05  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/58080
+       * g++.dg/cpp0x/pr58080.C: New.
+
 2013-08-05  David Malcolm  <dmalcolm@redhat.com>
 
        * lib/plugin-support.exp (plugin-test-execute): Add -fno-rtti
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr58080.C b/gcc/testsuite/g++.dg/cpp0x/pr58080.C
new file mode 100644 (file)
index 0000000..82f200d
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/58080
+// { dg-do compile { target c++11 } }
+
+template<class A, class B>
+struct Eval
+{
+  void foo(A a, B b) { bar(a,b, 0); }
+  auto bar(A a, B b, decltype(a+b)* _) -> decltype(a+b) { return a+b; }  // { dg-error "pointer" }
+};
+
+int main()
+{
+  Eval<int,void*> eiv; eiv.foo(0,0);
+}