Commit 5d77fb19 by Marc Glisse Committed by Marc Glisse

re PR c++/53017 (Integer constant expression not constant enough for vector_size)

2014-02-03  Marc Glisse  <marc.glisse@inria.fr>

	PR c++/53017
	PR c++/59211
gcc/c-family/
	* c-common.c (handle_aligned_attribute, handle_alloc_size_attribute,
	handle_vector_size_attribute, handle_nonnull_attribute): Call
	default_conversion on the attribute argument.
	(handle_nonnull_attribute): Increment the argument number.
gcc/cp/
	* tree.c (handle_init_priority_attribute): Call default_conversion on
	the attribute argument.
gcc/
	* doc/extend.texi (Function Attributes): Typo.
gcc/testsuite/
	* c-c++-common/attributes-1.c: New testcase.
	* g++.dg/cpp0x/constexpr-attribute2.C: Likewise.

From-SVN: r207436
parent f344f525
2014-02-03 Marc Glisse <marc.glisse@inria.fr>
PR c++/53017
PR c++/59211
* doc/extend.texi (Function Attributes): Typo.
2014-02-03 Cong Hou <congh@google.com>
PR tree-optimization/60000
......
2014-02-03 Marc Glisse <marc.glisse@inria.fr>
PR c++/53017
PR c++/59211
* c-common.c (handle_aligned_attribute, handle_alloc_size_attribute,
handle_vector_size_attribute, handle_nonnull_attribute): Call
default_conversion on the attribute argument.
(handle_nonnull_attribute): Increment the argument number.
2014-01-31 Marek Polacek <polacek@redhat.com>
PR c/59963
......
......@@ -7526,10 +7526,18 @@ handle_aligned_attribute (tree *node, tree ARG_UNUSED (name), tree args,
tree decl = NULL_TREE;
tree *type = NULL;
int is_type = 0;
tree align_expr = (args ? TREE_VALUE (args)
: size_int (ATTRIBUTE_ALIGNED_VALUE / BITS_PER_UNIT));
tree align_expr;
int i;
if (args)
{
align_expr = TREE_VALUE (args);
if (align_expr && TREE_CODE (align_expr) != IDENTIFIER_NODE)
align_expr = default_conversion (align_expr);
}
else
align_expr = size_int (ATTRIBUTE_ALIGNED_VALUE / BITS_PER_UNIT);
if (DECL_P (*node))
{
decl = *node;
......@@ -8023,6 +8031,9 @@ handle_alloc_size_attribute (tree *node, tree ARG_UNUSED (name), tree args,
for (; args; args = TREE_CHAIN (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
|| TREE_INT_CST_HIGH (position)
......@@ -8467,6 +8478,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)
size = default_conversion (size);
if (!tree_fits_uhwi_p (size))
{
......@@ -8560,11 +8573,16 @@ handle_nonnull_attribute (tree *node, tree ARG_UNUSED (name),
/* Argument list specified. Verify that each argument number references
a pointer argument. */
for (attr_arg_num = 1; args; args = TREE_CHAIN (args))
for (attr_arg_num = 1; args; attr_arg_num++, args = TREE_CHAIN (args))
{
unsigned HOST_WIDE_INT arg_num = 0, ck_num;
if (!get_nonnull_operand (TREE_VALUE (args), &arg_num))
tree arg = TREE_VALUE (args);
if (arg && TREE_CODE (arg) != IDENTIFIER_NODE
&& TREE_CODE (arg) != FUNCTION_DECL)
arg = default_conversion (arg);
if (!get_nonnull_operand (arg, &arg_num))
{
error ("nonnull argument has invalid operand number (argument %lu)",
(unsigned long) attr_arg_num);
......
2014-02-03 Marc Glisse <marc.glisse@inria.fr>
PR c++/53017
PR c++/59211
* tree.c (handle_init_priority_attribute): Call default_conversion on
the attribute argument.
2014-02-03 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/58871
......
......@@ -3250,6 +3250,7 @@ handle_init_priority_attribute (tree* node,
int pri;
STRIP_NOPS (initp_expr);
initp_expr = default_conversion (initp_expr);
if (!initp_expr || TREE_CODE (initp_expr) != INTEGER_CST)
{
......
......@@ -2241,7 +2241,7 @@ For instance,
@smallexample
void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
void my_realloc(void*, size_t) __attribute__((alloc_size(2)))
void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
@end smallexample
@noindent
......
2014-02-03 Marc Glisse <marc.glisse@inria.fr>
PR c++/53017
PR c++/59211
* c-c++-common/attributes-1.c: New testcase.
* g++.dg/cpp0x/constexpr-attribute2.C: Likewise.
2014-02-03 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/58871
......
/* { dg-do compile } */
/* { dg-prune-output "undeclared here \\(not in a function\\)|\[^\n\r\]* was not declared in this scope" } */
void* my_calloc(unsigned, unsigned) __attribute__((alloc_size(1,bar))); /* { dg-warning "outside range" } */
void* my_realloc(void*, unsigned) __attribute__((alloc_size(bar))); /* { dg-warning "outside range" } */
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 foo(void);
void* my_calloc(unsigned, unsigned) __attribute__((alloc_size(1,foo))); /* { dg-warning "outside range" } */
void* my_realloc(void*, unsigned) __attribute__((alloc_size(foo))); /* { dg-warning "outside range" } */
typedef char vec __attribute__((vector_size(foo))); /* { dg-warning "ignored" } */
void f1(char*) __attribute__((nonnull(foo))); /* { dg-error "invalid operand" } */
void f2(char*) __attribute__((nonnull(1,foo))); /* { dg-error "invalid operand" } */
void g() __attribute__((aligned(foo))); /* { dg-error "invalid value|not an integer" } */
// { dg-options -std=gnu++11 }
struct t { t(); };
constexpr int prio = 123;
constexpr int size = 8;
constexpr int pos = 1;
enum A { zero = 0, one, two };
__attribute__((init_priority(prio))) t a;
enum class E1 : int {
first = 101,
second,
third,
};
__attribute__((init_priority(E1::second))) t b; // Should not compile?
enum E2 {
E2_first = 141,
E2_second,
E2_third,
};
__attribute__((init_priority(E2_second))) t c;
void* my_calloc(unsigned, unsigned) __attribute__((alloc_size(pos,two)));
void* my_realloc(void*, unsigned) __attribute__((alloc_size(two)));
typedef char vec __attribute__((vector_size(size)));
void f(char*) __attribute__((nonnull(pos)));
void g() __attribute__((aligned(size)));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment