We segfaulted on attached testcase, because we were accessing ->typed.type field via TREE_TYPE, but IDENTIFIER_NODEs don't contain ->typed element at all. Fixed by switching the expressions in a condition, so we always first check that we're operating on INTEGER_CST. Regtested/bootstrapped on x86_64-linux, ok for trunk and 4.7 branch?
2012-12-03 Marek Polacek <pola...@redhat.com> PR c/55570 * c-common.c (check_user_alignment): * gcc.dg/pr55570.c: New test. --- gcc/c-family/c-common.c.mp 2012-12-03 13:07:58.233832299 +0100 +++ gcc/c-family/c-common.c 2012-12-03 13:08:55.395259841 +0100 @@ -7261,8 +7261,8 @@ check_user_alignment (const_tree align, { int i; - if (!INTEGRAL_TYPE_P (TREE_TYPE (align)) - || TREE_CODE (align) != INTEGER_CST) + if (TREE_CODE (align) != INTEGER_CST + || !INTEGRAL_TYPE_P (TREE_TYPE (align))) { error ("requested alignment is not an integer constant"); return -1; --- gcc/testsuite/gcc.dg/pr55570.c.mp 2012-12-03 13:06:02.298558986 +0100 +++ gcc/testsuite/gcc.dg/pr55570.c 2012-12-03 13:05:39.200504521 +0100 @@ -0,0 +1,4 @@ +/* PR c/55570 */ +/* { dg-do compile } */ + +char array[16] __attribute__((aligned (SOME_NOT_DEFINED_MACRO))); /* { dg-error "requested alignment is not an integer constant" } */ Marek