diff gcc/testsuite/gcc.dg/attr-copy.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gcc/testsuite/gcc.dg/attr-copy.c	Thu Feb 13 11:34:05 2020 +0900
@@ -0,0 +1,34 @@
+/* PR middle-end/81824 - Warn for missing attributes with function aliases
+   Exercise error handling for attribute copy.
+   { dg-do compile }
+   { dg-require-alias "" }
+   { dg-options "-O2 -Wall" } */
+
+#define ATTR(list)   __attribute__ (list)
+
+/* Verify incorrect numbers of arguments.  */
+ATTR ((copy)) void
+fno_args (void);              /* { dg-error "wrong number of arguments specified for .copy. attribute" } */
+
+ATTR ((copy ())) void
+fno_args2 (void);             /* { dg-error "wrong number of arguments specified for .copy. attribute" } */
+
+ATTR ((copy (fno_args, fno_args))) void
+fmlti_args (void);            /* { dg-error "wrong number of arguments specified for .copy. attribute" } */
+
+/* Verify that referencing an undeclared symbol is rejected with an error.  */
+
+ATTR ((copy (foobar)))        /* { dg-error ".foobar. undeclared" } */
+void fundeclared (void);
+
+/* Verify that using a string argument triggers a descriptive error
+   (given attributes like alias and weakref using a string is a likely
+   mistake).  */
+
+ATTR ((copy ("foobar")))
+void fstring (void);          /* { dg-error ".copy. attribute argument cannot be a string" } */
+
+/* Ditto for an integer.  */
+
+ATTR ((copy (123)))
+void fnumber (void);          /* { dg-error ".copy. attribute argument cannot be a constant arithmetic expression" } */