aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2008-02-10 22:59:36 +0000
committerEli Friedman <eli.friedman@gmail.com>2008-02-10 22:59:36 +0000
commita541d53589f4fe681a136ce6b470d598b6d51ccd (patch)
tree0d5ff51b05ba76e97e5ffc42c87726c673030698
parent3c2eb66b0acb13c4bdd628e5e148c37958a85ec4 (diff)
Fix the type of conditionals involving void* to be self-consistent and
spec-compliant. I'll put together some testcases in a bit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46937 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Sema/SemaExpr.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index 2b63c10d98..8764a5e829 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -821,11 +821,22 @@ inline QualType Sema::CheckConditionalOperands( // C99 6.5.15
// ignore qualifiers on void (C99 6.5.15p3, clause 6)
if (lhptee->isVoidType() &&
- (rhptee->isObjectType() || rhptee->isIncompleteType()))
- return lexT;
+ (rhptee->isObjectType() || rhptee->isIncompleteType())) {
+ // figure out necessary qualifiers (C99 6.5.15p6)
+ QualType destPointee = lhptee.getQualifiedType(rhptee.getQualifiers());
+ QualType destType = Context.getPointerType(destPointee);
+ ImpCastExprToType(lex, destType); // add qualifiers if necessary
+ ImpCastExprToType(rex, destType); // promote to void*
+ return destType;
+ }
if (rhptee->isVoidType() &&
- (lhptee->isObjectType() || lhptee->isIncompleteType()))
- return rexT;
+ (lhptee->isObjectType() || lhptee->isIncompleteType())) {
+ QualType destPointee = rhptee.getQualifiedType(lhptee.getQualifiers());
+ QualType destType = Context.getPointerType(destPointee);
+ ImpCastExprToType(lex, destType); // add qualifiers if necessary
+ ImpCastExprToType(rex, destType); // promote to void*
+ return destType;
+ }
if (!Context.typesAreCompatible(lhptee.getUnqualifiedType(),
rhptee.getUnqualifiedType())) {
@@ -846,6 +857,7 @@ inline QualType Sema::CheckConditionalOperands( // C99 6.5.15
// a pointer to an appropriately qualified version of the *composite*
// type.
// FIXME: Need to return the composite type.
+ // FIXME: Need to add qualifiers
return lexT;
}
}