diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2008-02-10 22:59:36 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2008-02-10 22:59:36 +0000 |
| commit | 15888c23f5841d25b01333d0806d272ede734fd9 (patch) | |
| tree | 89faac6bf5cd07f99552f10544b1e49fbbd36ae2 /clang | |
| parent | 15833ed168088fc0140fbf1552735bbf7f480840 (diff) | |
| download | bcm5719-llvm-15888c23f5841d25b01333d0806d272ede734fd9.tar.gz bcm5719-llvm-15888c23f5841d25b01333d0806d272ede734fd9.zip | |
Fix the type of conditionals involving void* to be self-consistent and
spec-compliant.
I'll put together some testcases in a bit.
llvm-svn: 46937
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/Sema/SemaExpr.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/clang/Sema/SemaExpr.cpp b/clang/Sema/SemaExpr.cpp index 2b63c10d98e..8764a5e829d 100644 --- a/clang/Sema/SemaExpr.cpp +++ b/clang/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; } } |

