re PR c++/18389 (ICE on struct declaration in for statement)

PR c++/18389
	* decl.c (start_decl): Make sure to set *pop_scope_p.  Return
	error_mark_node to indicate errors.

	PR c++/18429
	* parser.c (cp_parser_direct_declarator): Disallow non-constant
	array bounds when not inside a function.

	PR c++/18436
	* pt.c (tsubst_copy_and_build): Do not do Koenig lookup when an
	unqualified name resolves to a member function.

	PR c++/18407
	* pt.c (tsubst_copy_and_build): Handle qualified names used from a
	derived class correctly.

	* decl2.c (import_export_decl): Fix typo in comment.
	* tree.c (pod_type_p): Likewise.

	PR c++/18389
	* g++.dg/parse/cond1.C: New test.

	PR c++/18429
	* g++.dg/template/array9.C: New test.
	* g++.dg/ext/vla1.C: Adjust error messages.
	* g++.dg/ext/vlm1.C: Likewise.
	* g++.dg/template/crash2.C: Likewise.

	PR c++/18436
	* g++.dg/template/call3.C: New test.

	PR c++/18407
	* g++.dg/template/ptrmem11.C: New test.

From-SVN: r90545
This commit is contained in:
Mark Mitchell 2004-11-12 21:47:13 +00:00 committed by Mark Mitchell
parent cc69336f16
commit 44370687a5
14 changed files with 123 additions and 13 deletions

View File

@ -1,3 +1,24 @@
2004-11-12 Mark Mitchell <mark@codesourcery.com>
PR c++/18389
* decl.c (start_decl): Make sure to set *pop_scope_p. Return
error_mark_node to indicate errors.
PR c++/18429
* parser.c (cp_parser_direct_declarator): Disallow non-constant
array bounds when not inside a function.
PR c++/18436
* pt.c (tsubst_copy_and_build): Do not do Koenig lookup when an
unqualified name resolves to a member function.
PR c++/18407
* pt.c (tsubst_copy_and_build): Handle qualified names used from a
derived class correctly.
* decl2.c (import_export_decl): Fix typo in comment.
* tree.c (pod_type_p): Likewise.
2004-11-10 Andrew Pinski <pinskia@physics.uc.edu>
* typeck.c (cxx_mark_addressable): Add braces around the first if.

View File

