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.
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,
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
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),
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));
--- /dev/null
+// { 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" "" }
+}