aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2018-10-04 16:44:53 +0200
committerMartin Liska <marxin@gcc.gnu.org>2018-10-04 14:44:53 +0000
commit96c545e5ed9d50b2af2d1d5a6a49b7ff1baa0d85 (patch)
tree3cb97d2117782805b63df0e3c56ff104071742f3 /gcc
parentb8ce8129a560f64f8b2855c4a3812b7c3c0ebf3f (diff)
downloadgcc-96c545e5ed9d50b2af2d1d5a6a49b7ff1baa0d85.zip
gcc-96c545e5ed9d50b2af2d1d5a6a49b7ff1baa0d85.tar.gz
gcc-96c545e5ed9d50b2af2d1d5a6a49b7ff1baa0d85.tar.bz2
Error about alias attribute with body definition (PR c/87483).
2018-10-04 Martin Liska <mliska@suse.cz> PR c/87483 * cgraphunit.c (process_function_and_variable_attributes): Warn about a function with alias attribute and a body. 2018-10-04 Martin Liska <mliska@suse.cz> PR c/87483 * gcc.dg/pr87483.c: New test. From-SVN: r264846
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/cgraphunit.c6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr87483.c16
4 files changed, 33 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f7a15e3..0340fa3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
2018-10-04 Martin Liska <mliska@suse.cz>
+ PR c/87483
+ * cgraphunit.c (process_function_and_variable_attributes):
+ Warn about a function with alias attribute and a body.
+
+2018-10-04 Martin Liska <mliska@suse.cz>
+
PR ipa/82625
* multiple_target.c (redirect_to_specific_clone): New function.
(ipa_target_clone): Use it.
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index c0baaea..146855f 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -784,6 +784,12 @@ process_function_and_variable_attributes (cgraph_node *first,
DECL_ATTRIBUTES (decl) = remove_attribute ("weakref",
DECL_ATTRIBUTES (decl));
}
+ else if (lookup_attribute ("alias", DECL_ATTRIBUTES (decl))
+ && node->definition
+ && !node->alias)
+ warning_at (DECL_SOURCE_LOCATION (node->decl), OPT_Wattributes,
+ "%<alias%> attribute ignored"
+ " because function is defined");
if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (decl))
&& !DECL_DECLARED_INLINE_P (decl)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ee8a184..7da77d1 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2018-10-04 Martin Liska <mliska@suse.cz>
+ PR c/87483
+ * gcc.dg/pr87483.c: New test.
+
+2018-10-04 Martin Liska <mliska@suse.cz>
+
PR ipa/82625
* g++.dg/ext/pr82625.C: New test.
diff --git a/gcc/testsuite/gcc.dg/pr87483.c b/gcc/testsuite/gcc.dg/pr87483.c
new file mode 100644
index 0000000..d3af8df
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr87483.c
@@ -0,0 +1,16 @@
+/* PR c/87483 */
+/* { dg-require-alias "" } */
+
+int f (void) { return 0; }
+__attribute__ ((alias ("f"))) int g () { return 1; } /* { dg-warning "attribute ignored because function is defined" } */
+__attribute__ ((alias ("f"))) int g2 ();
+
+int h (void)
+{
+ return g2 ();
+}
+
+int main()
+{
+ return h();
+}