mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-19 05:10:25 +08:00
re PR c++/11962 (ICE in type_dependent_expression on omitted second operand to ?: in template argument expression)
PR c++/11962 * typeck.c (build_x_conditional_expr): Handle missing middle operands in templates. * mangle.c (write_expression): Issue errors about attempts to mangle a non-existant middle operator to the ?: operator. PR c++/11962 * g++.dg/template/cond2.C: New test. From-SVN: r72785
This commit is contained in:
parent
4f52529432
commit
18fd68a8b3
@ -1,3 +1,11 @@
|
||||
2003-10-21 Mark Mitchell <mark@codesourcery.com>
|
||||
|
||||
PR c++/11962
|
||||
* typeck.c (build_x_conditional_expr): Handle missing middle
|
||||
operands in templates.
|
||||
* mangle.c (write_expression): Issue errors about attempts to
|
||||
mangle a non-existant middle operator to the ?: operator.
|
||||
|
||||
2003-10-21 Robert Bowdidge <bowdidge@apple.com>
|
||||
* decl.c (cp_finish_decl): Remove clause intended for asm directives
|
||||
in struct or class fields: this code is never executed.
|
||||
|
@ -2041,7 +2041,21 @@ write_expression (tree expr)
|
||||
|
||||
default:
|
||||
for (i = 0; i < TREE_CODE_LENGTH (code); ++i)
|
||||
write_expression (TREE_OPERAND (expr, i));
|
||||
{
|
||||
tree operand = TREE_OPERAND (expr, i);
|
||||
/* As a GNU expression, the middle operand of a
|
||||
conditional may be omitted. Since expression
|
||||
manglings are supposed to represent the input token
|
||||
stream, there's no good way to mangle such an
|
||||
expression without extending the C++ ABI. */
|
||||
if (code == COND_EXPR && i == 1 && !operand)
|
||||
{
|
||||
error ("omitted middle operand to `?:' operand "
|
||||
"cannot be mangled");
|
||||
continue;
|
||||
}
|
||||
write_expression (operand);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4284,11 +4284,13 @@ build_x_conditional_expr (tree ifexp, tree op1, tree op2)
|
||||
IFEXP is type-dependent, even though the eventual type of the
|
||||
expression doesn't dependent on IFEXP. */
|
||||
if (type_dependent_expression_p (ifexp)
|
||||
|| type_dependent_expression_p (op1)
|
||||
/* As a GNU extension, the middle operand may be omitted. */
|
||||
|| (op1 && type_dependent_expression_p (op1))
|
||||
|| type_dependent_expression_p (op2))
|
||||
return build_min_nt (COND_EXPR, ifexp, op1, op2);
|
||||
ifexp = build_non_dependent_expr (ifexp);
|
||||
op1 = build_non_dependent_expr (op1);
|
||||
if (op1)
|
||||
op1 = build_non_dependent_expr (op1);
|
||||
op2 = build_non_dependent_expr (op2);
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
2003-10-21 Mark Mitchell <mark@codesourcery.com>
|
||||
|
||||
PR c++/11962
|
||||
* g++.dg/template/cond2.C: New test.
|
||||
|
||||
2003-10-20 Joseph S. Myers <jsm@polyomino.org.uk>
|
||||
|
||||
* gcc.dg/builtins-28.c: New test.
|
||||
|
10
gcc/testsuite/g++.dg/template/cond2.C
Normal file
10
gcc/testsuite/g++.dg/template/cond2.C
Normal file
@ -0,0 +1,10 @@
|
||||
// PR c++/11962
|
||||
// { dg-options "" }
|
||||
|
||||
template<int X> class c;
|
||||
|
||||
template<int X, int Y> int test(c<X ? : Y>&);
|
||||
|
||||
void test(c<2>*c2) {
|
||||
test<0, 2>(*c2); // { dg-error "omitted" }
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user