On 09/18/2012 09:51 AM, Dodji Seketeli wrote:
+ VEC_safe_push (scoped_attributes, heap, attributes_table, sa);
+ result = &VEC_last (scoped_attributes, attributes_table);
Here you can set result from the return value of VEC_safe_push.
+ if ((flags & ATTR_FLAG_CXX11)
+ && !(flags & ATTR_FLAG_TYPE_IN_PLACE
+ && (TREE_CODE (*node) == RECORD_TYPE
+ || TREE_CODE (*node) == UNION_TYPE)))
+ {
+ /* unused is being used as a c++11 attribute. In this mode
+ we prevent it from applying to types, unless it's for a
+ class defintion. */
+ warning (OPT_Wattributes,
+ "attribute %qE cannot be applied to a non-class type", name);
+ return NULL_TREE;
+ }
I think this should now be covered by the general ignoring of attributes
that appertain to type-specifiers, so we don't need to check it here.
+ error ("requested alignment %d is larger than %d",
+ requested_alignment, max_align);
Let's make this a pedwarn.
+cxx_fundamental_alignment_p (unsigned align)
+{
+
+ return (align <= MAX (TYPE_ALIGN (long_long_integer_type_node),
+ TYPE_ALIGN (long_double_type_node)));
+}
Unneeded blank line.
+ inform (token->location,
+ "an attribute for a declaration should be either "
+ "at the begining of the declaration or after "
+ "the declarator-id");
Putting this code here means that we give the diagnostic for attributes
in the decl-specifier-seq, but not for attributes that apply to type
parts of the declarator such as a ptr-operator or a function declarator.
I think the best place to implement this in decl_attributes; there you
can just ignore any attributes applied to a type without
ATTR_FLAG_TYPE_IN_PLACE.
+ declarator = cp_parser_make_indirect_declarator
(code, type, cv_quals, declarator);
+ if (declarator != NULL && declarator != cp_error_declarator)
+ declarator->attributes = std_attributes;
Let's pass std_attributes to make_indirect_declarator.
declarator = cp_parser_make_indirect_declarator
(code, class_type, cv_quals, declarator);
+
+ /* For C++11 attributes, the standard at [decl.ptr]/1 says:
+
+ the optional attribute-specifier-seq appertains to the
+ pointer and not to the object pointed to". */
+ if (std_attributes
+ && declarator
+ && (declarator != cp_error_declarator))
+ declarator->std_attributes = std_attributes;
Here too.
+cp_parser_attributes_opt (cp_parser *parser)
+{
+
+ if (cp_next_tokens_can_be_gnu_attribute_p (parser))
Unneeded newline.
+ alignas_expr =
+ cp_parser_assignment_expression (parser, /*cast_p=*/false,
+ /**cp_id_kind=*/NULL);
Let's require_potential_rvalue_constant_expression here or in
cxx_alignas_expr.
+ alignas_expr = fold_non_dependent_expr (alignas_expr);
You don't need this both in the parser and in cxx_alignas_expr.
+cxx_alignas_expr (tree e, tsubst_flags_t complain)
I don't think you need the complain parameter anymore, so you don't need
to make fold_non_dependent_expr_sfinae non-static either.
+ /* [dcl.align]/2 says:
+
+ [the assignment-expression shall be an integral constant
+ expression]. */
+ e = fold_non_dependent_expr_sfinae (e, complain);
+ if (e == NULL_TREE
+ || e == error_mark_node
+ || TREE_CODE (e) != INTEGER_CST)
+ return error_mark_node;
This needs to allow value-dependent expressions. I'd say
e = fold_non_dependent_expr (e);
if (value_dependent_expression_p (e))
/* Leave value-dependent expression alone for now. */;
else
e = cxx_constant_value (e);
Jason