This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

about function attributes for functions returning a pointer


Hello,

in the linux kernel I defined a function as follows:

	static struct platform_device *__init __maybe_unused imx_add_imx_dma(void)
	{
		...
	}

and the only used was #ifdefed out.

With the following defines:

	#define __section(S) __attribute__ ((__section__(#S)))
	#define __cold __attribute__((__cold__))
	#define notrace __attribute__((no_instrument_function))
	#define __init	__section(.init.text) __cold notrace
	#define __maybe_unused                  __attribute__((unused))

this still generated the "defined but unused" warning.

Then after changing the definition to

	static struct platform_device __init __maybe_unused *imx_add_imx_dma(void)

(i.e. move the * after the attribute stuff) the warning is gone.  In
both cases (and when the function was used) it is put in the
".init.text" section though.  That is in the first case __init worked,
but __maybe_unused did not.  Is this intended?  Do I something wrong?
What is the most correct position for function attributes for functions
returning a pointer?

(I'm using gcc 4.3.2 for arm, OSELAS.Toolchain-1.99.3.6 here.  Could not
reproduce with Debian's gcc 4.4.5 for x86 using a minimal example.)

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]