Fix the following bogus diagnostic...reported by Jeroen.
#include <stdio.h>
int
main(void) {
int test = 0;
printf("Type is %s\n", (test >= 1 ? "short" : "char"));
return (0);
}
It comes up with a diagnostic that's misleading upon first read.
t.c:7:36: error: incompatible operand types ('char *' and 'char *')
printf("Type is %s\n", (test >= 1 ? "short" : "char"));
^ ~~~~~~~ ~~~~~~
1 diagnostic generated.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40526 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index cd19872..00838f7 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -585,10 +585,6 @@
(lhptee->isObjectType() || lhptee->isIncompleteType()))
return rexT;
- // FIXME: C99 6.5.15p6: If both operands are pointers to compatible types
- // *or* to differently qualified versions of compatible types, the result
- // type is a pointer to an appropriately qualified version of the
- // *composite* type.
if (!Type::typesAreCompatible(lhptee.getUnqualifiedType(),
rhptee.getUnqualifiedType())) {
Diag(questionLoc, diag::ext_typecheck_cond_incompatible_pointers,
@@ -596,6 +592,11 @@
lex->getSourceRange(), rex->getSourceRange());
return lexT; // FIXME: this is an _ext - is this return o.k?
}
+ // The pointer types are compatible.
+ // C99 6.5.15p6: If both operands are pointers to compatible types *or* to
+ // differently qualified versions of compatible types, the result type is a
+ // pointer to an appropriately qualified version of the *composite* type.
+ return lexT; // FIXME: Need to return the composite type.
}
if (lexT->isVoidType() && rexT->isVoidType()) // C99 6.5.15p3
return lexT;