2006-09-02 Lee Millward <lee.millward@codesourcery.com>
authorlmillward <lmillward@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 2 Sep 2006 14:15:37 +0000 (14:15 +0000)
committerlmillward <lmillward@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 2 Sep 2006 14:15:37 +0000 (14:15 +0000)
        PR c++/27670
        PR c++/27493
        PR c++/27494
        PR c++/27397
        * parser.c (cp_parser_template_parameter_list): Add
        invalid template parameters to the parameter list as
        error_mark_node.

        * g++.dg/template/operator9.C: New test.
        * g++.dg/template/operator7.C: New test.
        * g++.dg/template/operator8.C: New test.
        * g++.dg/template/crash57.C: New test.

        * g++.dg/template/typedef4.C: Adjust error markers.
        * g++.dg/template/typedef5.C: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116661 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/crash57.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/operator7.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/operator8.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/operator9.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/typedef4.C
gcc/testsuite/g++.dg/template/typedef5.C

index 4709c14..4568cb2 100644 (file)
@@ -1,3 +1,13 @@
+2006-09-02  Lee Millward  <lee.millward@codesourcery.com>
+
+        PR c++/27670
+        PR c++/27493
+        PR c++/27494
+        PR c++/27397
+        * parser.c (cp_parser_template_parameter_list): Add
+        invalid template parameters to the parameter list as
+        error_mark_node.
+
 2006-09-02  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/28878
index 2e28856..72e1c92 100644 (file)
@@ -8441,6 +8441,13 @@ cp_parser_template_parameter_list (cp_parser* parser)
        parameter_list = process_template_parm (parameter_list,
                                                parameter,
                                                is_non_type);
+      else
+       {
+         tree err_parm = build_tree_list (parameter, parameter);
+         TREE_VALUE (err_parm) = error_mark_node;
+         parameter_list = chainon (parameter_list, err_parm);
+       }
+
       /* Peek at the next token.  */
       token = cp_lexer_peek_token (parser->lexer);
       /* If it's not a `,', we're done.  */
index a8c9b62..a1fdb4e 100644 (file)
@@ -1,3 +1,20 @@
+2006-09-02  Lee Millward  <lee.millward@codesourcery.com>
+
+        PR c+/27670
+        * g++.dg/template/operator9.C: New test.
+
+        PR c++/27493
+        * g++.dg/template/operator7.C: New test.
+
+        PR c++/27494
+        * g++.dg/template/operator8.C: New test.
+
+        PR c++/27397
+        * g++.dg/template/crash57.C: New test.
+
+        * g++.dg/template/typedef4.C: Adjust error markers.
+        * g++.dg/template/typedef5.C: Likewise.
+       
 2006-09-02  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/28878
diff --git a/gcc/testsuite/g++.dg/template/crash57.C b/gcc/testsuite/g++.dg/template/crash57.C
new file mode 100644 (file)
index 0000000..cf1c3c2
--- /dev/null
@@ -0,0 +1,10 @@
+//PR c++/27397
+
+template<int(> struct A;        // { dg-error "token" }
+
+template<typename> struct B
+{
+    template<int(> struct C;    // { dg-error "token" }
+};
+
+A<char> a;                      // { dg-error "type/value mismatch|constant|declaration" }
diff --git a/gcc/testsuite/g++.dg/template/operator7.C b/gcc/testsuite/g++.dg/template/operator7.C
new file mode 100644 (file)
index 0000000..bd733da
--- /dev/null
@@ -0,0 +1,6 @@
+//PR c++/27493
+
+template<operator T> void foo()         // { dg-error "before|template" }
+{
+  struct A {};
+}
diff --git a/gcc/testsuite/g++.dg/template/operator8.C b/gcc/testsuite/g++.dg/template/operator8.C
new file mode 100644 (file)
index 0000000..a7f9856
--- /dev/null
@@ -0,0 +1,12 @@
+//PR c++/27494
+
+struct A
+{
+    template<operator+> void foo() {}   // { dg-error "identifier|non-function|template arguments" }
+};
+struct B
+{
+    template<operator> void foo() {}    // { dg-error "identifier|non-function|'void'" }
+    template<int> void bar() {}         // { dg-error "template arguments" }
+};
diff --git a/gcc/testsuite/g++.dg/template/operator9.C b/gcc/testsuite/g++.dg/template/operator9.C
new file mode 100644 (file)
index 0000000..dfd491d
--- /dev/null
@@ -0,0 +1,9 @@
+//PR c++/27670
+
+template<operator+> void foo(); // { dg-error "before|non-function|template" }
+
+void bar()
+{
+  foo();                        // { dg-error "no matching function" }
+}
index 8337110..2676d8f 100644 (file)
@@ -1,7 +1,7 @@
 // PR c++/27572
 // { dg-do compile }
 
-template<typedef> void foo();  // { dg-error "no type|typedef declaration" }
+template<typedef> void foo();  // { dg-error "no type|typedef declaration|template" }
 
 void bar()
 {
index 843d1a9..abd9ebb 100644 (file)
@@ -1,7 +1,7 @@
 // PR c++/27572
 // { dg-do compile }
 
-template<typedef,int>        struct A1; // { dg-error "no type|typedef declaration" }
-template<typedef x,int>      struct A2; // { dg-error "no type|typedef declaration" }
-template<typedef x[],int>    struct A3; // { dg-error "no type|typedef declaration" }
-template<typedef int x, int> struct A4; // { dg-error "typedef declaration" }
+template<typedef,int>        struct A1; // { dg-error "no type|typedef declaration|default argument" }
+template<typedef x,int>      struct A2; // { dg-error "no type|typedef declaration|default argument" }
+template<typedef x[],int>    struct A3; // { dg-error "no type|typedef declaration|default argument" }
+template<typedef int x, int> struct A4; // { dg-error "typedef declaration|default argument" }