https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84628

            Bug ID: 84628
           Summary: attribute(warning/error) should be evaluated before
                    optimization
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jay.krell at cornell dot edu
  Target Milestone: ---

This code should not error.
It is derived from real world code.

$ cat object.c
#define ERROR __attribute__ ((__error__ ("do not call this")))

int (*f1)();
int f2 () { return f1 (); }
ERROR int error1 () { return f2(); }
ERROR int error2 () { return f2(); }

$ $HOME/gcc720/bin/gcc -v

Using built-in specs.
COLLECT_GCC=/home/jay/gcc720/bin/gcc
COLLECT_LTO_WRAPPER=/home/jay/gcc720/libexec/gcc/x86_64-pc-linux-gnu/7.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /src/gcc-7.2.0/configure -prefix=/home/jay/gcc720
-enable-languages=objc,obj-c++,go,fortran -disable-multilib
Thread model: posix

gcc version 7.2.0 (GCC)

$ $HOME/gcc720/bin/gcc -c -O2 object.c
object.c: In function ‘error2’:
cc1: error: call to ‘error1’ declared with attribute error: do not call this


I will try trunk.

Reply via email to