diff options
| author | Steve Naroff <snaroff@apple.com> | 2008-05-12 21:44:38 +0000 |
|---|---|---|
| committer | Steve Naroff <snaroff@apple.com> | 2008-05-12 21:44:38 +0000 |
| commit | bf1516c61876f160a91cf0a19d77c01e95f0a457 (patch) | |
| tree | 4c3b33f4e40148b783d27cf7058f87b67f9ad574 /clang/lib/Sema | |
| parent | 1e11768a4f9a9c3e0ea43d0271ab476bbc3d0331 (diff) | |
| download | bcm5719-llvm-bf1516c61876f160a91cf0a19d77c01e95f0a457.tar.gz bcm5719-llvm-bf1516c61876f160a91cf0a19d77c01e95f0a457.zip | |
Fix <rdar://problem/5928590> clang -fsyntax-only: "incompatible operand types ('int' and 'void')" on input that 'gcc -fsyntax-only' eats
llvm-svn: 51002
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 5341ee7faa3..68a3f8d5936 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -856,9 +856,16 @@ inline QualType Sema::CheckConditionalOperands( // C99 6.5.15 } // C99 6.5.15p5: "If both operands have void type, the result has void type." - if (lexT->isVoidType() && rexT->isVoidType()) + // The following || allows only one side to be void (a GCC-ism). + if (lexT->isVoidType() || rexT->isVoidType()) { + if (!lexT->isVoidType()) + Diag(rex->getLocStart(), diag::ext_typecheck_cond_one_void, + rex->getSourceRange()); + if (!rexT->isVoidType()) + Diag(lex->getLocStart(), diag::ext_typecheck_cond_one_void, + lex->getSourceRange()); return lexT.getUnqualifiedType(); - + } // C99 6.5.15p6 - "if one operand is a null pointer constant, the result has // the type of the other operand." if (lexT->isPointerType() && rex->isNullPointerConstant(Context)) { |

