]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/15044 (ICE on syntax error, template header.)
authorMark Mitchell <mark@codesourcery.com>
Mon, 24 May 2004 02:29:34 +0000 (02:29 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Mon, 24 May 2004 02:29:34 +0000 (02:29 +0000)
PR c++/15044
* parser.c (cp_parser_class_head): Robustify.

PR c++/15317
* parser.c (cp_parser_decl_specifier_seq): Correct error in
comment.
(cp_parser_constructor_declarator_p): Treat attributes
as decl-specifiers.

PR c++/15329
* typeck.c (build_unary_op): Do not attempt to resolve casts to
base classes in templates.

PR c++/15044
* g++.dg/template/error12.C: New test.

PR c++/15317
* g++.dg/ext/attrib15.C: New test.

PR c++/15329
* g++.dg/template/ptrmem9.C: New test.

From-SVN: r82191

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/attrib15.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/error12.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/ptrmem9.C [new file with mode: 0644]

index a517716fc21ebf9f5ded3ea6dbeda3f883e11b10..8e5e03adcf9691325b8e1389c4a4c44af562b25b 100644 (file)
@@ -1,3 +1,18 @@
+2004-05-23  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/15044
+       * parser.c (cp_parser_class_head): Robustify.
+
+       PR c++/15317
+       * parser.c (cp_parser_decl_specifier_seq): Correct error in
+       comment.
+       (cp_parser_constructor_declarator_p): Treat attributes
+       as decl-specifiers.
+
+       PR c++/15329
+       * typeck.c (build_unary_op): Do not attempt to resolve casts to
+       base classes in templates.
+
 2004-05-23  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/15165
index 59ef23ff8553a8e7baa57b9ddde466d3ea671d51..44c820a2868fec65e9cc273fff127c366e4164c5 100644 (file)
@@ -6659,8 +6659,8 @@ cp_parser_simple_declaration (cp_parser* parser,
 
    GNU Extension:
 
-   decl-specifier-seq:
-     decl-specifier-seq [opt] attributes
+   decl-specifier:
+     attributes
 
    Returns a TREE_LIST, giving the decl-specifiers in the order they
    appear in the source code.  The TREE_VALUE of each node is the
@@ -12101,7 +12101,8 @@ cp_parser_class_head (cp_parser* parser,
 
   pop_deferring_access_checks ();
 
-  cp_parser_check_for_invalid_template_id (parser, id);
+  if (id)
+    cp_parser_check_for_invalid_template_id (parser, id);
 
   /* If it's not a `:' or a `{' then we can't really be looking at a
      class-head, since a class-head only appears as part of a
@@ -14154,6 +14155,10 @@ cp_parser_constructor_declarator_p (cp_parser *parser, bool friend_p)
     {
       if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN)
          && cp_lexer_next_token_is_not (parser->lexer, CPP_ELLIPSIS)
+         /* A parameter declaration begins with a decl-specifier,
+            which is either the "attribute" keyword, a storage class
+            specifier, or (usually) a type-specifier.  */
+         && !cp_lexer_next_token_is_keyword (parser->lexer, RID_ATTRIBUTE)
          && !cp_parser_storage_class_specifier_opt (parser))
        {
          tree type;
index 603f655c832f18e31bb16554f5d238f79dc27373..fb00f58d815d1e55257441f4add440667563a174 100644 (file)
@@ -4046,7 +4046,11 @@ build_unary_op (enum tree_code code, tree xarg, int noconvert)
       {
        tree addr;
 
-       if (TREE_CODE (arg) != COMPONENT_REF)
+       if (TREE_CODE (arg) != COMPONENT_REF
+           /* Inside a template, we are processing a non-dependent
+              expression so we can just form an ADDR_EXPR with the
+              correct type.  */
+           || processing_template_decl)
          addr = build_address (arg);
        else if (TREE_CODE (TREE_OPERAND (arg, 1)) == BASELINK)
          {
index d32a76d7866671642ae89bd3cd0e664ccee3be7d..667a742a8ecf04afa961edd5c1eec648ac6838a3 100644 (file)
@@ -1,3 +1,14 @@
+2004-05-23  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/15044
+       * g++.dg/template/error12.C: New test.
+
+       PR c++/15317
+       * g++.dg/ext/attrib15.C: New test.
+
+       PR c++/15329
+       * g++.dg/template/ptrmem9.C: New test.
+
 2004-05-25  Paul Brook  <paul@codesourcery.com>
 
        * gfortran.fortran-torture/compile/inquiry_1.f90: New test.
diff --git a/gcc/testsuite/g++.dg/ext/attrib15.C b/gcc/testsuite/g++.dg/ext/attrib15.C
new file mode 100644 (file)
index 0000000..05de12c
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/15317
+
+struct A
+{
+  A(char);
+};
+A::A(__attribute__((unused)) char i2)
+{}
+
diff --git a/gcc/testsuite/g++.dg/template/error12.C b/gcc/testsuite/g++.dg/template/error12.C
new file mode 100644 (file)
index 0000000..c15961f
--- /dev/null
@@ -0,0 +1,4 @@
+// PR c++/15044
+
+template class <num_t> class a { num_t n; } // { dg-error "" }
+
diff --git a/gcc/testsuite/g++.dg/template/ptrmem9.C b/gcc/testsuite/g++.dg/template/ptrmem9.C
new file mode 100644 (file)
index 0000000..55e8815
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/15329
+
+struct S {}; 
+template <typename> struct X { 
+    S s; 
+    void foo (void (S::*p)()) 
+      { (s.*p)(); } 
+};