@ -3670,6 +3670,8 @@ start_decl (const cp_declarator *declarator,
tree type, tem;
tree context;
*pop_scope_p = false;
/* This should only be done once on the top most decl. */
if (have_extern_spec)
{
@ -3690,19 +3692,17 @@ start_decl (const cp_declarator *declarator,
deprecated_state = DEPRECATED_NORMAL;
if (decl == NULL_TREE || TREE_CODE (decl) == VOID_TYPE)
return NULL_TREE;
return error_mark_node;
type = TREE_TYPE (decl);
if (type == error_mark_node)
return NULL_TREE;
return error_mark_node;
context = DECL_CONTEXT (decl);
if (context)
*pop_scope_p = push_scope (context);
else
*pop_scope_p = false;
/* We are only interested in class contexts, later. */
if (context && TREE_CODE (context) == NAMESPACE_DECL)

View File

@ -1743,7 +1743,7 @@ import_export_decl (tree decl)
vague linkage, maybe_commonize_var is used.
Therefore, the only declarations that should be provided to this
function are those with external linkage that:
function are those with external linkage that are:
* implicit instantiations of function templates

View File

@ -10960,6 +10960,11 @@ cp_parser_direct_declarator (cp_parser* parser,
&non_constant_p);
if (!non_constant_p)
bounds = fold_non_dependent_expr (bounds);
else if (!at_function_scope_p ())
{
error ("array bound is not an integer constant");
bounds = error_mark_node;
}
}
else
bounds = NULL_TREE;

View File

@ -8543,7 +8543,11 @@ tsubst_copy_and_build (tree t,
lookup finds a non-function, in accordance with the
expected resolution of DR 218. */
if (koenig_p
&& (is_overloaded_fn (function)
&& ((is_overloaded_fn (function)
/* If lookup found a member function, the Koenig lookup is
not appropriate, even if an unqualified-name was used
to denote the function. */
&& !DECL_FUNCTION_MEMBER_P (get_first_fn (function)))
|| TREE_CODE (function) == IDENTIFIER_NODE))
function = perform_koenig_lookup (function, call_args);
@ -8659,9 +8663,14 @@ tsubst_copy_and_build (tree t,
/*is_type_p=*/false,
/*complain=*/false);
if (BASELINK_P (member))
BASELINK_FUNCTIONS (member)
= build_nt (TEMPLATE_ID_EXPR, BASELINK_FUNCTIONS (member),
args);
{
BASELINK_FUNCTIONS (member)
= build_nt (TEMPLATE_ID_EXPR, BASELINK_FUNCTIONS (member),
args);
member = (adjust_result_of_qualified_name_lookup
(member, BINFO_TYPE (BASELINK_BINFO (member)),
TREE_TYPE (object)));
}
else
{
qualified_name_lookup_error (TREE_TYPE (object), tmpl,

View File

@ -1716,7 +1716,7 @@ pod_type_p (tree t)
return 1; /* pointer to member */
if (TREE_CODE (t) == VECTOR_TYPE)
return 1; /* vectors are (small) arrays if scalars */
return 1; /* vectors are (small) arrays of scalars */
if (! CLASS_TYPE_P (t))
return 0; /* other non-class type (reference or function) */

View File

@ -1,3 +1,20 @@
2004-11-12 Mark Mitchell <mark@codesourcery.com>
PR c++/18389
* g++.dg/parse/cond1.C: New test.
PR c++/18429
* g++.dg/template/array9.C: New test.
* g++.dg/ext/vla1.C: Adjust error messages.
* g++.dg/ext/vlm1.C: Likewise.
* g++.dg/template/crash2.C: Likewise.
PR c++/18436
* g++.dg/template/call3.C: New test.
PR c++/18407
* g++.dg/template/ptrmem11.C: New test.
2004-11-12 Andrew Pinski <pinskia@physics.uc.edu>
PR other/14264

View File

@ -19,7 +19,7 @@ class B { B (int); };
B::B (int i)
{
struct S {
int ar[1][i]; // { dg-error "variable-size|variably modified" }
int ar[1][i]; // { dg-error "array" }
} s;
s.ar[0][0] = 0; // { dg-error "no member" }

View File

@ -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|trying to instantiate" }
A<int[s]> a; // { dg-error "array|template" }
};
const int B::s=16;

View File

@ -0,0 +1,6 @@
// PR c++/18389
void foo()
{
for (; struct A {}; ); // { dg-error "" }
}

View File

@ -0,0 +1,18 @@
// PR c++/18429
int subtrees = 4;
template< class T >
struct Tree {
Tree* L[subtrees]; // { dg-error "" }
Tree* R[subtrees]; // { dg-error "" }
~Tree()
{
delete [] L[0]; // { dg-error "" }
delete [] R[0]; // { dg-error "" }
}
};
void f()
{
Tree<int> t;
}

View File

@ -0,0 +1,15 @@
// PR c++/18436
void foo(int);
struct A
{
static void foo(A);
};
template <typename T> struct B : T
{
B() { foo(T()); }
};
B<A> b;

View File

@ -5,7 +5,7 @@ class A
{
public:
static const EnumType size = max; // { dg-error "" }
int table[size];
int table[size]; // { dg-error "" }
};
template <class EnumType>
const EnumType A<EnumType>::size;

View File

@ -0,0 +1,19 @@
// PR c++/18407
template <typename Class>
struct the_base{
template <void (Class::*Fn)()> void foo() { }
};
template <typename T>
struct derivedT: the_base<derivedT<T> > {
typedef the_base<derivedT<T> > parent;
void ice(){
this->parent::template foo< &derivedT<T>::ice>();
}
};
int main() {
derivedT<int> dT;
dT.ice();
}