[PATCH] D74116: [Sema][C++] Strawman patch to propagate conversion type in order to specialize the diagnostics

2020-02-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:3880
+ToType, From->getType(), From, Action);
+// assert(Diagnosed && "failed to diagnose bad conversion");
+(void)Diagnosed;

Anastasia wrote:
> rjmccall wrote:
> > This assertion seems important; can we make it work?
> Currently DiagnoseAssignmentResult returns true only for `Incompatible` , 
> However we can change it to return true for all `Incompatibel*` in C++ mode. 
> So yes it should be doable.
Okay.  My guess is it should return true whenever we emit an error rather than 
a warning (ignoring the effects of things like `-Werror`, of course).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74116/new/

https://reviews.llvm.org/D74116



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74116: [Sema][C++] Strawman patch to propagate conversion type in order to specialize the diagnostics

2020-02-17 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked an inline comment as done.
Anastasia added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:3880
+ToType, From->getType(), From, Action);
+// assert(Diagnosed && "failed to diagnose bad conversion");
+(void)Diagnosed;

rjmccall wrote:
> This assertion seems important; can we make it work?
Currently DiagnoseAssignmentResult returns true only for `Incompatible` , 
However we can change it to return true for all `Incompatibel*` in C++ mode. So 
yes it should be doable.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74116/new/

https://reviews.llvm.org/D74116



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74116: [Sema][C++] Strawman patch to propagate conversion type in order to specialize the diagnostics

2020-02-14 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

The C diagnostic changes seem like improvements, yeah.  The virtue of re-using 
the same infrastructure across language modes.




Comment at: clang/lib/Sema/SemaExprCXX.cpp:3880
+ToType, From->getType(), From, Action);
+// assert(Diagnosed && "failed to diagnose bad conversion");
+(void)Diagnosed;

This assertion seems important; can we make it work?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74116/new/

https://reviews.llvm.org/D74116



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74116: [Sema][C++] Strawman patch to propagate conversion type in order to specialize the diagnostics

2020-02-14 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.



> It looks like there's already some type analysis in 
> `DiagnoseAssignmentResult` to get a specialized diagnostic for certain cases 
> of function-pointer assignment.  That could probably be easily moved into 
> `CheckAssignmentConstraints` by just adding a few more cases to 
> `AssignConvertResult`.

One interesting effect I get after modifying this that some extra tests in C 
mode started to report function pointer instead of generic pointer warning. I 
feel this is because in `checkPointerTypesForAssignment`  we use canonical 
types and in `DiagnoseAssignmentResult` we don't.

Perhaps this way is better? I can update the test if so and then finalize some 
other bits.

  FAIL: Clang :: Sema/block-return.c (9341 of 16808)
   TEST 'Clang :: Sema/block-return.c' FAILED 

  Script:
  --
  : 'RUN: at line 1';   <...>build/bin/clang -cc1 -internal-isystem 
<...>build/lib/clang/11.0.0/include -nostdsysteminc -Wno-int-to-pointer-cast 
-pedantic -fsyntax-only <...>clang/test/Sema/block-return.c -verify -fblocks
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  error: 'warning' diagnostics expected but not seen: 
File <...>clang/test/Sema/block-return.c Line 82: incompatible pointer 
types initializing 'int (*)(const char *)' with an expression of type 'int 
(char *)'
  error: 'warning' diagnostics seen but not expected: 
File <...>clang/test/Sema/block-return.c Line 82: incompatible function 
pointer types initializing 'int (*)(const char *)' with an expression of type 
'int (char *)'
  2 errors generated.
  
  --
  
  
  FAIL: Clang :: Sema/callingconv-ms_abi.c (9396 of 16808)
   TEST 'Clang :: Sema/callingconv-ms_abi.c' FAILED 

  Script:
  --
  : 'RUN: at line 1';   <...>build/bin/clang -cc1 -internal-isystem 
<...>build/lib/clang/11.0.0/include -nostdsysteminc -fsyntax-only -verify 
-triple x86_64-pc-win32 <...>clang/test/Sema/callingconv-ms_abi.c
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  error: 'warning' diagnostics expected but not seen: 
File <...>clang/test/Sema/callingconv-ms_abi.c Line 7: incompatible pointer 
types
File <...>clang/test/Sema/callingconv-ms_abi.c Line 9: incompatible pointer 
types
  error: 'warning' diagnostics seen but not expected: 
