@@ -7418,6 +7418,8 @@ check_user_alignment (const_tree align, bool allow_zero)
{
int i;
+ if (error_operand_p (align))
+ return -1;
if (TREE_CODE (align) != INTEGER_CST
|| !INTEGRAL_TYPE_P (TREE_TYPE (align)))
{
@@ -7539,7 +7541,8 @@ handle_aligned_attribute (tree *node, tree ARG_UNUSED (name), tree args,
if (args)
{
align_expr = TREE_VALUE (args);
- if (align_expr && TREE_CODE (align_expr) != IDENTIFIER_NODE)
+ if (align_expr && TREE_CODE (align_expr) != IDENTIFIER_NODE
+ && TREE_CODE (align_expr) != FUNCTION_DECL)
align_expr = default_conversion (align_expr);
}
else
@@ -8404,9 +8407,11 @@ handle_tm_wrap_attribute (tree *node, tree name, tree args,
else
{
tree wrap_decl = TREE_VALUE (args);
- if (TREE_CODE (wrap_decl) != IDENTIFIER_NODE
- && TREE_CODE (wrap_decl) != VAR_DECL
- && TREE_CODE (wrap_decl) != FUNCTION_DECL)
+ if (error_operand_p (wrap_decl))
+ ;
+ else if (TREE_CODE (wrap_decl) != IDENTIFIER_NODE
+ && TREE_CODE (wrap_decl) != VAR_DECL
+ && TREE_CODE (wrap_decl) != FUNCTION_DECL)
error ("%qE argument not an identifier", name);
else
{
@@ -8533,7 +8538,8 @@ handle_vector_size_attribute (tree *node, tree name, tree args,
*no_add_attrs = true;
size = TREE_VALUE (args);
- if (size && TREE_CODE (size) != IDENTIFIER_NODE)
+ if (size && TREE_CODE (size) != IDENTIFIER_NODE
+ && TREE_CODE (size) != FUNCTION_DECL)
size = default_conversion (size);
if (!tree_fits_uhwi_p (size))
@@ -8944,8 +8950,12 @@ handle_sentinel_attribute (tree *node, tree name, tree args,
if (args)
{
tree position = TREE_VALUE (args);
+ if (position && TREE_CODE (position) != IDENTIFIER_NODE
+ && TREE_CODE (position) != FUNCTION_DECL)
+ position = default_conversion (position);
- if (TREE_CODE (position) != INTEGER_CST)
+ if (TREE_CODE (position) != INTEGER_CST
+ || !INTEGRAL_TYPE_P (TREE_TYPE (position)))
{
warning (OPT_Wattributes,
"requested position is not an integer constant");
@@ -3943,11 +3943,16 @@ c_parser_attributes (c_parser *parser)
In objective-c the identifier may be a classname. */
if (c_parser_next_token_is (parser, CPP_NAME)
&& (c_parser_peek_token (parser)->id_kind == C_ID_ID
- || (c_dialect_objc ()
- && c_parser_peek_token (parser)->id_kind == C_ID_CLASSNAME))
+ || (c_dialect_objc ()
+ && c_parser_peek_token (parser)->id_kind
+ == C_ID_CLASSNAME))
&& ((c_parser_peek_2nd_token (parser)->type == CPP_COMMA)
|| (c_parser_peek_2nd_token (parser)->type
- == CPP_CLOSE_PAREN)))
+ == CPP_CLOSE_PAREN))
+ && (attribute_takes_identifier_p (attr_name)
+ || (c_dialect_objc ()
+ && c_parser_peek_token (parser)->id_kind
+ == C_ID_CLASSNAME)))
{
tree arg1 = c_parser_peek_token (parser)->value;
c_parser_consume_token (parser);
@@ -9,7 +9,7 @@ typedef char vec __attribute__((vector_size(bar))); /* { dg-warning "ignored" }
void f1(char*) __attribute__((nonnull(bar))); /* { dg-error "invalid operand" } */
void f2(char*) __attribute__((nonnull(1,bar))); /* { dg-error "invalid operand" } */
-void g() __attribute__((aligned(bar))); /* { dg-error "invalid value|not an integer" } */
+void g() __attribute__((aligned(bar)));
void foo(void);
void* my_calloc(unsigned, unsigned) __attribute__((alloc_size(1,foo))); /* { dg-warning "outside range" } */
@@ -0,0 +1,14 @@
+/* PR c/50459 */
+/* { dg-do compile } */
+/* { dg-options "-Wall -Wextra" } */
+
+enum { A = 128, B = 1 };
+void *fn1 (void) __attribute__((assume_aligned (A)));
+void *fn2 (void) __attribute__((assume_aligned (A, 4)));
+void fn3 (void) __attribute__((constructor (A)));
+void fn4 (void) __attribute__((destructor (A)));
+void *fn5 (int) __attribute__((alloc_size (B)));
+void *fn6 (int) __attribute__((alloc_align (B)));
+void fn7 (const char *, ...) __attribute__ ((sentinel (B)));
+int __attribute__((vector_size (A))) a;
+int __attribute__((aligned (A))) foo;
@@ -1,4 +1,4 @@
/* PR c/59280 */
/* { dg-do compile } */
-void bar (char *) __attribute__((constructor(foo))); /* { dg-error "constructor priorities must be integers|was not declared|constructor priorities are not supported" } */
+void bar (char *) __attribute__((constructor(foo))); /* { dg-error "constructor priorities must be integers|was not declared|undeclared|constructor priorities are not supported" } */
@@ -6,7 +6,7 @@ extern void func1 () __attribute__((nonnull)); /* { dg-error "without arguments"
extern void func2 (char *) __attribute__((nonnull(2))); /* { dg-error "out-of-range operand" } */
-extern void func3 (char *) __attribute__((nonnull(foo))); /* { dg-error "invalid operand number" } */
+extern void func3 (char *) __attribute__((nonnull(foo))); /* { dg-error "invalid operand number|undeclared" } */
extern void func4 (int) __attribute__((nonnull(1))); /* { dg-error "references non-pointer" } */
@@ -1,4 +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" } */
+char array[16] __attribute__((aligned (SOME_NOT_DEFINED_MACRO))); /* { dg-error "undeclared here" } */
@@ -10,7 +10,7 @@ int f7(void);
void g1(void) W(f1);
void g2(void) W(f2); /* { dg-error "is not compatible" } */
void g3(void) W(i3); /* { dg-error "is not a function" } */
-void g4(void) W(f4); /* { dg-error "is not a function" } */
+void g4(void) W(f4); /* { dg-error "undeclared" } */
void g5(void) W(1); /* { dg-error "not an identifier" } */
void g6(void) W("f1"); /* { dg-error "not an identifier" } */
void g7(void) W(f7); /* { dg-error "is not compatible" } */