diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2003-09-05 08:38:44 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2003-09-05 08:38:44 +0000 |
commit | 12483c9f2e0c237977f2e2ee190492274f7f0d28 (patch) | |
tree | 0f5cce31b1086b96c55db1488aad78c82b94fc6c /gcc | |
parent | 8e1daa341261864912c3b19c87c78babd4a80edf (diff) | |
download | gcc-12483c9f2e0c237977f2e2ee190492274f7f0d28.zip gcc-12483c9f2e0c237977f2e2ee190492274f7f0d28.tar.gz gcc-12483c9f2e0c237977f2e2ee190492274f7f0d28.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/pt.c | 18 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/qualified-id1.C | 26 |
5 files changed, 55 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6b7662f..1f78927 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c163018..f8f38f0 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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), diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index d3191a9..d8ac60d9 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -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)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 693ae0c..2b99c09 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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. diff --git a/gcc/testsuite/g++.dg/template/qualified-id1.C b/gcc/testsuite/g++.dg/template/qualified-id1.C new file mode 100644 index 0000000..bbe23c2 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/qualified-id1.C @@ -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" "" } +} |