aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2008-02-12 08:23:06 +0000
committerEli Friedman <eli.friedman@gmail.com>2008-02-12 08:23:06 +0000
commit4c721d381fb279899337d120edd4a24d405e56b2 (patch)
treec981d5dff5bdf1cf57e2b6e48f95e3e09f8a8bd1
parent9532414c45a7114d9e94a733121655a5b5d5b473 (diff)
Fix type compatibility between constant and variable arrays.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47003 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--AST/ASTContext.cpp4
-rw-r--r--test/Sema/conditional-expr.c5
2 files changed, 9 insertions, 0 deletions
diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp
index 6eae4584d5..dd8a9d4ecf 100644
--- a/AST/ASTContext.cpp
+++ b/AST/ASTContext.cpp
@@ -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) {
diff --git a/test/Sema/conditional-expr.c b/test/Sema/conditional-expr.c
index 0c9052845c..a24846ac1d 100644
--- a/test/Sema/conditional-expr.c
+++ b/test/Sema/conditional-expr.c
@@ -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);
}