File <...>clang/test/Sema/callingconv-ms_abi.c Line 7: incompatible 
function pointer types initializing 'void (*)(void)' with an expression of type 
'void (void) __attribute__((sysv_abi))'
File <...>clang/test/Sema/callingconv-ms_abi.c Line 9: incompatible 
function pointer types initializing 'void (*)(void) __attribute__((sysv_abi))' 
with an expression of type 'void (void) __attribute__((ms_abi))'
  4 errors generated.
  
  --
  
  
  FAIL: Clang :: Sema/callingconv-sysv_abi.c (9397 of 16808)
   TEST 'Clang :: Sema/callingconv-sysv_abi.c' FAILED 

  Script:
  --
  : 'RUN: at line 1';   <...>build/bin/clang -cc1 -internal-isystem 
<...>build/lib/clang/11.0.0/include -nostdsysteminc -fsyntax-only -verify 
-triple x86_64-pc-linux-gnu <...>clang/test/Sema/callingconv-sysv_abi.c
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  error: 'warning' diagnostics expected but not seen: 
File <...>clang/test/Sema/callingconv-sysv_abi.c Line 4: incompatible 
pointer types
File <...>clang/test/Sema/callingconv-sysv_abi.c Line 9: incompatible 
pointer types
  error: 'warning' diagnostics seen but not expected: 
File <...>clang/test/Sema/callingconv-sysv_abi.c Line 4: incompatible 
function pointer types initializing 'void (*)(void)' with an expression of type 
'void (void) __attribute__((ms_abi))'
File <...>clang/test/Sema/callingconv-sysv_abi.c Line 9: incompatible 
function pointer types initializing 'void (*)(void) __attribute__((ms_abi))' 
with an expression of type 'void (void) __attribute__((sysv_abi))'
  4 errors generated.
  
  --
  
  
  FAIL: Clang :: Sema/callingconv.c (9398 of 16808)
   TEST 'Clang :: Sema/callingconv.c' FAILED 

  Script:
  --
  : 'RUN: at line 1';   <...>build/bin/clang -cc1 -internal-isystem 
<...>build/lib/clang/11.0.0/include -nostdsysteminc 
<...>clang/test/Sema/callingconv.c -fsyntax-only -triple i386-unknown-unknown 
-verify
  : 'RUN: at line 2';   <...>build/bin/clang -cc1 -internal-isystem 
<...>build/lib/clang/11.0.0/include -nostdsysteminc 
<...>clang/test/Sema/callingconv.c -fsyntax-only -triple i386-unknown-unknown 
-fms-compatibility -DWIN -verify
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  error: 'warning' diagnostics expected but not seen: 
File <...>clang/test/Sema/callingconv.c Line 34: incompatible pointer types
  error: 'warning' diagnostics seen but not expected: 
File <...>clang/test/Sema/callingconv.c Line 34: incompatible function 
pointer types initializing 'void (*)(void) 

[PATCH] D74116: [Sema][C++] Strawman patch to propagate conversion type in order to specialize the diagnostics

2020-02-14 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 244691.
Anastasia added a comment.
Herald added a reviewer: jdoerfert.

- Switched to using `CheckAssignmentConstraints`
- Duplicated all extensions and warnings as errors for C++ mode
- Added `IncompatibleFunctionPointer`


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74116/new/

