re PR c++/13736 (Parser confused on compound casts)
authorMark Mitchell <mark@codesourcery.com>
Thu, 29 Jan 2004 01:29:03 +0000 (01:29 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 29 Jan 2004 01:29:03 +0000 (01:29 +0000)
PR c++/13736
* parser.c (cp_parser_direct_declarator): Do not prevent
backtracking inside a parenthesized declarator.
(cp_parser_parameter_declaration): Fix typo in comment.

PR c++/13736
* g++.dg/parse/cast2.C (main): New test.

From-SVN: r76825

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/cast2.C [new file with mode: 0644]

index ba306b82ebe0e7f2448c583fda01198c1bdac133..73451be58df1e336eff99bbbb84347c8c8d73cdc 100644 (file)
@@ -1,3 +1,10 @@
+2004-01-28  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/13736
+       * parser.c (cp_parser_direct_declarator): Do not prevent
+       backtracking inside a parenthesized declarator.
+       (cp_parser_parameter_declaration): Fix typo in comment.
+
 2004-01-28  Jan Hubicka  <jh@suse.cz>
 
        * semantics.c (expand_body)  Do emit_associated_thunks before
index 0ca1dca56a89c7f7cf65ac96c1c9a6862868b923..7c9be8507eceed853d4d86817b62cfab120eddeb 100644 (file)
@@ -10285,15 +10285,20 @@ cp_parser_direct_declarator (cp_parser* parser,
             declarator.  */
          if (first)
            {
+             bool saved_in_type_id_in_expr_p;
+
              parser->default_arg_ok_p = saved_default_arg_ok_p;
              parser->in_declarator_p = saved_in_declarator_p;
              
              /* Consume the `('.  */
              cp_lexer_consume_token (parser->lexer);
              /* Parse the nested declarator.  */
+             saved_in_type_id_in_expr_p = parser->in_type_id_in_expr_p;
+             parser->in_type_id_in_expr_p = true;
              declarator 
                = cp_parser_declarator (parser, dcl_kind, ctor_dtor_or_conv_p,
                                        /*parenthesized_p=*/NULL);
+             parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p;
              first = false;
              /* Expect a `)'.  */
              if (!cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'"))
@@ -11048,11 +11053,11 @@ cp_parser_parameter_declaration (cp_parser *parser,
       if (!parser->in_template_argument_list_p
          /* In an expression context, having seen:
 
-              (int((char *)...
+              (int((char ...
 
             we cannot be sure whether we are looking at a
-            function-type (taking a "char*" as a parameter) or a cast
-            of some object of type "char*" to "int".  */
+            function-type (taking a "char" as a parameter) or a cast
+            of some object of type "char" to "int".  */
          && !parser->in_type_id_in_expr_p
          && cp_parser_parsing_tentatively (parser)
          && !cp_parser_committed_to_tentative_parse (parser)
index e22e0e368840684f52393e2f1f81d12751379e94..3c0df5151653d3cd49a9d00883bce74c0d17f14b 100644 (file)
@@ -1,3 +1,8 @@
+2004-01-28  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/13736
+       * g++.dg/parse/cast2.C (main): New test.
+
 2004-01-27  James E Wilson  <wilson@specifixinc.com>
 
        * objc.dg/encode-2.m (main): New local string.  Set depending on
diff --git a/gcc/testsuite/g++.dg/parse/cast2.C b/gcc/testsuite/g++.dg/parse/cast2.C
new file mode 100644 (file)
index 0000000..d447bb4
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/13736
+
+struct string
+{
+  string() {}
+  string(const string&) {}
+  string(const char*) {}
+};
+
+int main()
+{
+  string s2(string( (const char*)("")));
+}