* init.c (build_new): Set the type of the new-expression, even
when processing_templte_decl.
PR c++/9216
* parser.c (cp_parser_primary_expression): Improve error message
for templates used in an expression context.
PR c++/8696
* parser.c (cp_parser_decl_specifier_seq): Commit to tentative
parse when encountering "typedef".
PR c++/9354
* g++.dg/parse/new1.C: New test.
PR c++/9216
* g++.dg/parse/template2.C: New test.
PR c++/9354
* g++.dg/parse/typedef2.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@61643
138bc75d-0d04-0410-961f-
82ee72b054a4
+2003-01-22 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/9354
+ * init.c (build_new): Set the type of the new-expression, even
+ when processing_templte_decl.
+
+ PR c++/9216
+ * parser.c (cp_parser_primary_expression): Improve error message
+ for templates used in an expression context.
+
+ PR c++/8696
+ * parser.c (cp_parser_decl_specifier_seq): Commit to tentative
+ parse when encountering "typedef".
+
2003-01-22 Nathanael Nerode <neroden@gcc.gnu.org>
* class.c, parser.c: ANSIfy function definitions and declarations.
else
t = type;
- rval = build_min_nt (NEW_EXPR, placement, t, init);
+ rval = build_min (NEW_EXPR, build_pointer_type (type),
+ placement, t, init);
NEW_EXPR_USE_GLOBAL (rval) = use_global_new;
return rval;
}
/* If we didn't find anything, or what we found was a type,
then this wasn't really an id-expression. */
- if (TREE_CODE (decl) == TYPE_DECL
- || TREE_CODE (decl) == NAMESPACE_DECL
- || (TREE_CODE (decl) == TEMPLATE_DECL
- && !DECL_FUNCTION_TEMPLATE_P (decl)))
+ if (TREE_CODE (decl) == TEMPLATE_DECL
+ && !DECL_FUNCTION_TEMPLATE_P (decl))
+ {
+ cp_parser_error (parser, "missing template arguments");
+ return error_mark_node;
+ }
+ else if (TREE_CODE (decl) == TYPE_DECL
+ || TREE_CODE (decl) == NAMESPACE_DECL)
{
cp_parser_error (parser,
"expected primary-expression");
cp_lexer_consume_token (parser->lexer);
/* A constructor declarator cannot appear in a typedef. */
constructor_possible_p = false;
+ /* The "typedef" keyword can only occur in a declaration; we
+ may as well commit at this point. */
+ cp_parser_commit_to_tentative_parse (parser);
break;
/* storage-class-specifier:
2003-01-22 Mark Mitchell <mark@codesourcery.com>
+ PR c++/9354
+ * g++.dg/parse/new1.C: New test.
+
+ PR c++/9216
+ * g++.dg/parse/template2.C: New test.
+
+ PR c++/9354
+ * g++.dg/parse/typedef2.C: New test.
+
PR c++/9328
* g++.dg/ext/typeof3.C: New test.
--- /dev/null
+struct T;
+T* manage(T* t);
+template <class Obj> struct ObjectSlot0_ {
+ void create() {
+ void* tmp = manage(new T());
+ }
+};
--- /dev/null
+namespace N {
+ template < typename T > class C : T {};
+}
+
+int main() {
+ N::C(); // { dg-error "template" }
+}
--- /dev/null
+template <typename T> struct B { typedef typename T::X X; };
+template <typename T> struct A { typedef B<T>::X::Y Z; }; // { dg-error "" }
+