https://reviews.llvm.org/D74116

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CXX/conv/conv.fctptr/p1.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/except/except.handle/p16.cpp
  clang/test/CXX/expr/p13.cpp
  clang/test/CXX/temp/temp.spec/temp.expl.spec/p19.cpp
  clang/test/CXX/temp/temp.spec/temp.explicit/p10.cpp
  clang/test/CXX/temp/temp.spec/temp.explicit/p9.cpp
  clang/test/OpenMP/allocate_allocator_messages.cpp
  clang/test/SemaCXX/addr-of-overloaded-function.cpp
  clang/test/SemaCXX/decl-microsoft-call-conv.cpp
  clang/test/SemaCXX/goto.cpp
  clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
  clang/test/SemaCXX/ms-property-error.cpp
  clang/test/SemaObjCXX/arc-type-conversion.mm
  clang/test/SemaObjCXX/comptypes-1.mm
  clang/test/SemaObjCXX/comptypes-7.mm
  clang/test/SemaObjCXX/instantiate-expr.mm
  clang/test/SemaObjCXX/instantiate-stmt.mm
  clang/test/SemaObjCXX/noescape.mm
  clang/test/SemaObjCXX/nullability-pragmas.mm
  clang/test/SemaObjCXX/objc-container-subscripting.mm
  clang/test/SemaObjCXX/parameterized_classes_subst.mm
  clang/test/SemaObjCXX/property-invalid-type.mm
  clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  clang/test/SemaOpenCL/address-spaces.cl
  clang/test/SemaTemplate/extern-templates.cpp
  clang/test/SemaTemplate/instantiate-member-class.cpp
  clang/test/SemaTemplate/member-access-expr.cpp
  clang/test/SemaTemplate/temp_arg_nontype.cpp

Index: clang/test/SemaTemplate/temp_arg_nontype.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype.cpp
@@ -194,7 +194,7 @@
   template
   struct Y {
 static void f(T x) { 
-  x = 1; // expected-error{{assigning to 'int *' from incompatible type 'int'}}
+  x = 1; // expected-error{{incompatible integer to pointer conversion assigning to 'int *' from 'int'}}
 }
   };
 
Index: clang/test/SemaTemplate/member-access-expr.cpp
===
--- clang/test/SemaTemplate/member-access-expr.cpp
+++ clang/test/SemaTemplate/member-access-expr.cpp
@@ -156,7 +156,7 @@
 void get(B **ptr) {
   // It's okay if at some point we figure out how to diagnose this
   // at instantiation time.
-  *ptr = field; // expected-error {{assigning to 'test6::B *' from incompatible type 'test6::A *}}
+  *ptr = field; // expected-error {{incompatible pointer types assigning to 'test6::B *' from 'test6::A *'}}
 }
   };
 }
Index: clang/test/SemaTemplate/instantiate-member-class.cpp
===
--- clang/test/SemaTemplate/instantiate-member-class.cpp
+++ clang/test/SemaTemplate/instantiate-member-class.cpp
@@ -43,8 +43,8 @@
 X::X *xf; // expected-error{{qualified reference to 'X' is a constructor name rather than a type}}
 
 void test_naming() {
-  c1 = c2; // expected-error{{assigning to 'X::C *' from incompatible type 'X::C *'}}
-  xi = xf;  // expected-error{{assigning to 'X::X *' from incompatible type 'X::X *'}}
+  c1 = c2; // expected-error{{incompatible pointer types assigning to 'X::C *' from 'X::C *'}}
+  xi = xf;  // expected-error{{incompatible pointer types assigning to 'X::X *' from 'X::X *'}}
 // FIXME: error above doesn't print the type X::X cleanly!
 }
 
Index: clang/test/SemaTemplate/extern-templates.cpp
===
--- clang/test/SemaTemplate/extern-templates.cpp
+++ clang/test/SemaTemplate/extern-templates.cpp
@@ -23,9 +23,9 @@
 template
 void X0::Inner::g(T t) {
 #ifdef MS
-  t = 17; // expected-error{{assigning to 'long *' from incompatible}} expected-error{{assigning to 'int *' from incompatible}}
+  t = 17; // expected-error{{incompatible integer to pointer conversion assigning to 'long *'}} expected-error{{incompatible integer to pointer conversion assigning to 'int *'}}
 #else
-  t = 17; // expected-error{{assigning to 'long *' from incompatible}}
+  t = 17; // expected-error{{incompatible integer to pointer conversion assigning to 'long *'}}
 #endif
 }
 
Index: clang/test/SemaOpenCL/address-spaces.cl
===
--- clang/test/SemaOpenCL/address-spaces.cl
+++ clang/test/SemaOpenCL/address-spaces.cl
@@ -20,7 +20,7 @@
 #if !__OPENCL_CPP_VERSION__
 // expected-error@-2 {{assigning '__constant int *' to '__generic int *__private' changes address space of pointer}}
 #else
