re PR c/28286 (ICE with invalid value in #pragma pack)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Tue, 18 Jul 2006 10:08:22 +0000 (10:08 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Tue, 18 Jul 2006 10:08:22 +0000 (10:08 +0000)
PR c/28286
* c-pragma.c (handle_pragma_pack): Handle invalid constants.

* gcc.dg/pragma-pack-4.c: New test.

From-SVN: r115548

gcc/ChangeLog
gcc/c-pragma.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pragma-pack-4.c [new file with mode: 0644]

index 65b6b2f9bd084d59655d4e7ce64865af3cfe5d32..8a295d6c324b2030d98e59538189670b1f25a560 100644 (file)
@@ -1,3 +1,8 @@
+2006-07-18  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c/28286
+       * c-pragma.c (handle_pragma_pack): Handle invalid constants.
+
 2006-07-18  Alexandre Oliva  <aoliva@redhat.com>
 
        PR c/26993
index e71ab07a16f40aaea9ef3b31b98598a8e0930504..b2712acc93798b2f305373b81530d1b6c7fb0cd1 100644 (file)
@@ -160,6 +160,8 @@ handle_pragma_pack (cpp_reader * ARG_UNUSED (dummy))
     }
   else if (token == CPP_NUMBER)
     {
+      if (TREE_CODE (x) != INTEGER_CST)
+       GCC_BAD ("invalid constant in %<#pragma pack%> - ignored");
       align = TREE_INT_CST_LOW (x);
       action = set;
       if (pragma_lex (&x) != CPP_CLOSE_PAREN)
@@ -190,6 +192,8 @@ handle_pragma_pack (cpp_reader * ARG_UNUSED (dummy))
            }
          else if (token == CPP_NUMBER && action == push && align == -1)
            {
+             if (TREE_CODE (x) != INTEGER_CST)
+               GCC_BAD ("invalid constant in %<#pragma pack%> - ignored");
              align = TREE_INT_CST_LOW (x);
              if (align == -1)
                action = set;
index 9638bcf78d4d9bbd9fcfa004047798ac0cfe9b5b..0828f4aaa2a72cfe1d06d1eb636aef5b6f7c432b 100644 (file)
@@ -1,3 +1,8 @@
+2006-07-18  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c/28286
+       * gcc.dg/pragma-pack-4.c: New test.
+
 2006-07-17  Steve Ellcey  <sje@cup.hp.com>
 
        PR c++/28291
diff --git a/gcc/testsuite/gcc.dg/pragma-pack-4.c b/gcc/testsuite/gcc.dg/pragma-pack-4.c
new file mode 100644 (file)
index 0000000..1765591
--- /dev/null
@@ -0,0 +1,6 @@
+/* PR c/28286 */
+/* { dg-do compile } */
+
+#pragma pack(0.5)         /* { dg-warning "invalid constant" } */
+#pragma pack(push,0.5)    /* { dg-warning "invalid constant" } */
+#pragma pack(push,x,0.5)  /* { dg-warning "invalid constant" } */