Blame SOURCES/gcc32-c++-pr10558.patch

6f1b0c
2003-07-10  Mark Mitchell  <mark@codesourcery.com>
6f1b0c
6f1b0c
	PR c++/10558
6f1b0c
	* parse.y (class_template_ok_as_expr): New variable.
6f1b0c
	(template_arg_1): New non-terminal.
6f1b0c
	(primary): Issue errors about uses of class templates as
6f1b0c
	expressions.
6f1b0c
6f1b0c
	* g++.dg/parse/template8.C: New test.
6f1b0c
6f1b0c
--- gcc/cp/parse.y	10 Jul 2003 12:43:11 -0000	1.284.2.7
6f1b0c
+++ gcc/cp/parse.y	11 Jul 2003 08:39:55 -0000	1.284.2.8
6f1b0c
@@ -53,6 +53,8 @@ extern struct obstack permanent_obstack;
6f1b0c
 /* Like YYERROR but do call yyerror.  */
6f1b0c
 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
6f1b0c
 
6f1b0c
+static int class_template_ok_as_expr;
6f1b0c
+
6f1b0c
 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
6f1b0c
 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
6f1b0c
 
6f1b0c
@@ -422,7 +424,7 @@ cp_parse_init ()
6f1b0c
 %type   template_close_bracket
6f1b0c
 %type <ttype> apparent_template_type
6f1b0c
 %type <ttype> template_type template_arg_list template_arg_list_opt
6f1b0c
-%type <ttype> template_arg
6f1b0c
+%type <ttype> template_arg template_arg_1
6f1b0c
 %type <ttype> condition xcond paren_cond_or_null
6f1b0c
 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
6f1b0c
 %type <ttype> complete_type_name notype_identifier nonnested_type
6f1b0c
@@ -1108,7 +1110,7 @@ template_close_bracket:
6f1b0c
 template_arg_list_opt:
6f1b0c
          /* empty */
6f1b0c
                  { $$ = NULL_TREE; }
6f1b0c
-       | template_arg_list
6f1b0c
+       | template_arg_list 
6f1b0c
        ;
6f1b0c
 
6f1b0c
 template_arg_list:
6f1b0c
@@ -1119,6 +1121,15 @@ template_arg_list:
6f1b0c
 	;
6f1b0c
 
6f1b0c
 template_arg:
6f1b0c
+		{ ++class_template_ok_as_expr; }
6f1b0c
+	template_arg_1 
6f1b0c
+		{ 
6f1b0c
+		  --class_template_ok_as_expr; 
6f1b0c
+		  $$ = $2; 
6f1b0c
+		}
6f1b0c
+	;
6f1b0c
+
6f1b0c
+template_arg_1:
6f1b0c
 	  type_id
6f1b0c
 		{ $$ = groktypename ($1.t); }
6f1b0c
 	| PTYPENAME
6f1b0c
@@ -1695,7 +1706,14 @@ primary:
6f1b0c
 		    $$ = $2;
6f1b0c
 		}
6f1b0c
 	| overqualified_id  %prec HYPERUNARY
6f1b0c
-		{ $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
6f1b0c
+		{ $$ = build_offset_ref (OP0 ($$), OP1 ($$));
6f1b0c
+		  if (!class_template_ok_as_expr 
6f1b0c
+		      && DECL_CLASS_TEMPLATE_P ($$))
6f1b0c
+		    {
6f1b0c
+		      error ("invalid use of template `%D'", $$); 
6f1b0c
+		      $$ = error_mark_node;
6f1b0c
+		    }
6f1b0c
+		}
6f1b0c
 	| overqualified_id '(' nonnull_exprlist ')'
6f1b0c
                 { $$ = finish_qualified_call_expr ($1, $3); }
6f1b0c
 	| overqualified_id LEFT_RIGHT
6f1b0c
--- gcc/testsuite/g++.dg/parse/template8.C	2005-01-27 14:27:08.338732320 +0100
6f1b0c
+++ gcc/testsuite/g++.dg/parse/template8.C	2003-07-16 18:05:35.000000000 +0200
6f1b0c
@@ -0,0 +1,16 @@
6f1b0c
+namespace N
6f1b0c
+{
6f1b0c
+
6f1b0c
+template <typename> struct A
6f1b0c
+{
6f1b0c
+  template <typename T> A(A<T>);
6f1b0c
+};
6f1b0c
+
6f1b0c
+}
6f1b0c
+
6f1b0c
+void foo(N::A<int>);
6f1b0c
+
6f1b0c
+void bar()
6f1b0c
+{
6f1b0c
+  foo(N::A); // { dg-error "" }
6f1b0c
+}