suppress spurious "typecheck_cond_expect_scalar" diagnostic.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/Sema/SemaExpr.cpp | ||
---|---|---|
8072 | This follows the same way of how C++ codepath handles dependent code, see the above Line 8069 CXXCheckConditionalOperands. |
clang/test/Sema/error-dependence.c | ||
---|---|---|
14 | 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? |
rebase and add ast-dump test.
clang/test/Sema/error-dependence.c | ||
---|---|---|
14 |
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'
no unfortunately. the whole statement is being dropped (we don't preserve this in C/C++). |
address comments
clang/test/Sema/error-dependence.c | ||
---|---|---|
14 | oh, yeah. undefined() is not working (undefined function is implicitly treated as int () in C), but call() would work. |
This follows the same way of how C++ codepath handles dependent code, see the above Line 8069 CXXCheckConditionalOperands.