This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/50459] alignof doesn't work on plain old constant, works with expressions containing it


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50459

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
The problem on the C side of things is that the values of the enum are
represented by CONST_DECL nodes and check_user_alignment doesn't look through
it.  So maybe something like the following?  (Tested x86_64-linux, no
regressions.)

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 1d56bc0..d70ca3d 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -7418,6 +7418,13 @@ check_user_alignment (const_tree align, bool allow_zero)
 {
   int i;

+  if (TREE_CODE (align) == IDENTIFIER_NODE)
+    {
+      tree t = lookup_name (CONST_CAST_TREE (align));
+      if (t && TREE_CODE (t) == CONST_DECL)
+       align = DECL_INITIAL (t);
+    }
+
   if (TREE_CODE (align) != INTEGER_CST
       || !INTEGRAL_TYPE_P (TREE_TYPE (align)))
     {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]