re PR inline-asm/39059 (ICE with fixed-point type in inline-asm)
authorJakub Jelinek <jakub@redhat.com>
Tue, 3 Feb 2009 17:26:28 +0000 (18:26 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 3 Feb 2009 17:26:28 +0000 (18:26 +0100)
PR inline-asm/39059
* c-parser.c (c_parser_postfix_expression): If fixed point is not
supported, don't accept FIXED_CSTs.
* c-decl.c (finish_declspecs): Error if fixed point is not supported
and _Sat is used without _Fract/_Accum.  Set specs->type to
integer_type_node for cts_fract/cts_accum if fixed point is not
supported.

* parser.c (cp_parser_primary_expression): Reject FIXED_CSTs.

* gcc.dg/nofixed-point-2.c: New test.
* g++.dg/ext/fixed1.C: Adjust expected diagnostics.
* g++.dg/ext/fixed2.C: Likewise.
* g++.dg/other/error25.C: Likewise.
* g++.dg/lookup/crash7.C: Likewise.
* g++.dg/cpp0x/decltype-38655.C: Likewise.

From-SVN: r143900

12 files changed:
gcc/ChangeLog
gcc/c-decl.c
gcc/c-parser.c
gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/decltype-38655.C
gcc/testsuite/g++.dg/ext/fixed1.C
gcc/testsuite/g++.dg/ext/fixed2.C
gcc/testsuite/g++.dg/lookup/crash7.C
gcc/testsuite/g++.dg/other/error25.C
gcc/testsuite/gcc.dg/nofixed-point-2.c [new file with mode: 0644]

index e9da8807c4ab9e0b7624832429baf96638ce1fc8..a92228c9b113135f21d6e210f1d0690753c079a2 100644 (file)
@@ -1,3 +1,13 @@
+2009-02-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR inline-asm/39059
+       * c-parser.c (c_parser_postfix_expression): If fixed point is not
+       supported, don't accept FIXED_CSTs.
+       * c-decl.c (finish_declspecs): Error if fixed point is not supported
+       and _Sat is used without _Fract/_Accum.  Set specs->type to
+       integer_type_node for cts_fract/cts_accum if fixed point is not
+       supported.
+
 2009-02-02  Catherine Moore  <clm@codesourcery.com>
 
        * sde.h (SUBTARGET_ARM_SPEC): Don;t assemble -fpic code as
index 9f65af4efaca3557158fccedd7cc5f95d6603734..262d9d9283927edafe2255140d6ea716775b276b 100644 (file)
@@ -7772,6 +7772,8 @@ finish_declspecs (struct c_declspecs *specs)
       if (specs->saturating_p)
        {
          error ("%<_Sat%> is used without %<_Fract%> or %<_Accum%>");
+         if (!targetm.fixed_point_supported_p ())
+           error ("fixed-point types not supported for this target");
          specs->typespec_word = cts_fract;
        }
       else if (specs->long_p || specs->short_p
@@ -7894,8 +7896,10 @@ finish_declspecs (struct c_declspecs *specs)
        specs->type = dfloat128_type_node;
       break;
     case cts_fract:
-       gcc_assert (!specs->complex_p);
-       if (specs->saturating_p)
+      gcc_assert (!specs->complex_p);
+      if (!targetm.fixed_point_supported_p ())
+       specs->type = integer_type_node;
+      else if (specs->saturating_p)
        {
          if (specs->long_long_p)
            specs->type = specs->unsigned_p
@@ -7913,7 +7917,7 @@ finish_declspecs (struct c_declspecs *specs)
            specs->type = specs->unsigned_p
                          ? sat_unsigned_fract_type_node
                          : sat_fract_type_node;
-          }
+       }
       else
        {
          if (specs->long_long_p)
@@ -7932,11 +7936,13 @@ finish_declspecs (struct c_declspecs *specs)
            specs->type = specs->unsigned_p
                          ? unsigned_fract_type_node
                          : fract_type_node;
-          }
+       }
       break;
     case cts_accum:
-       gcc_assert (!specs->complex_p);
-       if (specs->saturating_p)
+      gcc_assert (!specs->complex_p);
+      if (!targetm.fixed_point_supported_p ())
+       specs->type = integer_type_node;
+      else if (specs->saturating_p)
        {
          if (specs->long_long_p)
            specs->type = specs->unsigned_p
@@ -7954,7 +7960,7 @@ finish_declspecs (struct c_declspecs *specs)
            specs->type = specs->unsigned_p
                          ? sat_unsigned_accum_type_node
                          : sat_accum_type_node;
-          }
+       }
       else
        {
          if (specs->long_long_p)
@@ -7973,7 +7979,7 @@ finish_declspecs (struct c_declspecs *specs)
            specs->type = specs->unsigned_p
                          ? unsigned_accum_type_node
                          : accum_type_node;
-          }
+       }
       break;
     default:
       gcc_unreachable ();
