diff options
-rw-r--r-- | gcc/cp/ChangeLog | 21 | ||||
-rw-r--r-- | gcc/cp/decl.c | 8 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 2 | ||||
-rw-r--r-- | gcc/cp/parser.c | 5 | ||||
-rw-r--r-- | gcc/cp/pt.c | 17 | ||||
-rw-r--r-- | gcc/cp/tree.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 17 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/vla1.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/vlm1.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/cond1.C | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/array9.C | 18 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/call3.C | 15 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/crash2.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/ptrmem11.C | 19 |
14 files changed, 123 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1b34b95..fe51d5b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index a696121..472b1f9 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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) diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 03c51e7..d8987e2 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -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 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index ef02ba9..265abdb 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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; diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 28ae8f3..54c9979 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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, diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index afe42e2..82aebe4 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -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) */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 853cd4a..10bac62 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 diff --git a/gcc/testsuite/g++.dg/ext/vla1.C b/gcc/testsuite/g++.dg/ext/vla1.C index bac5aac..f2238c2 100644 --- a/gcc/testsuite/g++.dg/ext/vla1.C +++ b/gcc/testsuite/g++.dg/ext/vla1.C @@ -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" } diff --git a/gcc/testsuite/g++.dg/ext/vlm1.C b/gcc/testsuite/g++.dg/ext/vlm1.C index 13f6702..9cb6c38 100644 --- a/gcc/testsuite/g++.dg/ext/vlm1.C +++ b/gcc/testsuite/g++.dg/ext/vlm1.C @@ -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; diff --git a/gcc/testsuite/g++.dg/parse/cond1.C b/gcc/testsuite/g++.dg/parse/cond1.C new file mode 100644 index 0000000..6994773 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/cond1.C @@ -0,0 +1,6 @@ +// PR c++/18389 + +void foo() +{ + for (; struct A {}; ); // { dg-error "" } +} diff --git a/gcc/testsuite/g++.dg/template/array9.C b/gcc/testsuite/g++.dg/template/array9.C new file mode 100644 index 0000000..f3e8335 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/array9.C @@ -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; +} diff --git a/gcc/testsuite/g++.dg/template/call3.C b/gcc/testsuite/g++.dg/template/call3.C new file mode 100644 index 0000000..1dd2b51 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/call3.C @@ -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; diff --git a/gcc/testsuite/g++.dg/template/crash2.C b/gcc/testsuite/g++.dg/template/crash2.C index a02787a..8bf7b45 100644 --- a/gcc/testsuite/g++.dg/template/crash2.C +++ b/gcc/testsuite/g++.dg/template/crash2.C @@ -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; diff --git a/gcc/testsuite/g++.dg/template/ptrmem11.C b/gcc/testsuite/g++.dg/template/ptrmem11.C new file mode 100644 index 0000000..da2ce49 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/ptrmem11.C @@ -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(); +} |