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 12515


This patch fixes PR c++/12515, which is yet another problem with one
of the silliest of all GNU extensions: the omitted second argument to
a ?: operator.

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

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

2003-11-21  Mark Mitchell  <mark@codesourcery.com>

	PR c++/12515
	* pt.c (build_non_dependent_expr): Handle GNU extension to ?:
	operator.

2003-11-21  Mark Mitchell  <mark@codesourcery.com>

	PR c++/12515
	* g++.dg/ext/cond1.C: New test.

Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.794
diff -c -5 -p -r1.794 pt.c
*** cp/pt.c	14 Nov 2003 04:51:21 -0000	1.794
--- cp/pt.c	21 Nov 2003 22:14:46 -0000
*************** build_non_dependent_expr (tree expr)
*** 11891,11901 ****
  
    if (TREE_CODE (expr) == COND_EXPR)
      return build (COND_EXPR,
  		  TREE_TYPE (expr),
  		  TREE_OPERAND (expr, 0),
! 		  build_non_dependent_expr (TREE_OPERAND (expr, 1)),
  		  build_non_dependent_expr (TREE_OPERAND (expr, 2)));
    if (TREE_CODE (expr) == COMPOUND_EXPR
        && !COMPOUND_EXPR_OVERLOADED (expr))
      return build (COMPOUND_EXPR,
  		  TREE_TYPE (expr),
--- 11891,11903 ----
  
    if (TREE_CODE (expr) == COND_EXPR)
      return build (COND_EXPR,
  		  TREE_TYPE (expr),
  		  TREE_OPERAND (expr, 0),
! 		  (TREE_OPERAND (expr, 1) 
! 		   ? build_non_dependent_expr (TREE_OPERAND (expr, 1))
! 		   : build_non_dependent_expr (TREE_OPERAND (expr, 0))),
  		  build_non_dependent_expr (TREE_OPERAND (expr, 2)));
    if (TREE_CODE (expr) == COMPOUND_EXPR
        && !COMPOUND_EXPR_OVERLOADED (expr))
      return build (COMPOUND_EXPR,
  		  TREE_TYPE (expr),
Index: testsuite/g++.dg/ext/cond1.C
===================================================================
RCS file: testsuite/g++.dg/ext/cond1.C
diff -N testsuite/g++.dg/ext/cond1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/ext/cond1.C	21 Nov 2003 22:14:46 -0000
***************
*** 0 ****
--- 1,4 ----
+ // PR c++/12515
+ // { dg-do compile }
+ // { dg-options "" }
+ template<int> void foo() { 0 ?: 0; }


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