This is the mail archive of the gcc-patches@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]

Re: [PATCH] Support "nothrow" function attribute



On Sun, 26 May 2002, Richard Henderson wrote:
> On Sun, May 26, 2002 at 07:21:52PM -0600, Roger Sayle wrote:
> > 	* c-common.c: Add support for __attribute__((nothrow)) to specify
> > 	that a function cannot throw an exception (using TREE_NOTHROW).
> > 	(handle_nothrow_attribute): New function to process this attribute.
> >
> > 	* doc/extend.texi: Document the new nothrow function attribute.
>
> This is ok.

Many thanks.

> > + extern void foo (void) __attribute__ ((section ("cross")));
> > + extern void superman (void) __attribute__ ((alias ("clark_kent")));
>
> Can't test these generically.

Ok, I'll remove these two lines.


> What's the point of this test case, anyway?  Seems to me that
> we should be doing functionality tests for each of these
> attributes, which tests parsing at the same time.

When I first searched the testsuite for examples of attribute tests,
I was shocked to find that there are currently no occurances of
__attribute__((pure)) or __attribute__((const)) etc..  Obviously
some patches are more meticulously reviewed than others :>  Given
this short coming and unsure of how to compose a suitable functionality
test, I thought the least I could do was to make sure that GCC could
correctly parse a "nothrow" attribute.  Without atleast this test an
attribute could be accidentally deleted and nobody may immediately
notice.

> For instance, this patch should be accompanied by a C++ test like
>
> 	// { dg-do link }
> 	extern void foo() __attribute__((nothrow))
> 	extern void link_error();
> 	int main()
> 	{
> 	  try {
> 	    foo();
> 	  } catch (...) {
> 	    link_error();
> 	  }
> 	}
> 	void foo() { }
>
> which should fail before your patch and pass afterward.

Ahhh!  That's how to do it.  Can I have permission to add this test
(with suitable comments) to the testsuite as g++.dg/ext/attrib6.C?

Roger
--


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