PR c++/21353
* g++.dg/template/defarg6.C: New.
testsuite:
PR c++/21353
* decl.c (check_default_argument): Don't check
processing_template_decl or uses_template_parms here.
(grokparms): Only call check_default_argument when not processing
a template decl.
* parser.c (cp_parser_late_parsing_default_arg): Call
check_default_argument when not processing a template decl.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@105492
138bc75d-0d04-0410-961f-
82ee72b054a4
+2005-10-17 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/21353
+ * decl.c (check_default_argument): Don't check
+ processing_template_decl or uses_template_parms here.
+ (grokparms): Only call check_default_argument when not processing
+ a template decl.
+ * parser.c (cp_parser_late_parsing_default_arg): Call
+ check_default_argument when not processing a template decl.
+
2005-10-16 Mark Mitchell <mark@codesourcery.com>
PR c++/24389
deal with it after the class is complete. */
return arg;
- if (processing_template_decl || uses_template_parms (arg))
- /* We don't do anything checking until instantiation-time. Note
- that there may be uninstantiated arguments even for an
- instantiated function, since default arguments are not
- instantiated until they are needed. */
- return arg;
-
if (TYPE_P (decl))
{
decl_type = decl;
decl, ptr ? "pointer" : "reference", t);
}
- if (!any_error && init)
- init = check_default_argument (decl, init);
- else
+ if (any_error)
init = NULL_TREE;
+ else if (init && !processing_template_decl)
+ init = check_default_argument (decl, init);
}
TREE_CHAIN (decl) = decls;
/* Parse the assignment-expression. */
parsed_arg = cp_parser_assignment_expression (parser, /*cast_p=*/false);
+ if (!processing_template_decl)
+ parsed_arg = check_default_argument (TREE_VALUE (parm), parsed_arg);
+
TREE_PURPOSE (parm) = parsed_arg;
/* Update any instantiations we've already created. */
+2005-10-17 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/21353
+ * g++.dg/template/defarg6.C: New.
+
2005-10-17 Uros Bizjak <uros@kss-loka.si>
PR target/24315
--- /dev/null
+// Copyright (C) 2005 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 14 Oct 2005 <nathan@codesourcery.com>
+
+// PR 21353 missing error.
+// Origin:Andrew Pinski <pinskia@gcc.gnu.org>
+
+enum X{ a, b, c };
+
+struct C
+{
+ static void func (X &ref = a); // { dg-error "default argument" "" }
+};
+
+template <typename T>
+struct D
+{
+ static void func (X &ref = a); // not an error at this point
+};
+
+void Foo (X & obj)
+{
+ D<int>::func (obj);
+
+ D<int>::func (); // { dg-error "default argument" "" }
+}