]> granicus.if.org Git - clang/commitdiff
Fix type compatibility between constant and variable arrays.
authorEli Friedman <eli.friedman@gmail.com>
Tue, 12 Feb 2008 08:23:06 +0000 (08:23 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Tue, 12 Feb 2008 08:23:06 +0000 (08:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47003 91177308-0d34-0410-b5e6-96231b3b80d8

AST/ASTContext.cpp
test/Sema/conditional-expr.c

index 6eae4584d5ed830ea1c2078c9ae7be7c1157cdd4..dd8a9d4ecf3cfc4c99c537423394b80a841728bc 100644 (file)
@@ -1685,6 +1685,10 @@ bool ASTContext::typesAreCompatible(QualType lhs, QualType rhs) {
   // comparisons, just force one to the other.
   if (LHSClass == Type::FunctionProto) LHSClass = Type::FunctionNoProto;
   if (RHSClass == Type::FunctionProto) RHSClass = Type::FunctionNoProto;
+
+  // Same as above for arrays
+  if (LHSClass == Type::VariableArray) LHSClass = Type::ConstantArray;
+  if (RHSClass == Type::VariableArray) RHSClass = Type::ConstantArray;
   
   // If the canonical type classes don't match...
   if (LHSClass != RHSClass) {
index 0c9052845c336e5a263d80176df66f5ab2558629..a24846ac1de6718683736f01c7cdbc7d09f233b0 100644 (file)
@@ -22,5 +22,10 @@ void foo() {
   const int *cip;
   vp = (0 ? vp : cip); // expected-warning {{discards qualifiers}}
   vp = (0 ? cip : vp); // expected-warning {{discards qualifiers}}
+
+  int i = 2;
+  int (*pf)[2];
+  int (*pv)[i];
+  pf = (i ? pf : pv);
 }