C++ PATCH: PR 24260

Mark Mitchell mark@codesourcery.com
Fri Oct 21 16:06:00 GMT 2005


This patch fixes a thinko in the new parser; we parsed the attributes
for members, but were forgetting to pass them along to the rest of the
compiler.  (Some, which were directly reflected in the types of
functions, worked anyhow -- but things like "stdcall" that live off on
the side, did not.)

Tested on x86_64-unknown-linux-gnu (in 32-bit mode), applied on the
mainline and on the 4.0 branch.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2005-10-21  Mark Mitchell  <mark@codesourcery.com>

	PR c++/24260
	* parser.c (cp_parser_init_declarator): Pass attributes to
	grokfield. 

2005-10-21  Mark Mitchell  <mark@codesourcery.com>

	PR c++/24260
	* g++.dg/ext/tmplattr1.C: New test.

Index: gcc/testsuite/g++.dg/ext/tmplattr1.C
===================================================================
RCS file: gcc/testsuite/g++.dg/ext/tmplattr1.C
diff -N gcc/testsuite/g++.dg/ext/tmplattr1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc/testsuite/g++.dg/ext/tmplattr1.C	21 Oct 2005 01:35:59 -0000
***************
*** 0 ****
--- 1,24 ----
+ // PR c++/24260
+ // { dg-do compile { target i?86-*-* x86_64-*-* } }
+ // { dg-require-effective-target ilp32 }
+ 
+ #define stdcall __attribute__((stdcall))
+ 
+ struct T {
+   template <class S>
+   static int stdcall func(int arg1, int arg2);
+ };
+ 
+ template <class S>
+ int stdcall T::func(int arg1, int arg2)
+ {
+   return arg1+arg2;
+ }
+ 
+ struct dummy {};
+ 
+ void xx()
+ {
+   int (stdcall *ptr2)(int,int) = &T::func<dummy>;
+ }
+ 
Index: gcc/cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.367
diff -c -5 -p -r1.367 parser.c
*** gcc/cp/parser.c	17 Oct 2005 22:22:29 -0000	1.367
--- gcc/cp/parser.c	21 Oct 2005 01:36:00 -0000
*************** cp_parser_init_declarator (cp_parser* pa
*** 10936,10946 ****
  	  pop_scope (pushed_scope);
  	  pushed_scope = false;
  	}
        decl = grokfield (declarator, decl_specifiers,
  			initializer, /*asmspec=*/NULL_TREE,
! 			/*attributes=*/NULL_TREE);
        if (decl && TREE_CODE (decl) == FUNCTION_DECL)
  	cp_parser_save_default_args (parser, decl);
      }
  
    /* Finish processing the declaration.  But, skip friend
--- 10936,10946 ----
  	  pop_scope (pushed_scope);
  	  pushed_scope = false;
  	}
        decl = grokfield (declarator, decl_specifiers,
  			initializer, /*asmspec=*/NULL_TREE,
! 			prefix_attributes);
        if (decl && TREE_CODE (decl) == FUNCTION_DECL)
  	cp_parser_save_default_args (parser, decl);
      }
  
    /* Finish processing the declaration.  But, skip friend



More information about the Gcc-patches mailing list