Commit eedff701 by Martin Sebor Committed by Martin Sebor

PR c/81544 - attribute noreturn and warn_unused_result on the same function

PR c/81544 - attribute noreturn and warn_unused_result on the same function
accepted 

Add tests missed in r255469.

From-SVN: r255557
parent 0242c7f0
2017-12-11 Martin Sebor <msebor@redhat.com>
PR c/81544
* c-c++-common/Wattributes-2.c: New test.
* c-c++-common/Wattributes.c: Ditto.
* g++.dg/Wattributes-2.C: Ditto.
* gcc.dg/Wattributes-6.c: Ditto.
* gcc.dg/Wattributes-7.c: Ditto.
* ../../../git/gcc/testsuite/g++.dg/pr53037-4.C:
2017-12-07 Carl Love <cel@us.ibm.com> 2017-12-07 Carl Love <cel@us.ibm.com>
* gcc.target/powerpc/altivec-12.c (main): Add tests for vec_avg. * gcc.target/powerpc/altivec-12.c (main): Add tests for vec_avg.
......
/* PR c/81566 - invalid attribute aligned accepted on functions
{ dg-do compile }
{ dg-options "-Wall -Wattributes -ftrack-macro-expansion=0" } */
#define ATTR(list) __attribute__ (list)
#define ALIGN(n) ATTR ((aligned (n)))
/* It's okay to increase the alignment of a function. */
void ALIGN (16) ALIGN (32)
falign32_1 (void);
void ALIGN (16) falign32_2 (void);
void ALIGN (32) falign32_2 (void);
void falign32_2 (void) { }
void ALIGN (32) falign32_2 (void);
/* It's not okay to decrease it. */
void ALIGN (32) ALIGN (16)
falign64_3 (void); /* { dg-warning "ignoring attribute .aligned \\(16\\). because it conflicts with attribute .aligned \\(32\\)." } */
void ALIGN (32)
falign64_3 (void);
void falign64_3 (void);
void falign64_3 (void) { }
void ALIGN (32)
falign64_4 (void); /* { dg-message "previous declaration here" } */
void ALIGN (16)
falign64_4 (void); /* { dg-warning "ignoring attribute .aligned \\(16\\). because it conflicts with attribute .aligned \\(32\\)." } */
void ALIGN (32)
falign64_4 (void); /* { dg-message "previous declaration here" } */
void ALIGN (16)
falign64_4 (void); /* { dg-warning "ignoring attribute .aligned \\(16\\). because it conflicts with attribute .aligned \\(32\\)." } */
void ALIGN (64)
falign64_4 (void);
void ALIGN (32)
falign64_4 (void); /* { dg-warning "ignoring attribute .aligned \\(32\\). because it conflicts with attribute .aligned \\(64\\)." } */
void falign64_4 (void);
void ALIGN (64)
falign64_4 (void) { }
void falign64_4 (void);
void ALIGN (64)
falign64_4 (void);
void ATTR ((aligned (16), aligned (32)))
falign64_5 (void);
void ATTR ((aligned (32), aligned (64)))
falign64_5 (void);
void ATTR ((aligned (16), aligned (32), aligned (64)))
falign64_5 (void); /* { dg-warning "ignoring attribute .aligned \\(16\\). because it conflicts with attribute .aligned \\(64\\)." } */
/* { dg-warning "ignoring attribute .aligned \\(32\\). because it conflicts with attribute .aligned \\(64\\)." "" { target *-*-* } .-1 } */
void ATTR ((aligned (16), aligned (32), aligned (16)))
falign64_6 (void); /* { dg-warning "ignoring attribute .aligned \\(16\\). because it conflicts with attribute .aligned \\(32\\)." } */
// Test to verify that attributes on distinct overloads of a function
// with the same name are properly looked up and applied.
// { dg-do compile }
// { dg-options "-Wall" }
int
foo (int);
int __attribute__ ((noreturn))
foo (int, int);
int __attribute__ ((warn_unused_result))
foo (int, int, int);
int call_foo_1 ()
{
foo (1);
} // { dg-warning "\\\[-Wreturn-type]" }
int call_foo_2 ()
{
foo (1, 2);
}
int call_foo_3 ()
{
foo (1, 2, 3); // { dg-warning "\\\[-Wunused-result]" }
} // { dg-warning "\\\[-Wreturn-type]" }
int call_foo_4 ()
{
// Make sure an error doesn't trigger bogus warnings or an ICE.
foo (1, 2, 3, 4); // { dg-error "no matching function" }
return 0;
}
/* PR c/81566 - invalid attribute aligned accepted on functions
{ dg-do compile }
{ dg-options "-Wall -Wattributes -ftrack-macro-expansion=0" } */
#define ATTR(list) __attribute__ (list)
#define ALIGN(n) ATTR ((aligned (n)))
/* It's okay to increase the alignment of a function. */
void ALIGN (16) ALIGN (32)
falign32_1 (void);
void ALIGN (16) falign32_2 (void);
void ALIGN (32) falign32_2 (void);
void falign32_2 (void) { }
void ALIGN (32) falign32_2 (void);
/* It's not okay to decrease it. */
void ALIGN (32) ALIGN (16)
falign64_3 (void); /* { dg-warning "ignoring attribute .aligned \\(16\\). because it conflicts with attribute .aligned \\(32\\)." } */
void ALIGN (32)
falign64_3 (void);
void falign64_3 (void);
void falign64_3 (void) { }
void ALIGN (32)
falign64_4 (void); /* { dg-message "previous declaration here" } */
void ALIGN (16)
falign64_4 (void); /* { dg-warning "ignoring attribute .aligned \\(16\\). because it conflicts with attribute .aligned \\(32\\)." } */
void ALIGN (32)
falign64_4 (void); /* { dg-message "previous declaration here" } */
void ALIGN (16)
falign64_4 (void); /* { dg-warning "ignoring attribute .aligned \\(16\\). because it conflicts with attribute .aligned \\(32\\)." } */
void ALIGN (64)
falign64_4 (void);
void ALIGN (32)
falign64_4 (void); /* { dg-warning "ignoring attribute .aligned \\(32\\). because it conflicts with attribute .aligned \\(64\\)." } */
void falign64_4 (void);
void ALIGN (64)
falign64_4 (void) { }
void falign64_4 (void);
void ALIGN (64)
falign64_4 (void);
void ATTR ((aligned (16), aligned (32)))
falign64_5 (void);
void ATTR ((aligned (32), aligned (64)))
falign64_5 (void);
void ATTR ((aligned (16), aligned (32), aligned (64)))
falign64_5 (void); /* { dg-warning "ignoring attribute .aligned \\(16\\). because it conflicts with attribute .aligned \\(64\\)." } */
/* { dg-warning "ignoring attribute .aligned \\(32\\). because it conflicts with attribute .aligned \\(64\\)." "" { target *-*-* } .-1 } */
void ATTR ((aligned (16), aligned (32), aligned (16)))
falign64_6 (void); /* { dg-warning "ignoring attribute .aligned \\(16\\). because it conflicts with attribute .aligned \\(32\\)." } */
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