aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-02-15 08:38:09 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2019-02-15 08:38:09 +0100
commit5f88ba10e017ec213b0fc4e1b0cd63f3dfcb6660 (patch)
treec20914b1d6a929372243af28a01055edaba9e6ec /gcc
parentf521d9d8ad83137bd2965556f2395a264efa80d7 (diff)
downloadgcc-5f88ba10e017ec213b0fc4e1b0cd63f3dfcb6660.zip
gcc-5f88ba10e017ec213b0fc4e1b0cd63f3dfcb6660.tar.gz
gcc-5f88ba10e017ec213b0fc4e1b0cd63f3dfcb6660.tar.bz2
re PR c/89340 (ICE in function_and_variable_visibility, at ipa-visibility.c:707)
PR c/89340 * c-decl.c (start_function): Clear TREE_PUBLIC on nested functions before c_decl_attributes rather than after it. * gcc.dg/pr89340.c: New test. * gcc.dg/torture/pr57036-2.c (jpgDecode_convert): Expect a warning that leaf attribute on nested function is useless. From-SVN: r268926
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-decl.c8
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr89340.c9
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr57036-2.c2
5 files changed, 25 insertions, 5 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index ebe944a..1def92a 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,9 @@
+2019-02-15 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/89340
+ * c-decl.c (start_function): Clear TREE_PUBLIC on nested functions
+ before c_decl_attributes rather than after it.
+
2019-02-06 Jakub Jelinek <jakub@redhat.com>
PR c/89211
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index b658eb1..69c04d5 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -8904,6 +8904,10 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
loc = DECL_SOURCE_LOCATION (decl1);
+ /* A nested function is not global. */
+ if (current_function_decl != NULL_TREE)
+ TREE_PUBLIC (decl1) = 0;
+
c_decl_attributes (&decl1, attributes, 0);
if (DECL_DECLARED_INLINE_P (decl1)
@@ -8945,10 +8949,6 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
error_mark_node is replaced below (in pop_scope) with the BLOCK. */
DECL_INITIAL (decl1) = error_mark_node;
- /* A nested function is not global. */
- if (current_function_decl != NULL_TREE)
- TREE_PUBLIC (decl1) = 0;
-
/* If this definition isn't a prototype and we had a prototype declaration
before, copy the arg type info from that prototype. */
old_decl = lookup_name_in_scope (DECL_NAME (decl1), current_scope);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f122cd7..582d28d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2019-02-15 Jakub Jelinek <jakub@redhat.com>
+ PR c/89340
+ * gcc.dg/pr89340.c: New test.
+ * gcc.dg/torture/pr57036-2.c (jpgDecode_convert): Expect a warning
+ that leaf attribute on nested function is useless.
+
PR other/89342
* gcc.dg/pr89342.c: New test.
diff --git a/gcc/testsuite/gcc.dg/pr89340.c b/gcc/testsuite/gcc.dg/pr89340.c
new file mode 100644
index 0000000..8636d22
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr89340.c
@@ -0,0 +1,9 @@
+/* PR c/89340 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void bar (void)
+{
+ __attribute__((weak)) void foo () {} /* { dg-error "weak declaration of 'foo' must be public" } */
+ foo ();
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr57036-2.c b/gcc/testsuite/gcc.dg/torture/pr57036-2.c
index 6e70d3b..972cc35 100644
--- a/gcc/testsuite/gcc.dg/torture/pr57036-2.c
+++ b/gcc/testsuite/gcc.dg/torture/pr57036-2.c
@@ -9,7 +9,7 @@ int jpgDecode_convert (unsigned i)
int j;
inline void __attribute__((always_inline,leaf)) f(void)
- {
+ { /* { dg-warning "'leaf' attribute has no effect" } */
g();
}