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

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

From-SVN: r115550

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

index 263c10fd98793ccaf7738c4e6c622a5116040417..c2e679a10af332ad3efda7e4e720bc51d6d58bdc 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-16  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * doc/install.texi (sparc-sun-solaris2*): Add GMP version number.
index 67fe8d2d85640b19369e2ed3a4a927282b757140..90568aed20b42d6837403a59649bf5a4da9db18d 100644 (file)
@@ -156,6 +156,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 (c_lex (&x) != CPP_CLOSE_PAREN)
@@ -186,6 +188,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 7d3b19b6caa5cd092e3dc4f5abc9129006fcf0c3..fabfec9268d7953fb42a5a0147548da8a9cbbb0e 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  Lee Millward  <lee.millward@gmail.com>
 
        PR c++/28051
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..1d78f47
--- /dev/null
@@ -0,0 +1,7 @@
+/* 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" } */
+int i;