* c-typeck.c (build_function_call): Check for calling a function
with qualified void return types. Call require_complete_type when
generating a trap.
testsuite:
* gcc.dg/call-diag-2.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146324
138bc75d-0d04-0410-961f-
82ee72b054a4
+2009-04-18 Joseph Myers <joseph@codesourcery.com>
+
+ PR c/35210
+ * c-typeck.c (build_function_call): Check for calling a function
+ with qualified void return types. Call require_complete_type when
+ generating a trap.
+
2009-04-18 Jan Hubicka <jh@suse.cz>
* cgraph.c (cgraph_make_edge, dump_cgraph_node, cgraph_set_call_stmt):
trap = build2 (COMPOUND_EXPR, void_type_node, argarray[i], trap);
if (VOID_TYPE_P (return_type))
- return trap;
+ {
+ if (TYPE_QUALS (return_type) != TYPE_UNQUALIFIED)
+ pedwarn (input_location, 0,
+ "function with qualified void return type called");
+ return trap;
+ }
else
{
tree rhs;
else
rhs = fold_convert (return_type, integer_zero_node);
- return build2 (COMPOUND_EXPR, return_type, trap, rhs);
+ return require_complete_type (build2 (COMPOUND_EXPR, return_type,
+ trap, rhs));
}
}
function, nargs, argarray);
if (VOID_TYPE_P (TREE_TYPE (result)))
- return result;
+ {
+ if (TYPE_QUALS (TREE_TYPE (result)) != TYPE_UNQUALIFIED)
+ pedwarn (input_location, 0,
+ "function with qualified void return type called");
+ return result;
+ }
return require_complete_type (result);
}
\f
2009-04-18 Joseph Myers <joseph@codesourcery.com>
+ PR c/35210
+ * gcc.dg/call-diag-2.c: New test.
+
+2009-04-18 Joseph Myers <joseph@codesourcery.com>
+
PR preprocessor/39646
* gcc.dg/cpp/line8.c: New test.
--- /dev/null
+/* Test diagnostics for calling function returning qualified void or
+ other incomplete type other than void. PR 35210. */
+/* { dg-do compile } */
+/* { dg-options "-pedantic-errors" } */
+
+const void f_cv (void);
+struct s f_s (void);
+void f_v (void);
+
+void g1 (void) { f_cv (); } /* { dg-error "qualified void" } */
+void g2 (void) { f_s (); } /* { dg-error "invalid use of undefined type" } */
+void g3 (void) { ((const void (*) (void)) f_v) (); } /* { dg-error "qualified void" } */
+/* { dg-warning "function called through a non-compatible type" "cast" { target *-*-* } 12 } */
+/* { dg-message "will abort" "abort" { target *-*-* } 12 } */
+void g4 (void) { ((struct s (*) (void)) f_v) (), (void) 0; } /* { dg-error "invalid use of undefined type" } */
+/* { dg-warning "function called through a non-compatible type" "cast" { target *-*-* } 15 } */
+/* { dg-message "will abort" "abort" { target *-*-* } 15 } */