[cfe-commits] r46937 - /cfe/trunk/Sema/SemaExpr.cpp
Eli Friedman
eli.friedman at gmail.com
Sun Feb 10 14:59:37 PST 2008
Author: efriedma
Date: Sun Feb 10 16:59:36 2008
New Revision: 46937
URL: http://llvm.org/viewvc/llvm-project?rev=46937&view=rev
Log:
Fix the type of conditionals involving void* to be self-consistent and
spec-compliant.
I'll put together some testcases in a bit.
Modified:
cfe/trunk/Sema/SemaExpr.cpp
Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=46937&r1=46936&r2=46937&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Sun Feb 10 16:59:36 2008
@@ -821,11 +821,22 @@
// 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 @@
// 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;
}
}
More information about the cfe-commits
mailing list