[cfe-commits] r55620 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/pointer-subtract-compat.c
Eli Friedman
eli.friedman at gmail.com
Mon Sep 1 22:09:35 PDT 2008
Author: efriedma
Date: Tue Sep 2 00:09:35 2008
New Revision: 55620
URL: http://llvm.org/viewvc/llvm-project?rev=55620&view=rev
Log:
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.
Added:
cfe/trunk/test/Sema/pointer-subtract-compat.c
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=55620&r1=55619&r2=55620&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Sep 2 00:09:35 2008
@@ -1013,7 +1013,7 @@
AssignConvertType ConvTy =
CheckSingleAssignmentConstraints(ProtoArgType, Arg);
TheCall->setArg(i, Arg);
-
+
if (DiagnoseAssignmentResult(ConvTy, Arg->getLocStart(), ProtoArgType,
ArgType, Arg, "passing"))
return true;
@@ -1700,8 +1700,9 @@
}
// 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());
Added: cfe/trunk/test/Sema/pointer-subtract-compat.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/pointer-subtract-compat.c?rev=55620&view=auto
==============================================================================
--- cfe/trunk/test/Sema/pointer-subtract-compat.c (added)
+++ cfe/trunk/test/Sema/pointer-subtract-compat.c Tue Sep 2 00:09:35 2008
@@ -0,0 +1,6 @@
+// RUN: clang %s -fsyntax-only -verify -pedantic
+
+typedef const char rchar;
+int a(char* a, rchar* b) {
+ return a-b;
+}
More information about the cfe-commits
mailing list