]> granicus.if.org Git - clang/commitdiff
Both operands to && have to be scalars, not just one.
authorEli Friedman <eli.friedman@gmail.com>
Tue, 13 May 2008 20:16:47 +0000 (20:16 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Tue, 13 May 2008 20:16:47 +0000 (20:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51065 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/Sema/typecheck-binop.c

index 68a3f8d5936532d006fce8e34f3a9e551debfffc..4567d82719fcc4b857bcf93bc00fe4c832a07c9a 100644 (file)
@@ -1603,7 +1603,7 @@ inline QualType Sema::CheckLogicalOperands( // C99 6.5.[13,14]
   UsualUnaryConversions(lex);
   UsualUnaryConversions(rex);
   
-  if (lex->getType()->isScalarType() || rex->getType()->isScalarType())
+  if (lex->getType()->isScalarType() && rex->getType()->isScalarType())
     return Context.IntTy;
   return InvalidOperands(loc, lex, rex);
 }
index 05b9ad9067e10a4881fa0777b5bf0b9c3f37c56a..8367565de2eab26f725e9a90a03015cc29ca1448 100644 (file)
@@ -18,3 +18,6 @@ int sub4(void *P, void *Q) {
   return P-Q;      /* expected-warning{{GNU void* extension}} */
 }
 
+int logicaland1(int a) {
+  return a && (void)a; /* expected-error{{invalid operands}} */
+}