aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-03-02 17:19:43 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2018-03-02 17:19:43 +0100
commit16225110ca8ae760f001c57571fa7e7e03c2c1fc (patch)
tree507c8717f341392d7b3c7b820b83416ffbd72560
parente3a72bc5dba4df94f74e6c49849e7b1b0c45ac11 (diff)
downloadgcc-16225110ca8ae760f001c57571fa7e7e03c2c1fc.zip
gcc-16225110ca8ae760f001c57571fa7e7e03c2c1fc.tar.gz
gcc-16225110ca8ae760f001c57571fa7e7e03c2c1fc.tar.bz2
re PR ipa/84628 (attribute(warning/error) functions should not be merged together)
PR ipa/84628 * expr.c (expand_expr_real_1) <case CALL_EXPR>: Don't emit diagnostics for error or warning attributes if CALL_FROM_THUNK_P is set. Formatting fixes. * gcc.dg/pr84628.c: New test. Co-Authored-By: Richard Biener <rguenther@suse.de> From-SVN: r258140
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/expr.c26
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/gcc.dg/pr84628.c8
4 files changed, 38 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a2263ed..447d563 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,4 +1,12 @@
2018-03-02 Jakub Jelinek <jakub@redhat.com>
+ Richard Biener <rguenther@suse.de>
+
+ PR ipa/84628
+ * expr.c (expand_expr_real_1) <case CALL_EXPR>: Don't emit diagnostics
+ for error or warning attributes if CALL_FROM_THUNK_P is set.
+ Formatting fixes.
+
+2018-03-02 Jakub Jelinek <jakub@redhat.com>
PR target/56540
* config/pa/pa.h (TARGET_CPU_CPP_BUILTINS): Predefine
diff --git a/gcc/expr.c b/gcc/expr.c
index 876883e..0066029 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -10963,18 +10963,30 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
tree fndecl = get_callee_fndecl (exp), attr;
if (fndecl
+ /* Don't diagnose the error attribute in thunks, those are
+ artificially created. */
+ && !CALL_FROM_THUNK_P (exp)
&& (attr = lookup_attribute ("error",
DECL_ATTRIBUTES (fndecl))) != NULL)
- error ("%Kcall to %qs declared with attribute error: %s",
- exp, identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 1)),
- TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))));
+ {
+ const char *ident = lang_hooks.decl_printable_name (fndecl, 1);
+ error ("%Kcall to %qs declared with attribute error: %s", exp,
+ identifier_to_locale (ident),
+ TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))));
+ }
if (fndecl
+ /* Don't diagnose the warning attribute in thunks, those are
+ artificially created. */
+ && !CALL_FROM_THUNK_P (exp)
&& (attr = lookup_attribute ("warning",
DECL_ATTRIBUTES (fndecl))) != NULL)
- warning_at (tree_nonartificial_location (exp),
- 0, "%Kcall to %qs declared with attribute warning: %s",
- exp, identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 1)),
- TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))));
+ {
+ const char *ident = lang_hooks.decl_printable_name (fndecl, 1);
+ warning_at (tree_nonartificial_location (exp), 0,
+ "%Kcall to %qs declared with attribute warning: %s",
+ exp, identifier_to_locale (ident),
+ TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr))));
+ }
/* Check for a built-in function. */
if (fndecl && DECL_BUILT_IN (fndecl))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 67eefea3..84ebf2e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2018-03-02 Jakub Jelinek <jakub@redhat.com>
+ PR ipa/84628
+ * gcc.dg/pr84628.c: New test.
+
PR target/56540
* gcc.target/ia64/pr56540.c: New test.
diff --git a/gcc/testsuite/gcc.dg/pr84628.c b/gcc/testsuite/gcc.dg/pr84628.c
new file mode 100644
index 0000000..b8eb53c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr84628.c
@@ -0,0 +1,8 @@
+/* PR ipa/84628 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int f0 (void);
+__attribute__((error ("err"))) void f1 (void) { f0 (); f0 (); }
+__attribute__((error ("err"))) void f2 (void) { f0 (); f0 (); }
+/* { dg-bogus "declared with attribute error" "" { target *-*-* } 0 } */