index 5cb1982a5445f9e96b4f407e9831aacce871ee37..88447692d9a7b18c8e285934baf31dfc77969b19 100644 (file)
@@ -5089,6 +5089,17 @@ c_parser_postfix_expression (c_parser *parser)
   switch (c_parser_peek_token (parser)->type)
     {
     case CPP_NUMBER:
+      expr.value = c_parser_peek_token (parser)->value;
+      expr.original_code = ERROR_MARK;
+      loc = c_parser_peek_token (parser)->location;
+      c_parser_consume_token (parser);
+      if (TREE_CODE (expr.value) == FIXED_CST
+         && !targetm.fixed_point_supported_p ())
+       {
+         error_at (loc, "fixed-point types not supported for this target");
+         expr.value = error_mark_node;
+       }
+      break;
     case CPP_CHAR:
     case CPP_CHAR16:
     case CPP_CHAR32:
index c84de888aed40988a13bbc520cc7781be40f868c..9d425ab1dfa06daefffa0dd23ced00a5ac199db8 100644 (file)
@@ -1,5 +1,8 @@
 2009-02-03  Jakub Jelinek  <jakub@redhat.com>
 
+       PR inline-asm/39059
+       * parser.c (cp_parser_primary_expression): Reject FIXED_CSTs.
+
        PR c++/39056
        * typeck2.c (digest_init_r): Don't call process_init_constructor
        for COMPLEX_TYPE.
index 138fe427b31b3e8157c1e090fdc1bab7bdda4efb..404e45a14c62d03deca408519033e263be7d7365 100644 (file)
@@ -3144,6 +3144,12 @@ cp_parser_primary_expression (cp_parser *parser,
     case CPP_WCHAR:
     case CPP_NUMBER:
       token = cp_lexer_consume_token (parser->lexer);
+      if (TREE_CODE (token->u.value) == FIXED_CST)
+       {
+         error ("%Hfixed-point types not supported in C++",
+                &token->location);
+         return error_mark_node;
+       }
       /* Floating-point literals are only allowed in an integral
         constant expression if they are cast to an integral or
         enumeration type.  */
index 128a7620803e69ab91f51479ce398fbb4f96f6f6..4062c8688a50712d438610681b3be518f7677c80 100644 (file)
@@ -1,5 +1,13 @@
 2009-02-03  Jakub Jelinek  <jakub@redhat.com>
 
+       PR inline-asm/39059
+       * gcc.dg/nofixed-point-2.c: New test.
+       * g++.dg/ext/fixed1.C: Adjust expected diagnostics.
+       * g++.dg/ext/fixed2.C: Likewise.
+       * g++.dg/other/error25.C: Likewise.
+       * g++.dg/lookup/crash7.C: Likewise.
+       * g++.dg/cpp0x/decltype-38655.C: Likewise.
+
        PR c++/39056
        * g++.dg/cpp0x/initlist13.C: New test.
 
index 689be9fa4742aaba9f61ce99caaec7ce3ae1d25c..3b8455bc13fa44e100ca62c7a5c9c924e2cbae6e 100644 (file)
@@ -1,4 +1,4 @@
 // PR c++/38655
 // { dg-options "" }
 
-__decltype(0r)* p = 1; // { dg-error "unnamed-fixed" }
+__decltype(0r)* p = 1; // { dg-error "not supported|invalid" }
index 9ee27808f46f226d2709ce1b3197098e8b3382b0..5a479d6891abeddabd0288191dd9699783cdb66b 100644 (file)
@@ -3,6 +3,6 @@
 
 template<int> struct A {};
 
-template<typename> struct B : A<sizeof(0=0r)> {};
+template<typename> struct B : A<sizeof(0=0r)> {};      // { dg-error "not supported" }
 
-template<typename> struct C : A<sizeof(0=0r)> {};
+template<typename> struct C : A<sizeof(0=0r)> {};      // { dg-error "not supported" }
index a4766eb794cf619be12e7408f859ba0671098b30..1ee5538a1721df37e6929085223b8482f5abf42c 100644 (file)
@@ -3,5 +3,5 @@
 
 void foo()
 {
-  throw 0r;
+  throw 0r;    // { dg-error "not supported" }
 }
index 11176677cb89ddb69087967c19033057f0389509..a3389a01a9735cc6604121298bcc4e89b6d73c97 100644 (file)
@@ -5,5 +5,5 @@ void foo(int);
 
 void bar()
 {
-  foo(1r); // { dg-error "unnamed-fixed" }
+  foo(1r); // { dg-error "not supported" }
 }
index 3bd9842c78fce83afc69ac5e009e66167ae6971d..b5b665a2edcc8b2027352e82475e0a54742acb3a 100644 (file)
@@ -1,5 +1,5 @@
 // PR c++/35338
 // { dg-options "" }
 
-int i = 0r; // { dg-error "unnamed-fixed" }
-bool b = !0r; // { dg-error "0.0|argument" }
+int i = 0r; // { dg-error "not supported" }
+bool b = !0r; // { dg-error "not supported" }
diff --git a/gcc/testsuite/gcc.dg/nofixed-point-2.c b/gcc/testsuite/gcc.dg/nofixed-point-2.c
new file mode 100644 (file)
index 0000000..97bbf70
--- /dev/null
@@ -0,0 +1,30 @@
+/* PR inline-asm/39059 */
+/* { dg-do compile { target {! fixed_point} } } */
+/* { dg-options "-std=gnu99" } */
+
+void
+f1 (void)
+{
+  asm ("" : : "r" (0r));       /* { dg-error "not supported" "reject fixed-point" } */
+}
+
+__typeof (0r)                 /* { dg-error "not supported" "reject fixed-point" } */
+b2 (void)
+{
+  return 0r;                  /* { dg-error "not supported" "reject fixed-point" } */
+}
+
+_Accum                        /* { dg-error "not supported" "reject fixed-point" } */
+f3 (void)
+{
+  return 0k;                   /* { dg-error "not supported" "reject fixed-point" } */
+}
+
+_Sat
+f4 (void)                      /* { dg-error "not supported" "reject fixed-point" } */
+{
+  return 0k;                   /* { dg-error "not supported" "reject fixed-point" } */
+}
+
+/* { dg-warning "defaults to" "" { target *-*-* } 13 } */
+/* { dg-error "is used without" "" { target *-*-* } 24 } */