From 5773a6c4ab5a3a7aa9f089bfde3ca1c99ea674ac Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Tue, 13 May 2008 20:16:47 +0000 Subject: [PATCH] Both operands to && have to be scalars, not just one. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51065 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExpr.cpp | 2 +- test/Sema/typecheck-binop.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 68a3f8d593..4567d82719 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -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); } diff --git a/test/Sema/typecheck-binop.c b/test/Sema/typecheck-binop.c index 05b9ad9067..8367565de2 100644 --- a/test/Sema/typecheck-binop.c +++ b/test/Sema/typecheck-binop.c @@ -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}} */ +} -- 2.50.1