cp:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 5 Sep 2003 08:38:44 +0000 (08:38 +0000)
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 5 Sep 2003 08:38:44 +0000 (08:38 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@71109 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/qualified-id1.C [new file with mode: 0644]

index 6b7662f..1f78927 100644 (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.
index c163018..f8f38f0 100644 (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),
index d3191a9..d8ac60d 100644 (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));
index 693ae0c..2b99c09 100644 (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.
 
diff --git a/gcc/testsuite/g++.dg/template/qualified-id1.C b/gcc/testsuite/g++.dg/template/qualified-id1.C
new file mode 100644 (file)
index 0000000..bbe23c2
--- /dev/null
@@ -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" "" }
+}