hokein added inline comments.
================ Comment at: clang/test/Sema/error-dependence.c:18 + // type is required" is not emitted. + ptr > f ? ptr : f; // expected-error {{invalid operands to binary expression}} +} ---------------- sammccall wrote: > hokein wrote: > > sammccall wrote: > > > nit: parens would help me understand here :-) > > > > > > I don't find this example compelling because we should know that "ptr > > > > f" is a boolean. > > > > > > Can we just have `undefined ? ptr : f`, expecting the only diag to be the > > > undeclared ident? > > > I don't find this example compelling because we should know that "ptr > > > > f" is a boolean. > > > > this is a reasonable impression, but in this case, there is no > > binary-operator `>` -- operands `ptr`, `f` have different types, and > > invalid for binary operator, instead we build a recovery-expr. > > > > so the AST looks like (added in the dump-recovery.c test as well) > > > > ``` > > ConditionalOperator> '<dependent type>' contains-errors > > | |-RecoveryExpr '<dependent type>' contains-errors lvalue > > | | |-DeclRefExpr 'int *' lvalue Var 0x8fdb620 'ptr' 'int *' > > | | `-DeclRefExpr 'float' lvalue Var 0x8ffd388 'f' 'float' > > | |-DeclRefExpr 'int *' lvalue Var 0x8fdb620 'ptr' 'int *' > > | `-DeclRefExpr 'float' lvalue Var 0x8ffd388 'f' 'float' > > ``` > > > > > Can we just have undefined ? ptr : f, expecting the only diag to be the > > > undeclared ident? > > > > no unfortunately. the whole statement is being dropped (we don't preserve > > this in C/C++). > `undefined() ? ptr : f` then? oh, yeah. undefined() is not working (undefined function is implicitly treated as `int ()` in C), but `call()` would work. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D84322/new/ https://reviews.llvm.org/D84322 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits