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]

C++ PATCH: PR 12093


This patch fixes PR c++/12093.  String constants have special
conversion rules, so we have to avoid creating NON_DEPENDENT_EXPRs for
them.

Tested on i686-pc-linux-gnu, applied on the mainline.

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

2003-08-29  Mark Mitchell  <mark@codesourcery.com>

	PR c++/12093
	* pt.c (build_non_dependent_expr): Do not build a
	NON_DEPENDENT_EXPR for a STRING_CST.

2003-08-29  Mark Mitchell  <mark@codesourcery.com>

	PR c++/12093
	* g++.dg/template/non-dependent4.C: New test.

Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.766
diff -c -5 -p -r1.766 pt.c
*** cp/pt.c	29 Aug 2003 23:11:13 -0000	1.766
--- cp/pt.c	30 Aug 2003 01:40:59 -0000
*************** build_non_dependent_expr (tree expr)
*** 11804,11813 ****
--- 11804,11818 ----
      return expr;
    /* Preserve OVERLOADs; the functions must be available to resolve
       types.  */
    if (TREE_CODE (expr) == OVERLOAD)
      return expr;
+   /* Preserve string constants; conversions from string constants to
+      "char *" are allowed, even though normally a "const char *"
+      cannot be used to initialize a "char *".  */
+   if (TREE_CODE (expr) == STRING_CST)
+     return expr;
  
    if (TREE_CODE (expr) == COND_EXPR)
      return build (COND_EXPR,
  		  TREE_TYPE (expr),
  		  TREE_OPERAND (expr, 0),
Index: testsuite/g++.dg/template/non-dependent4.C
===================================================================
RCS file: testsuite/g++.dg/template/non-dependent4.C
diff -N testsuite/g++.dg/template/non-dependent4.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/non-dependent4.C	30 Aug 2003 01:41:00 -0000
***************
*** 0 ****
--- 1,4 ----
+ int temp(char *temp);
+ 
+ template <int> int g() { return temp("Hi"); }
+ int g1() { return temp("Hi"); }


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