mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-22 18:31:48 +08:00
decl.c (start_preparsed_function): Call check_function_type even in templates.
* decl.c (start_preparsed_function): Call check_function_type even in templates. (require_complete_types_for_parms): Skip dependent types. (check_function_type): Likewise. * g++.dg/template/incomplete1.C: New test. From-SVN: r90779
This commit is contained in:
parent
f4e649d2d2
commit
c938791573
@ -1,3 +1,10 @@
|
||||
2004-11-16 Giovanni Bajo <giovannibajo@gcc.gnu.org>
|
||||
|
||||
* decl.c (start_preparsed_function): Call check_function_type even
|
||||
in templates.
|
||||
(require_complete_types_for_parms): Skip dependent types.
|
||||
(check_function_type): Likewise.
|
||||
|
||||
2004-11-16 Steven Bosscher <stevenb@suse.de>
|
||||
|
||||
* Make-lang.in (cp/decl.o, cp/search.o): Don't depend on stack.h.
|
||||
|
@ -8271,6 +8271,8 @@ require_complete_types_for_parms (tree parms)
|
||||
{
|
||||
for (; parms; parms = TREE_CHAIN (parms))
|
||||
{
|
||||
if (dependent_type_p (TREE_TYPE (parms)))
|
||||
continue;
|
||||
if (VOID_TYPE_P (TREE_TYPE (parms)))
|
||||
/* grokparms will have already issued an error. */
|
||||
TREE_TYPE (parms) = error_mark_node;
|
||||
@ -9840,6 +9842,8 @@ check_function_type (tree decl, tree current_function_parms)
|
||||
/* In a function definition, arg types must be complete. */
|
||||
require_complete_types_for_parms (current_function_parms);
|
||||
|
||||
if (dependent_type_p (return_type))
|
||||
return;
|
||||
if (!COMPLETE_OR_VOID_TYPE_P (return_type))
|
||||
{
|
||||
error ("return type %q#T is incomplete", TREE_TYPE (fntype));
|
||||
@ -9985,8 +9989,7 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
|
||||
/* Make sure the parameter and return types are reasonable. When
|
||||
you declare a function, these types can be incomplete, but they
|
||||
must be complete when you define the function. */
|
||||
if (! processing_template_decl)
|
||||
check_function_type (decl1, current_function_parms);
|
||||
check_function_type (decl1, current_function_parms);
|
||||
|
||||
/* Build the return declaration for the function. */
|
||||
restype = TREE_TYPE (fntype);
|
||||
|
@ -1,3 +1,7 @@
|
||||
2004-11-16 Giovanni Bajo <giovannibajo@gcc.gnu.org>
|
||||
|
||||
* g++.dg/template/incomplete1.C: New test.
|
||||
|
||||
2004-11-16 Nick Clifton <nickc@redhat.com>
|
||||
|
||||
Revert patches accidentally commited during checkin of fixes for
|
||||
|
18
gcc/testsuite/g++.dg/template/incomplete1.C
Normal file
18
gcc/testsuite/g++.dg/template/incomplete1.C
Normal file
@ -0,0 +1,18 @@
|
||||
// { dg-do compile }
|
||||
// Origin: Ivan Godard <igodard at pacbell dot net>
|
||||
// PR c++/17447: Detect parameters of dependent types even in templates
|
||||
|
||||
struct B; // { dg-error "forward declaration" }
|
||||
template<typename T> struct A {
|
||||
|
||||
friend A& operator <<(A& a, B b) { return a; } // { dg-error "incomplete" }
|
||||
friend A& operator <<(A& a, T b) { return a; }
|
||||
|
||||
void foo1(B b) {} // { dg-error "incomplete" }
|
||||
void foo1a(T b) {}
|
||||
|
||||
B foo2(void) {} // { dg-error "incomplete" }
|
||||
T foo2a(void) {}
|
||||
|
||||
void foo3(B b);
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user