This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ Patch updated] Allow __attribute__ on inline member funcs
- From: Ira Ruben <ira at apple dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 3 Jan 2002 20:06:39 -0800
- Subject: [C++ Patch updated] Allow __attribute__ on inline member funcs
Below is the patch to handle __attribute__ on inline member
functions again with a test case as Aldy requested. The patch
isn't changed, only the test case added. I've included the
original comments I made when I submitted it. Hopefully this
time it won't appear as one long unwrapped line :-)
Ira
-----------------------
While working on the __attribute__((deprecated)) patch (apparently
still unreviewed) I discovered that any __attribute__ declared for
a C++ inline member function was effectively being ignored. They
were being properly handled by the grammar but the resulting
attribute list was not being processed. The following patch corrects
this. It patches start_method() which interestingly enough has a
comments implying that changes made to start_method() should also
be done to grokfield() and vice versa. Grokfield() does handle
__attribute__ but that code was not in start_method() so I made
it do the same thing as grokfield() with the attribute list.
-----------------------
2001-01-03 Ira Ruben <ira@apple.com>
Fix to assign attributes to inline member functions.
* cp/decl.c (start_method): Handle attrlist.
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.844
diff -c -3 -p -r1.844 decl.c
*** decl.c 2001/12/18 13:30:29 1.844
--- decl.c 2002/01/04 03:39:54
*************** start_method (declspecs, declarator, att
*** 14173,14178 ****
--- 14173,14181 ----
if (fndecl == NULL_TREE)
return NULL_TREE;
+ if (attrlist)
+ cplus_decl_attributes (&fndecl, attrlist, 0);
+
/* Pass friends other than inline friend functions back. */
if (fndecl == void_type_node)
return fndecl;
Index: testsuite/g++.dg/ext/member-attr.C
===================================================================
RCS file: member-attr.C
diff -N member-attr.C
*** /dev/null Tue May 5 13:32:27 1998
--- member-attr.C Thu Jan 3 19:39:58 2002
***************
*** 0 ****
--- 1,14 ----
+ /* Test to see if__attribute__'s are handled by inline member functions */
+ /* { dg-do compile } */
+ /* { dg-options "-fmessage-length=0" } */
+
+ /* Previously __attribute__'s were handled by the grammar but "dropped
+ on the floor", these effectively ignoring them. This tests the fix
+ to see that they are now handled. In this test it should report
+ that we have an illegal attribute. */
+
+ class T {
+ public:
+ __attribute__ ((garbage1)) void member1(int) {} /* { dg-error "`garbage1' attribute directive ignored" "" } */
+ void __attribute__ ((garbage2)) member2(int) {} /* { dg-error "`garbage2' attribute directive ignored" "" } */
+ };