Bug 49718 - please allow no_instrument_function attribute in class member definition/declaration
Summary: please allow no_instrument_function attribute in class member definition/decl...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.9.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-12 14:21 UTC by gee
Modified: 2014-08-04 19:18 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gee 2011-07-12 14:21:54 UTC
it says
instrument.cc:10:6: error: can’t set ‘no_instrument_function’ attribute after definition
isn't it false-positive? because in class/struct it is normal one to define such member function in it.

#include <stdio.h>
struct t
{
public:
t();
__attribute__((no_instrument_function)) void a(){
}
void __attribute__((no_instrument_function))b(){
}
void c() __attribute__((no_instrument_function)){
}
void d() __attribute__((no_instrument_function));
};
void t::d()
{}
int main()
{
t a;
a.a();
}

$ g++ instrument.cc  -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i686-pc-cygwin/4.7.0/lto-wrapper.exe
Target: i686-pc-cygwin
Configured with: ./configure --config-cache --prefix=/usr --disable-win32-registry --enable-threads=win32 --enable-languages=c,c++,lto --with-win32-nlsapi=unicode --enable-tls --disable-bootstrap --enable-shared --disable-sjlj-exceptions --enable-gomp
Thread model: win32
gcc version 4.7.0 20110708 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' '-march=pentiumpro'
 /usr/libexec/gcc/i686-pc-cygwin/4.7.0/cc1plus.exe -quiet -v -D__CYGWIN32__ -D__CYGWIN__ -Dunix -D__unix__ -D__unix -idirafter /usr/lib/gcc/i686-pc-cygwin/4.7.0/../../../../i686-pc-cygwin/lib/../include/w32api -idirafter /usr/lib/gcc/i686-pc-cygwin/4.7.0/../../../../i686-pc-cygwin/lib/../../include/w32api instrument.cc -quiet -dumpbase instrument.cc -mtune=generic -march=pentiumpro -auxbase instrument -version -o /tmp/ccqnGK06.s
GNU C++ (GCC) version 4.7.0 20110708 (experimental) (i686-pc-cygwin)
        compiled by GNU C version 4.7.0 20110622 (experimental), GMP version 5.0.0, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
ignoring duplicate directory "/usr/include"
ignoring duplicate directory "/usr/lib/gcc/i686-pc-cygwin/4.7.0/../../../../i686-pc-cygwin/lib/../../include/w32api"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/i686-pc-cygwin/4.7.0/../../../../include/c++/4.7.0
 /usr/lib/gcc/i686-pc-cygwin/4.7.0/../../../../include/c++/4.7.0/i686-pc-cygwin
 /usr/lib/gcc/i686-pc-cygwin/4.7.0/../../../../include/c++/4.7.0/backward
 /usr/lib/gcc/i686-pc-cygwin/4.7.0/include
 /usr/local/include
 /usr/lib/gcc/i686-pc-cygwin/4.7.0/include-fixed
 /usr/lib/gcc/i686-pc-cygwin/4.7.0/../../../../i686-pc-cygwin/include
 /usr/lib/gcc/i686-pc-cygwin/4.7.0/../../../../i686-pc-cygwin/lib/../include/w32api
End of search list.
GNU C++ (GCC) version 4.7.0 20110708 (experimental) (i686-pc-cygwin)
        compiled by GNU C version 4.7.0 20110622 (experimental), GMP version 5.0.0, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 68ba7c3bade77b76b9651c346a28b1de
instrument.cc:6:46: error: can’t set ‘no_instrument_function’ attribute after definition
instrument.cc:8:45: error: can’t set ‘no_instrument_function’ attribute after definition
instrument.cc:10:6: error: can’t set ‘no_instrument_function’ attribute after definition
Comment 1 Avi Kivity 2013-06-13 07:50:36 UTC
Seeing this too.
Comment 2 Laurent Aflonsi 2014-01-08 09:07:01 UTC
I have post a patch about this issue :
  http://gcc.gnu.org/ml/gcc-patches/2014-01/msg00342.html
Comment 3 Jeffrey A. Law 2014-01-15 19:38:07 UTC
Author: law
Date: Wed Jan 15 19:37:35 2014
New Revision: 206643

URL: http://gcc.gnu.org/viewcvs?rev=206643&root=gcc&view=rev
Log:
	PR c++/49718
	* c-common.c (handle_no_instrument_function_attribute): Allow
	no_instrument_function attribute in class member
	definition/declaration.

	PR c++/49718
	* g++.dg/pr49718.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/pr49718.C
Modified:
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c-common.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Jeffrey A. Law 2014-01-15 19:38:33 UTC
Fixed by recent trunk commit.
Comment 5 bradley_small 2014-08-04 19:02:30 UTC
This behavior still appears in version 4.8 
g++-4.8 (Debian 4.8.3-6) 4.8.3
Comment 6 Jonathan Wakely 2014-08-04 19:18:58 UTC
(In reply to bradley_small from comment #5)
> This behavior still appears in version 4.8 
> g++-4.8 (Debian 4.8.3-6) 4.8.3

To be expected, it was only fixed in January, prior to the GCC 4.9.0 release.