On Tue, Apr 15, 2014 at 09:59:10AM -0400, Jason Merrill wrote: > On 04/14/2014 11:10 AM, Marek Polacek wrote: > >+ else if (TREE_CODE (val) == IDENTIFIER_NODE) > >+ { > >+ tree t = lookup_name (val); > >+ if (t && TREE_CODE (t) == CONST_DECL) > >+ return DECL_INITIAL (t); > >+ } > > I'm uncomfortable with this; we should have looked up any attributes > in the parser. Does the testsuite hit this code?
Thanks for looking at it. So the newer version of the patch contains: + else if (TREE_CODE (val) == IDENTIFIER_NODE) + { + tree t = lookup_name (val); + if (t && TREE_CODE (t) == CONST_DECL) + val = default_conversion (t); + } The testsuite doesn't hit this code with C++, but does hit this code with C. The thing is, if we have e.g. enum { A = 128 }; void *fn1 (void) __attribute__((assume_aligned (A))); then handle_assume_aligned_attribute walks the attribute arguments and gets the argument via TREE_VALUE. If this argument is an enum value, then for C the argument is identifier_node that contains const_decl, but for C++ the argument is directly const_decl. That means for C++ in get_attrib_value we just call default_conversion as before, but for C we call lookup_name firstly. Does this answer your question? Marek