-// expected-error@-4 {{assigning to '__generic int *' 

[PATCH] D74116: [Sema][C++] Strawman patch to propagate conversion type in order to specialize the diagnostics

2020-02-12 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Ah, yes, we're laxer about these things in C than we are in C++.  If we do 
this, we'll need to go through `DiagnoseAssignmentResult` and make sure that 
everything (except `Compatible`, which we'll never pass) triggers an error in 
C++ mode.

Is there a good reason to just do this for pointer types instead of 
unconditionally calling `CheckAssignmentConstraints`?  It'd be nice to take 
advantage of any specialized diagnostics we have for C/ObjC/whatever in C++ 
mode, and that can apply to a lot of types that aren't pointer types.

It looks like there's already some type analysis in `DiagnoseAssignmentResult` 
to get a specialized diagnostic for certain cases of function-pointer 
assignment.  That could probably be easily moved into 
`CheckAssignmentConstraints` by just adding a few more cases to 
`AssignConvertResult`.

And yeah, it's possible that we'll need to teach that function about some C++ 
cases that it currently never sees.  But I don't think that needs to include 
references, because IIRC reference-binding doesn't go through 
`ImplicitConversionSequence`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74116/new/

https://reviews.llvm.org/D74116



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74116: [Sema][C++] Strawman patch to propagate conversion type in order to specialize the diagnostics

2020-02-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 244135.
Anastasia added a comment.

If I reuse the helper `checkPointerTypesForAssignment` I end up with lots of 
error turned into warnings, see example in 
test/SemaCXX/addr-of-overloaded-function.cpp

I guess we don't want them to be warnings? Should we duplicate all those as 
errors in C++?

It seems there are about 3 of them that would have to be duplicated:

  [40/41] Running the Clang regression tests
  llvm-lit: ...llvm/utils/lit/lit/llvm/config.py:342: note: using clang: 
...build/bin/clang
  FAIL: Clang :: CXX/conv/conv.fctptr/p1.cpp (1051 of 16808)
   TEST 'Clang :: CXX/conv/conv.fctptr/p1.cpp' FAILED 

  Script:
  --
  : 'RUN: at line 1';   ...build/bin/clang -cc1 -internal-isystem 
...build/lib/clang/11.0.0/include -nostdsysteminc -std=c++1z -verify 
...clang/test/CXX/conv/conv.fctptr/p1.cpp -triple x86_64-unknown-unknown
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  error: 'error' diagnostics expected but not seen: 
File ...clang/test/CXX/conv/conv.fctptr/p1.cpp Line 14: assigning to 
'Nothrow *' (aka 'void (*)() noexcept') from incompatible type 'Throw *' (aka 
'void (*)()'): different exception specifications
  error: 'warning' diagnostics seen but not expected: 
File ...clang/test/CXX/conv/conv.fctptr/p1.cpp Line 14: incompatible 
function pointer types assigning to 'Nothrow *' (aka 'void (*)() noexcept') 
from 'Throw *' (aka 'void (*)()')
  2 errors generated.
  
  --
  
  
  FAIL: Clang :: CXX/except/except.handle/p16.cpp (1234 of 16808)
   TEST 'Clang :: CXX/except/except.handle/p16.cpp' FAILED 

  Script:
  --
  : 'RUN: at line 1';   ...build/bin/clang -cc1 -internal-isystem 
...build/lib/clang/11.0.0/include -nostdsysteminc -fcxx-exceptions -fexceptions 
-fsyntax-only -verify ...clang/test/CXX/except/except.handle/p16.cpp
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  error: 'error' diagnostics expected but not seen: 
File ...clang/test/CXX/except/except.handle/p16.cpp Line 14: assigning to 
'float *' from incompatible type 'int *'
File ...clang/test/CXX/except/except.handle/p16.cpp Line 19: assigning to 
'int *' from incompatible type 'float *'
  error: 'warning' diagnostics seen but not expected: 
File ...clang/test/CXX/except/except.handle/p16.cpp Line 14: incompatible 
pointer types assigning to 'float *' from 'int *'
File ...clang/test/CXX/except/except.handle/p16.cpp Line 19: incompatible 
pointer types assigning to 'int *' from 'float *'
  4 errors generated.
  
  --
  
  
  FAIL: Clang :: CXX/expr/p13.cpp (1350 of 16808)
   TEST 'Clang :: CXX/expr/p13.cpp' FAILED 

  Script:
  --
  : 'RUN: at line 1';   ...build/bin/clang -cc1 -internal-isystem 
...build/lib/clang/11.0.0/include -nostdsysteminc -std=c++1z -verify 
...clang/test/CXX/expr/p13.cpp -fexceptions -fcxx-exceptions 
-Wno-dynamic-exception-spec
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  error: 'error' diagnostics expected but not seen: 
File ...clang/test/CXX/expr/p13.cpp Line 14: different exception 
specifications
  error: 'warning' diagnostics seen but not expected: 
File ...clang/test/CXX/expr/p13.cpp Line 14: incompatible function pointer 
types assigning to 'A' (aka 'void (*)() noexcept') from 'void (*)()'
  2 errors generated.
  
  --
  
  
  FAIL: Clang :: CXX/temp/temp.decls/temp.class/temp.mem.class/p1.cpp (1519 of 
16808)
   TEST 'Clang :: 
CXX/temp/temp.decls/temp.class/temp.mem.class/p1.cpp' FAILED 

  Script:
  --
  : 'RUN: at line 1';   ...build/bin/clang -cc1 -internal-isystem 
...build/lib/clang/11.0.0/include -nostdsysteminc -fsyntax-only -verify 
...clang/test/CXX/temp/temp.decls/temp.class/temp.mem.class/p1.cpp
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  error: 'error' diagnostics expected but not seen: 
File ...clang/test/CXX/temp/temp.decls/temp.class/temp.mem.class/p1.cpp 
Line 13: incompatible
  error: 'warning' diagnostics seen but not expected: 
File ...clang/test/CXX/temp/temp.decls/temp.class/temp.mem.class/p1.cpp 
Line 13: incompatible pointer types assigning to 'int *' from 'float *'
  2 errors generated.
  
  --
  
  
  FAIL: Clang :: SemaCXX/addr-of-overloaded-function.cpp (9959 of 16808)
   TEST 'Clang :: SemaCXX/addr-of-overloaded-function.cpp' 
FAILED 
  Script:
  --
  : 'RUN: at line 1';   ...build/bin/clang -cc1 -internal-isystem 
...build/lib/clang/11.0.0/include -nostdsysteminc -fsyntax-only -verify 
...clang/test/SemaCXX/addr-of-overloaded-function.cpp
  : 'RUN: at line 2';   ...build/bin/clang -cc1 -internal-isystem 
...build/lib/clang/11.0.0/include -nostdsysteminc -fsyntax-only -verify 
-std=c++98 ...clang/test/SemaCXX/addr-of-overloaded-function.cpp
  : 'RUN: at line 3';   

[PATCH] D74116: [Sema][C++] Strawman patch to propagate conversion type in order to specialize the diagnostics

2020-02-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

This shouldn't be an expensive function call, and being a little inefficient on 
the error path to get better diagnostics is a good trade-off.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74116/new/

https://reviews.llvm.org/D74116



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74116: [Sema][C++] Strawman patch to propagate conversion type in order to specialize the diagnostics

2020-02-07 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D74116#1863186 , @rjmccall wrote:

> Hmm.  The alternative approach, I suppose, would be to recognize that we're 
> about to emit a generic error and just recheck assignment constraints to 
> recompute the AssignConvertType.


Indeed. It will need less changes around the code base but also means checks 
will be repeated.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74116/new/

https://reviews.llvm.org/D74116



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74116: [Sema][C++] Strawman patch to propagate conversion type in order to specialize the diagnostics

2020-02-06 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Hmm.  The alternative approach, I suppose, would be to recognize that we're 
about to emit a generic error and just recheck assignment constraints to 
recompute the AssignConvertType.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74116/new/

https://reviews.llvm.org/D74116



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74116: [Sema][C++] Strawman patch to propagate conversion type in order to specialize the diagnostics

2020-02-06 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added a reviewer: rjmccall.
Herald added a subscriber: ebevhan.
Anastasia edited the summary of this revision.

Currently in C++ we don't set/propagate what type of implicit conversions 
occurs on assignments/initializations/params/etc. Therefore the diagnostic 
provided is more generic than in C mode. This patch attempt to propagate the 
conversion kind through layers of C++ semantic checks. It is currently only 
used for address spaces conversion of nested pointers (from 
https://reviews.llvm.org/D73360). Setting this for other conversions would be 
quite a lot of work and I am not sure I feel confident to get it right. We 
could potentially gradually modify it as we go along. Although this is not an 
actively modified code base at the moment so not sure whether it will happen 
and when.

Feedback welcome!


https://reviews.llvm.org/D74116

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl

Index: clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
===
--- clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
+++ clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
@@ -515,11 +515,7 @@
   // Case 3: Corresponded inner pointees has overlapping but not equivalent address spaces.
   var_as_as_int = var_asc_asc_int;
 #ifdef GENERIC
-#if !__OPENCL_CPP_VERSION__
-// expected-error@-3 {{assigning '__local int *__local *__private' to '__generic int *__generic *__private' changes address space of nested pointer}}
-#else
-// expected-error@-5 {{assigning to '__generic int *__generic *' from incompatible type '__local int *__local *__private'}}
-#endif
+// expected-error-re@-2{{assigning '__local int *__local *__private' to '__generic int *__generic {{\*|\*__private}}' changes address space of nested pointer}}
 #endif
 
   var_as_as_int = (AS int *AS *)var_asc_asc_int;
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3286,9 +3286,10 @@
   // function types (recursively).
   bool ObjCLifetimeConversion = false;
   QualType ResultTy;
+  Sema::AssignConvertType ConvType = Sema::Compatible;
   if ((A->isAnyPointerType() || A->isMemberPointerType()) &&
   (S.IsQualificationConversion(A, DeducedA, false,
-   ObjCLifetimeConversion) ||
+   ObjCLifetimeConversion, ConvType) ||
S.IsFunctionConversion(A, DeducedA, ResultTy)))
 return Sema::TDK_Success;
 
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -5847,9 +5847,10 @@
!EvalResult.Val.getMemberPointerDecl())) {
 // If our expression has an appropriate type, we've succeeded.
 bool ObjCLifetimeConversion;
+Sema::AssignConvertType ConvType = Sema::Compatible;
 if (S.Context.hasSameUnqualifiedType(Arg->getType(), ParamType) ||
 S.IsQualificationConversion(Arg->getType(), ParamType, false,
- ObjCLifetimeConversion))
+ ObjCLifetimeConversion, ConvType))
   return NPV_NullPointer;
 
 // The types didn't match, but we know we got a null pointer; complain,
@@ -5884,10 +5885,11 @@
 Sema , NonTypeTemplateParmDecl *Param, QualType ParamType, Expr *ArgIn,
 Expr *Arg, QualType ArgType) {
   bool ObjCLifetimeConversion;
+  Sema::AssignConvertType ConvType = Sema::Compatible;
   if (ParamType->isPointerType() &&
   !ParamType->castAs()->getPointeeType()->isFunctionType() &&
   S.IsQualificationConversion(ArgType, ParamType, false,
-  ObjCLifetimeConversion)) {
+  ObjCLifetimeConversion, ConvType)) {
 // For pointer-to-object types, qualification conversions are
 // permitted.
   } else {
@@ -6303,10 +6305,10 @@
   case NPV_NotNullPointer:
 break;
   }
-
+  Sema::AssignConvertType ConvType = Sema::Compatible;
   if (S.IsQualificationConversion(ResultArg->getType(),
   ParamType.getNonReferenceType(), false,
-  ObjCLifetimeConversion)) {
+  ObjCLifetimeConversion, ConvType)) {
 ResultArg = S.ImpCastExprToType(ResultArg, ParamType, CK_NoOp,
 ResultArg->getValueKind())
 .get();
Index: clang/lib/Sema/SemaOverload.cpp