Make sure to take the unqualified versions of the canonical types for
type-checking pointer subtraction; if the canonical types aren't used, the qualifiers won't always get stripped off correctly. llvm-svn: 55620
This commit is contained in:
parent
a1035df101
commit
e7175d83dc
|
@ -1700,8 +1700,9 @@ QualType Sema::CheckSubtractionOperands(Expr *&lex, Expr *&rex,
|
|||
}
|
||||
|
||||
// Pointee types must be compatible.
|
||||
if (!Context.typesAreCompatible(lpointee.getUnqualifiedType(),
|
||||
rpointee.getUnqualifiedType())) {
|
||||
if (!Context.typesAreCompatible(
|
||||
Context.getCanonicalType(lpointee).getUnqualifiedType(),
|
||||
Context.getCanonicalType(rpointee).getUnqualifiedType())) {
|
||||
Diag(loc, diag::err_typecheck_sub_ptr_compatible,
|
||||
lex->getType().getAsString(), rex->getType().getAsString(),
|
||||
lex->getSourceRange(), rex->getSourceRange());
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
// RUN: clang %s -fsyntax-only -verify -pedantic
|
||||
|
||||
typedef const char rchar;
|
||||
int a(char* a, rchar* b) {
|
||||
return a-b;
|
||||
}
|
Loading…
Reference in New Issue