+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.
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);
+ }
}
}
}
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);
}
+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.
--- /dev/null
+// 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" }
+}