re PR c++/11922 (ICE on type_unification_real)

cp:
	PR c++/11922
	* pt.c (tsubst_qualified_id): Make sure we get a non-type.
	(tsubst_expr, tsubst_copy_and_build): Pass false, not zero, as
	is_type_p to lookup_qualified_name.

	* semantics.c (finish_call_expr): Refactor some code.
testsuite:
	PR c++/11922
	* g++/dg/template/qualified-id1.C: New test.

From-SVN: r71109
This commit is contained in:
Nathan Sidwell 2003-09-05 08:38:44 +00:00 committed by Nathan Sidwell
parent 8e1daa3412
commit 12483c9f2e
5 changed files with 55 additions and 8 deletions

View File

@ -1,5 +1,12 @@
2003-09-05 Nathan Sidwell <nathan@codesourcery.com>
PR c++/11922
* pt.c (tsubst_qualified_id): Make sure we get a non-type.
(tsubst_expr, tsubst_copy_and_build): Pass false, not zero, as
is_type_p to lookup_qualified_name.
* semantics.c (finish_call_expr): Refactor some code.
PR c++/12037
* cp-tree.h (COMPOUND_EXPR_OVERLOADED): New.
(build_min_non_dep): Declare.

View File

@ -7091,7 +7091,17 @@ tsubst_qualified_id (tree qualified_id, tree args,
my_friendly_assert (!dependent_type_p (scope), 20030729);
if (!BASELINK_P (name) && !DECL_P (expr))
expr = lookup_qualified_name (scope, expr, /*is_type_p=*/0, false);
{
expr = lookup_qualified_name (scope, expr, /*is_type_p=*/0, false);
if (TREE_CODE (TREE_CODE (expr) == TEMPLATE_DECL
? DECL_TEMPLATE_RESULT (expr) : expr) == TYPE_DECL)
{
if (complain & tf_error)
error ("`%E' names a type, but a non-type is expected",
qualified_id);
return error_mark_node;
}
}
if (DECL_P (expr))
check_accessibility_of_qualified_id (expr, /*object_type=*/NULL_TREE,
@ -7549,7 +7559,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
scope = tsubst_expr (scope, args, complain, in_decl);
decl = lookup_qualified_name (scope, name,
/*is_type_p=*/0, /*complain=*/false);
/*is_type_p=*/false,
/*complain=*/false);
if (decl == error_mark_node)
qualified_name_lookup_error (scope, name);
else
@ -8225,7 +8236,8 @@ tsubst_copy_and_build (tree t,
tmpl = TREE_OPERAND (TREE_OPERAND (member, 1), 0);
args = TREE_OPERAND (TREE_OPERAND (member, 1), 1);
member = lookup_qualified_name (TREE_OPERAND (member, 0), tmpl,
/*is_type=*/0, /*complain=*/false);
/*is_type_p=*/false,
/*complain=*/false);
if (BASELINK_P (member))
BASELINK_FUNCTIONS (member)
= build_nt (TEMPLATE_ID_EXPR, BASELINK_FUNCTIONS (member),

View File

@ -1622,12 +1622,11 @@ finish_call_expr (tree fn, tree args, bool disallow_virtual, bool koenig_p)
to refer to it. */
if (!BASELINK_P (fn) && is_overloaded_fn (fn))
{
tree f;
tree f = fn;
if (TREE_CODE (fn) == TEMPLATE_ID_EXPR)
f = get_first_fn (TREE_OPERAND (fn, 0));
else
f = get_first_fn (fn);
if (TREE_CODE (f) == TEMPLATE_ID_EXPR)
f = TREE_OPERAND (f, 0);
f = get_first_fn (f);
if (DECL_FUNCTION_MEMBER_P (f))
{
tree type = currently_open_derived_class (DECL_CONTEXT (f));

View File

@ -1,5 +1,8 @@
2003-09-05 Nathan Sidwell <nathan@codesourcery.com>
PR c++/11922
* g++/dg/template/qualified-id1.C: New test.
PR c++/12037
* g++.dg/warn/noeffect4.C: New test.

View File

@ -0,0 +1,26 @@
// { dg-do compile }
// Copyright (C) 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 4 Sep 2003 <nathan@codesourcery.com>
// Origin Volker Reichelt reichelt@igpm.rwth-aachen.de
// PR 11922
struct A
{
template <bool> struct B;
struct C;
};
template <> struct A::B<false> {};
template <typename T> void foo()
{
T::C (); // { dg-error "names a type" "" }
T::template B<false>(); // { dg-error "names a type" "" }
}
void bar()
{
foo<A>(); // { dg-error "instantiated" "" }
}