From: Eli Friedman Date: Tue, 12 Feb 2008 08:23:06 +0000 (+0000) Subject: Fix type compatibility between constant and variable arrays. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4c721d381fb279899337d120edd4a24d405e56b2;p=clang 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 --- 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); }