PATCH for Re: Bug with const int, typedef and templates

Mark Mitchell mmitchell@usa.net
Sun Mar 22 12:55:00 GMT 1998


Laurent --

  Here's a patch for your bug.  Jason?

-- 
Mark Mitchell <mmitchell@usa.net>
http://home.earthlink.net/~mbmitchell
Consulting Services Available

Sun Mar 22 11:35:13 1998  Mark Mitchell  <mmitchell@usa.net>

	* decl.c (grokdeclarator): When creating PARM_DECLs, make sure not
	to use cv-qualified types.

Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.81
diff -c -p -r1.81 decl.c
*** decl.c	1998/03/20 11:43:36	1.81
--- decl.c	1998/03/22 20:34:49
*************** grokdeclarator (declarator, declspecs, d
*** 9613,9618 ****
--- 9613,9632 ----
  	    return NULL_TREE;
  	  }
  
+ 	/* We use TYPE_MAIN_VARIANT below because of:
+ 
+ 	   [dcl.fct]
+ 
+ 	   Any cv-qualifier modifying a parameter type is deleted.
+ 	   [Example: the type void(*)(const int) becomes void(*)(int)
+ 	   --end example] Such cv-qualifiers affect only the
+ 	   definition of the parameter within the body of the
+ 	   function; they do not affect the function type.  
+ 
+ 	   However, we must not do this for opaque types in signatures.  */
+ 	if (TYPE_MAIN_VARIANT (type) != opaque_type_node)
+ 	  type = TYPE_MAIN_VARIANT (type);
+ 
  	decl = build_decl (PARM_DECL, declarator, complete_type (type));
  
  	bad_specifiers (decl, "parameter", virtualp, quals != NULL_TREE,
Index: typedef2.C
===================================================================
RCS file: typedef2.C
diff -N typedef2.C
*** /dev/null	Mon Dec 31 20:00:00 1979
--- typedef2.C	Sun Mar 22 11:35:25 1998
***************
*** 0 ****
--- 1,20 ----
+ // Build don't link:
+ 
+ typedef const int cint;
+ 
+ template<class T>
+ class A
+ {
+ public:
+   T f(cint i);
+ };
+ 
+ template <class T>
+ T A<T>::f(cint i)
+ {
+ }
+ 
+ int main()
+ {
+   A<int> a;
+ }



More information about the Gcc-bugs mailing list