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

Another PATCH for nontype argument conversion



Jason --

  Here's another patch to handle nontype argument conversion
correctly. 

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

Wed Mar 25 13:21:52 1998  Mark Mitchell  <mmitchell@usa.net>

	* pt.c (convert_nontype_argument): STRIP_NOPS where appropriate.

Index: pt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/pt.c,v
retrieving revision 1.105
diff -c -p -r1.105 pt.c
*** pt.c	1998/03/24 16:13:10	1.105
--- pt.c	1998/03/25 21:33:52
*************** convert_nontype_argument (type, expr)
*** 1861,1868 ****
  	   || expr_type == unknown_type_node)
      {
        tree referent;
  
!       if (TREE_CODE (expr) != ADDR_EXPR)
  	{
  	bad_argument:
  	  cp_error ("`%E' is not a valid template argument", expr);
--- 1861,1870 ----
  	   || expr_type == unknown_type_node)
      {
        tree referent;
+       tree e = expr;
+       STRIP_NOPS (e);
  
!       if (TREE_CODE (e) != ADDR_EXPR)
  	{
  	bad_argument:
  	  cp_error ("`%E' is not a valid template argument", expr);
*************** convert_nontype_argument (type, expr)
*** 1874,1880 ****
  	  return NULL_TREE;
  	}
  
!       referent = TREE_OPERAND (expr, 0);
        STRIP_NOPS (referent);
        
        if (TREE_CODE (referent) == STRING_CST)
--- 1876,1882 ----
  	  return NULL_TREE;
  	}
  
!       referent = TREE_OPERAND (e, 0);
        STRIP_NOPS (referent);
        
        if (TREE_CODE (referent) == STRING_CST)
Index: nontype3.C
===================================================================
RCS file: nontype3.C
diff -N nontype3.C
*** /dev/null	Mon Dec 31 20:00:00 1979
--- nontype3.C	Wed Mar 25 13:29:33 1998
***************
*** 0 ****
--- 1,28 ----
+ // Build don't link:
+ 
+ enum E { e };
+ 
+ template <const E* ep>
+ struct S1
+ {
+   static char* s;
+ };
+ 
+ template <int D>
+ struct S2 {};
+ 
+ template <>
+ struct S2<1>
+ {
+   static E es[1];
+ };
+ 
+ struct S3
+ {
+   typedef S1<S2<1>::es> S3_Type;
+ };
+ 
+ E S2<1>::es[1] = {e};
+ 
+ template <>
+ char* S1<S2<1>::es>::s = "abc";


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