Commit 3e4a3562 by Nathan Sidwell Committed by Nathan Sidwell

PR c++/9978, c++/9708

cp:
	PR c++/9978, c++/9708
	* cp-tree.h (instantiate_template): Add tsubst_flags parameter.
	* call.c (add_template_candidate_real): Adjust
	instantiate_template call.
	* class.c (resolve_address_of_overloaded_function): Likewise.
	* decl.c (build_enumerator): Set TREE_CONSTANT.
	* pt.c (check_instantiated_args): New.
	(push_inline_template_parms_recursive): Set TREE_CONSTANT,
	TREE_READONLY.
	(build_template_parm_index): Copy TREE_CONSTANT, TREE_READONLY.
	(reduce_template_parm_level): Likewise.
	(process_template_parm): Likewise.
	(check_explicit_specialization): Adjust instantiate_template call.
	(convert_template_argument): Don't check non-type argument here.
	(lookup_template_class): Check them here.
	(tsubst_friend_function): Adjust instantiate_template call.
	(instantiate_template): Add tsubst_flags parameter, use it. Check
	instantiated args.
testsuite:
	PR c++/9978, c++/9708
	* g++.dg/ext/vlm1.C: Adjust expected error.
	* g++.dg/ext/vla2.C: New test.
	* g++.dg/template/arg1.C: New test.
	* g++.dg/template/arg2.C: New test.

From-SVN: r64714
parent c8fcf20c
2003-03-22 Nathan Sidwell <nathan@codesourcery.com>
PR c++/9978, c++/9708
* cp-tree.h (instantiate_template): Add tsubst_flags parameter.
* call.c (add_template_candidate_real): Adjust
instantiate_template call.
* class.c (resolve_address_of_overloaded_function): Likewise.
* decl.c (build_enumerator): Set TREE_CONSTANT.
* pt.c (check_instantiated_args): New.
(push_inline_template_parms_recursive): Set TREE_CONSTANT,
TREE_READONLY.
(build_template_parm_index): Copy TREE_CONSTANT, TREE_READONLY.
(reduce_template_parm_level): Likewise.
(process_template_parm): Likewise.
(check_explicit_specialization): Adjust instantiate_template call.
(convert_template_argument): Don't check non-type argument here.
(lookup_template_class): Check them here.
(tsubst_friend_function): Adjust instantiate_template call.
(instantiate_template): Add tsubst_flags parameter, use it. Check
instantiated args.
2003-03-21 Zack Weinberg <zack@codesourcery.com>
* decl.c: Update calls to shadow_warning.
......
......@@ -2275,7 +2275,7 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl,
if (i != 0)
return NULL;
fn = instantiate_template (tmpl, targs);
fn = instantiate_template (tmpl, targs, tf_none);
if (fn == error_mark_node)
return NULL;
......
......@@ -5989,7 +5989,8 @@ cannot resolve overloaded function `%D' based on conversion to type `%T'",
continue;
/* Instantiate the template. */
instantiation = instantiate_template (fn, targs);
instantiation = instantiate_template (fn, targs,
complain ? tf_error : tf_none);
if (instantiation == error_mark_node)
/* Instantiation failed. */
continue;
......
......@@ -4016,7 +4016,7 @@ extern tree lookup_template_class (tree, tree, tree, tree, int, tsubst_flags_t)
extern tree lookup_template_function (tree, tree);
extern int uses_template_parms (tree);
extern tree instantiate_class_template (tree);
extern tree instantiate_template (tree, tree);
extern tree instantiate_template (tree, tree, tsubst_flags_t);
extern int fn_type_unification (tree, tree, tree, tree, tree, unification_kind_t, int);
extern tree tinst_for_decl (void);
extern void mark_decl_instantiated (tree, int);
......
......@@ -13286,8 +13286,8 @@ build_enumerator (tree name, tree value, tree enumtype)
decl = build_decl (CONST_DECL, name, type);
DECL_CONTEXT (decl) = FROB_CONTEXT (context);
TREE_CONSTANT (decl) = TREE_READONLY (decl) = 1;
DECL_INITIAL (decl) = value;
TREE_READONLY (decl) = 1;
if (context && context == current_class_type)
/* In something like `struct S { enum E { i = 7 }; };' we put `i'
......
2003-03-22 Nathan Sidwell <nathan@codesourcery.com>
PR c++/9978, c++/9708
* g++.dg/ext/vlm1.C: Adjust expected error.
* g++.dg/ext/vla2.C: New test.
* g++.dg/template/arg1.C: New test.
* g++.dg/template/arg2.C: New test.
2003-03-22 Bud Davis <bdavis9659@comcast.net>
* g77.f-torture/execute/select.f: New test.
......
// { dg-do compile }
// { dg-options "" }
// Copyright (C) 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 21 Mar 2003 <nathan@codesourcery.com>
// PR 9708. We unified a VLA size as a constant. Then issued bogus
// errors.
template <unsigned int N>
char* begin(char (&a) [N] );
void bar(int i)
{
char d[i] ;
begin(d); // { dg-error "no matching function" "" }
}
......@@ -4,7 +4,7 @@ template <class T> struct A {};
struct B {
static const int s;
A<int[s]> a; // { dg-error "variably modified|no type" }
A<int[s]> a; // { dg-error "variably modified|no type|trying to instantiate" }
};
const int B::s=16;
......
// { dg-do compile }
// Copyright (C) 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 21 Mar 2003 <nathan@codesourcery.com>
// PR 9978. We rejected a constant expression.
enum { val = 1 };
template <class T>
struct Bar
{
static const int A = val;
static const int B = A + 1;
};
// { dg-do compile }
// Copyright (C) 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 21 Mar 2003 <nathan@codesourcery.com>
// PR 9708. We accepted a local class
template <typename T> class X {};
void fn ()
{
class L {};
X<L> f; // { dg-error "uses local type|trying to instantiate|expected" "" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment