]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/28249 ("long long long" accepted by catch)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Sat, 15 Jul 2006 09:58:47 +0000 (09:58 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Sat, 15 Jul 2006 09:58:47 +0000 (09:58 +0000)
PR c++/28249
* parser.c (cp_parser_check_decl_spec): New function.
(cp_parser_decl_specifier_seq): Factor out check for repeated
decl-specifiers into cp_parser_check_decl_spec. Use it.
(cp_parser_type_specifier_seq): Use it.

* g++.dg/parse/catch1.C: New test.

From-SVN: r115471

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

index 81d872ecf7aeb6b471b287d8e9f29021132174fe..6f58dcb469845cfda3f9942617a4a9f6963e5bdd 100644 (file)
@@ -1,5 +1,11 @@
 2006-07-15  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
+       PR c++/28249
+       * parser.c (cp_parser_check_decl_spec): New function.
+       (cp_parser_decl_specifier_seq): Factor out check for repeated
+       decl-specifiers into cp_parser_check_decl_spec. Use it.
+       (cp_parser_type_specifier_seq): Use it.
+
        PR c++/28294
        * semantics.c (finish_offsetof): Use TREE_OPERAND for COMPONENT_REFs
        only.
index 4e171899a74f20a23bb8d4ef05e1337307fd242f..8e8294a9b21faceb08d1e5657bb8d24e7ef26b8f 100644 (file)
@@ -1894,6 +1894,49 @@ cp_parser_simulate_error (cp_parser* parser)
   return false;
 }
 
+/* Check for repeated decl-specifiers.  */
+
+static void
+cp_parser_check_decl_spec (cp_decl_specifier_seq *decl_specs)
+{
+  cp_decl_spec ds;
+
+  for (ds = ds_first; ds != ds_last; ++ds)
+    {
+      unsigned count = decl_specs->specs[(int)ds];
+      if (count < 2)
+       continue;
+      /* The "long" specifier is a special case because of "long long".  */
+      if (ds == ds_long)
+       {
+         if (count > 2)
+           error ("%<long long long%> is too long for GCC");
+         else if (pedantic && !in_system_header && warn_long_long)
+           pedwarn ("ISO C++ does not support %<long long%>");
+       }
+      else if (count > 1)
+       {
+         static const char *const decl_spec_names[] = {
+           "signed",
+           "unsigned",
+           "short",
+           "long",
+           "const",
+           "volatile",
+           "restrict",
+           "inline",
+           "virtual",
+           "explicit",
+           "friend",
+           "typedef",
+           "__complex",
+           "__thread"
+         };
+         error ("duplicate %qs", decl_spec_names[(int)ds]);
+       }
+    }
+}
+
 /* This function is called when a type is defined.  If type
    definitions are forbidden at this point, an error message is
    issued.  */
@@ -7186,7 +7229,6 @@ cp_parser_decl_specifier_seq (cp_parser* parser,
                              int* declares_class_or_enum)
 {
   bool constructor_possible_p = !parser->in_declarator_p;
-  cp_decl_spec ds;
 
   /* Clear DECL_SPECS.  */
   clear_decl_specs (decl_specs);
@@ -7387,41 +7429,7 @@ cp_parser_decl_specifier_seq (cp_parser* parser,
       flags |= CP_PARSER_FLAGS_OPTIONAL;
     }
 
-  /* Check for repeated decl-specifiers.  */
-  for (ds = ds_first; ds != ds_last; ++ds)
-    {
-      unsigned count = decl_specs->specs[(int)ds];
-      if (count < 2)
-       continue;
-      /* The "long" specifier is a special case because of "long long".  */
-      if (ds == ds_long)
-       {
-         if (count > 2)
-           error ("%<long long long%> is too long for GCC");
-         else if (pedantic && !in_system_header && warn_long_long)
-           pedwarn ("ISO C++ does not support %<long long%>");
-       }
-      else if (count > 1)
-       {
-         static const char *const decl_spec_names[] = {
-           "signed",
-           "unsigned",
-           "short",
-           "long",
-           "const",
-           "volatile",
-           "restrict",
-           "inline",
-           "virtual",
-           "explicit",
-           "friend",
-           "typedef",
-           "__complex",
-           "__thread"
-         };
-         error ("duplicate %qs", decl_spec_names[(int)ds]);
-       }
-    }
+  cp_parser_check_decl_spec (decl_specs);
 
   /* Don't allow a friend specifier with a class definition.  */
   if (decl_specs->specs[(int) ds_friend] != 0
@@ -11756,7 +11764,7 @@ cp_parser_type_specifier_seq (cp_parser* parser,
        flags |= CP_PARSER_FLAGS_NO_USER_DEFINED_TYPES; 
     }
 
-  return;
+  cp_parser_check_decl_spec (type_specifier_seq);
 }
 
 /* Parse a parameter-declaration-clause.
index cd7f3b53c027a684c882ea4f54bb9b6892245624..888077d7a5dd0eee6a1e99c57fd3e1076ff7dd90 100644 (file)
@@ -1,5 +1,8 @@
 2006-07-15  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
+       PR c++/28249
+       * g++.dg/parse/catch1.C: New test.
+
        PR c++/28294
        * g++.dg/ext/offsetof1.C: Add test with function pointer arithmetic.
 
diff --git a/gcc/testsuite/g++.dg/parse/catch1.C b/gcc/testsuite/g++.dg/parse/catch1.C
new file mode 100644 (file)
index 0000000..8774022
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/28249
+// { dg-do compile }
+
+void foo()
+{
+  try {}
+  catch (long long long) {}  // { dg-error "long long long" }
+}