[clang] [clang] Improve source location in binary type traits diagnostics (PR #88097)

2024-04-09 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll closed 
https://github.com/llvm/llvm-project/pull/88097
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Improve source location in binary type traits diagnostics (PR #88097)

2024-04-09 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

> Do we now have enough information to pass a source range as well?

Yes, `TypeLoc` inside `TypeSourceInfo` has two `SourceLocation` object that 
represent the range.
In order to limit the scope of the PR, I'm not refactoring 
`RequireCompleteType` and friends to accept `TypeSourceInfo`, but that's an 
obvious next step. Diagnostics would benefit from source range.

https://github.com/llvm/llvm-project/pull/88097
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Improve source location in binary type traits diagnostics (PR #88097)

2024-04-09 Thread Timm Baeder via cfe-commits

tbaederr wrote:

Do we now have enough information to pass a source range as well?

https://github.com/llvm/llvm-project/pull/88097
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Improve source location in binary type traits diagnostics (PR #88097)

2024-04-09 Thread via cfe-commits

https://github.com/cor3ntin approved this pull request.


https://github.com/llvm/llvm-project/pull/88097
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Improve source location in binary type traits diagnostics (PR #88097)

2024-04-09 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/88097

>From 3bc2d71cbe5e5613b430968fe84023a736072e54 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 9 Apr 2024 10:20:10 +0300
Subject: [PATCH 1/2] [clang] Improve source location in binary type traits
 diagnostics

---
 clang/lib/Sema/SemaExprCXX.cpp | 21 -
 clang/test/SemaCXX/type-traits.cpp |  1 +
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index dee6b658cd0054..7d7be27a862c2a 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -5843,7 +5843,7 @@ static bool EvaluateBinaryTypeTrait(Sema , TypeTrait 
BTT, const TypeSourceI
 return false;
 
   if (Self.RequireCompleteType(
-  KeyLoc, RhsT, diag::err_incomplete_type_used_in_type_trait_expr))
+  Rhs->getTypeLoc().getBeginLoc(), RhsT, 
diag::err_incomplete_type_used_in_type_trait_expr))
 return false;
 
   return BaseInterface->isSuperClassOf(DerivedInterface);
@@ -5866,7 +5866,7 @@ static bool EvaluateBinaryTypeTrait(Sema , TypeTrait 
BTT, const TypeSourceI
 //   If Base and Derived are class types and are different types
 //   (ignoring possible cv-qualifiers) then Derived shall be a
 //   complete type.
-if (Self.RequireCompleteType(KeyLoc, RhsT,
+if (Self.RequireCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT,
   diag::err_incomplete_type_used_in_type_trait_expr))
   return false;
 
@@ -5919,7 +5919,7 @@ static bool EvaluateBinaryTypeTrait(Sema , TypeTrait 
BTT, const TypeSourceI
   return LhsT->isVoidType();
 
 // A function definition requires a complete, non-abstract return type.
-if (!Self.isCompleteType(KeyLoc, RhsT) || Self.isAbstractType(KeyLoc, 
RhsT))
+if (!Self.isCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT) || 
Self.isAbstractType(Rhs->getTypeLoc().getBeginLoc(), RhsT))
   return false;
 
 // Compute the result of add_rvalue_reference.
@@ -5969,11 +5969,11 @@ static bool EvaluateBinaryTypeTrait(Sema , 
TypeTrait BTT, const TypeSourceI
 //   For both, T and U shall be complete types, (possibly cv-qualified)
 //   void, or arrays of unknown bound.
 if (!LhsT->isVoidType() && !LhsT->isIncompleteArrayType() &&
-Self.RequireCompleteType(KeyLoc, LhsT,
+Self.RequireCompleteType(Lhs->getTypeLoc().getBeginLoc(), LhsT,
   diag::err_incomplete_type_used_in_type_trait_expr))
   return false;
 if (!RhsT->isVoidType() && !RhsT->isIncompleteArrayType() &&
-Self.RequireCompleteType(KeyLoc, RhsT,
+Self.RequireCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT,
   diag::err_incomplete_type_used_in_type_trait_expr))
   return false;
 
@@ -6029,12 +6029,15 @@ static bool EvaluateBinaryTypeTrait(Sema , 
TypeTrait BTT, const TypeSourceI
   }
   case BTT_IsLayoutCompatible: {
 if (!LhsT->isVoidType() && !LhsT->isIncompleteArrayType())
-  Self.RequireCompleteType(KeyLoc, LhsT, diag::err_incomplete_type);
+  Self.RequireCompleteType(Lhs->getTypeLoc().getBeginLoc(), LhsT, 
diag::err_incomplete_type);
 if (!RhsT->isVoidType() && !RhsT->isIncompleteArrayType())
-  Self.RequireCompleteType(KeyLoc, RhsT, diag::err_incomplete_type);
+  Self.RequireCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT, 
diag::err_incomplete_type);
 
-if (LhsT->isVariableArrayType() || RhsT->isVariableArrayType())
-  Self.Diag(KeyLoc, diag::err_vla_unsupported)
+if (LhsT->isVariableArrayType())
+  Self.Diag(Lhs->getTypeLoc().getBeginLoc(), diag::err_vla_unsupported)
+  << 1 << tok::kw___is_layout_compatible;
+if (RhsT->isVariableArrayType())
+  Self.Diag(Rhs->getTypeLoc().getBeginLoc(), diag::err_vla_unsupported)
   << 1 << tok::kw___is_layout_compatible;
 return Self.IsLayoutCompatible(LhsT, RhsT);
   }
diff --git a/clang/test/SemaCXX/type-traits.cpp 
b/clang/test/SemaCXX/type-traits.cpp
index e29763714341e7..421d3007d27ffe 100644
--- a/clang/test/SemaCXX/type-traits.cpp
+++ b/clang/test/SemaCXX/type-traits.cpp
@@ -1759,6 +1759,7 @@ void is_layout_compatible(int n)
   // expected-error@-1 {{variable length arrays are not supported in 
'__is_layout_compatible'}}
   static_assert(!__is_layout_compatible(int[n], int[n]));
   // expected-error@-1 {{variable length arrays are not supported in 
'__is_layout_compatible'}}
+  // expected-error@-2 {{variable length arrays are not supported in 
'__is_layout_compatible'}}
   static_assert(__is_layout_compatible(int&, int&));
   static_assert(!__is_layout_compatible(int&, char&));
   static_assert(__is_layout_compatible(void(int), void(int)));

>From 7767807a6eef31010e72a803b171b1d43b44fcca Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 9 Apr 2024 10:32:36 +0300
Subject: [PATCH 2/2] Run clang-format

---
 clang/lib/Sema/SemaExprCXX.cpp | 27 

[clang] [clang] Improve source location in binary type traits diagnostics (PR #88097)

2024-04-09 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff c7db450e5c1a83ea768765dcdedfd50f3358d418 
3bc2d71cbe5e5613b430968fe84023a736072e54 -- clang/lib/Sema/SemaExprCXX.cpp 
clang/test/SemaCXX/type-traits.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 7d7be27a86..ed18c9021e 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -5843,7 +5843,8 @@ static bool EvaluateBinaryTypeTrait(Sema , TypeTrait 
BTT, const TypeSourceI
 return false;
 
   if (Self.RequireCompleteType(
-  Rhs->getTypeLoc().getBeginLoc(), RhsT, 
diag::err_incomplete_type_used_in_type_trait_expr))
+  Rhs->getTypeLoc().getBeginLoc(), RhsT,
+  diag::err_incomplete_type_used_in_type_trait_expr))
 return false;
 
   return BaseInterface->isSuperClassOf(DerivedInterface);
@@ -5866,8 +5867,9 @@ static bool EvaluateBinaryTypeTrait(Sema , TypeTrait 
BTT, const TypeSourceI
 //   If Base and Derived are class types and are different types
 //   (ignoring possible cv-qualifiers) then Derived shall be a
 //   complete type.
-if (Self.RequireCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT,
-  diag::err_incomplete_type_used_in_type_trait_expr))
+if (Self.RequireCompleteType(
+Rhs->getTypeLoc().getBeginLoc(), RhsT,
+diag::err_incomplete_type_used_in_type_trait_expr))
   return false;
 
 return cast(rhsRecord->getDecl())
@@ -5919,7 +5921,8 @@ static bool EvaluateBinaryTypeTrait(Sema , TypeTrait 
BTT, const TypeSourceI
   return LhsT->isVoidType();
 
 // A function definition requires a complete, non-abstract return type.
-if (!Self.isCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT) || 
Self.isAbstractType(Rhs->getTypeLoc().getBeginLoc(), RhsT))
+if (!Self.isCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT) ||
+Self.isAbstractType(Rhs->getTypeLoc().getBeginLoc(), RhsT))
   return false;
 
 // Compute the result of add_rvalue_reference.
@@ -5969,12 +5972,14 @@ static bool EvaluateBinaryTypeTrait(Sema , 
TypeTrait BTT, const TypeSourceI
 //   For both, T and U shall be complete types, (possibly cv-qualified)
 //   void, or arrays of unknown bound.
 if (!LhsT->isVoidType() && !LhsT->isIncompleteArrayType() &&
-Self.RequireCompleteType(Lhs->getTypeLoc().getBeginLoc(), LhsT,
-  diag::err_incomplete_type_used_in_type_trait_expr))
+Self.RequireCompleteType(
+Lhs->getTypeLoc().getBeginLoc(), LhsT,
+diag::err_incomplete_type_used_in_type_trait_expr))
   return false;
 if (!RhsT->isVoidType() && !RhsT->isIncompleteArrayType() &&
-Self.RequireCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT,
-  diag::err_incomplete_type_used_in_type_trait_expr))
+Self.RequireCompleteType(
+Rhs->getTypeLoc().getBeginLoc(), RhsT,
+diag::err_incomplete_type_used_in_type_trait_expr))
   return false;
 
 // cv void is never assignable.
@@ -6029,9 +6034,11 @@ static bool EvaluateBinaryTypeTrait(Sema , 
TypeTrait BTT, const TypeSourceI
   }
   case BTT_IsLayoutCompatible: {
 if (!LhsT->isVoidType() && !LhsT->isIncompleteArrayType())
-  Self.RequireCompleteType(Lhs->getTypeLoc().getBeginLoc(), LhsT, 
diag::err_incomplete_type);
+  Self.RequireCompleteType(Lhs->getTypeLoc().getBeginLoc(), LhsT,
+   diag::err_incomplete_type);
 if (!RhsT->isVoidType() && !RhsT->isIncompleteArrayType())
-  Self.RequireCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT, 
diag::err_incomplete_type);
+  Self.RequireCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT,
+   diag::err_incomplete_type);
 
 if (LhsT->isVariableArrayType())
   Self.Diag(Lhs->getTypeLoc().getBeginLoc(), diag::err_vla_unsupported)

``




https://github.com/llvm/llvm-project/pull/88097
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Improve source location in binary type traits diagnostics (PR #88097)

2024-04-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Vlad Serebrennikov (Endilll)


Changes

This patch takes advantage of a recent NFC change that refactored 
`EvaluateBinaryTypeTrait()` to accept `TypeSourceInfo` instead of `QualType` 
c7db450e5c1a83ea768765dcdedfd50f3358d418.
Before:
```
test2.cpp:105:55: error: variable length arrays are not supported in 
'__is_layout_compatible'
  105 |   static_assert(!__is_layout_compatible(int[n], int[n]));
  |   ^
test2.cpp:125:76: error: incomplete type 'CStructIncomplete' where a complete 
type is required
  125 |   static_assert(__is_layout_compatible(CStructIncomplete, 
CStructIncomplete));
  | 
   ^
``` 
After:
```
test2.cpp:105:41: error: variable length arrays are not supported in 
'__is_layout_compatible'
  105 |   static_assert(!__is_layout_compatible(int[n], int[n]));
  | ^
test2.cpp:125:40: error: incomplete type 'CStructIncomplete' where a complete 
type is required
  125 |   static_assert(__is_layout_compatible(CStructIncomplete, 
CStructIncomplete));
  |^
```

---
Full diff: https://github.com/llvm/llvm-project/pull/88097.diff


2 Files Affected:

- (modified) clang/lib/Sema/SemaExprCXX.cpp (+12-9) 
- (modified) clang/test/SemaCXX/type-traits.cpp (+1) 


``diff
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index dee6b658cd0054..7d7be27a862c2a 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -5843,7 +5843,7 @@ static bool EvaluateBinaryTypeTrait(Sema , TypeTrait 
BTT, const TypeSourceI
 return false;
 
   if (Self.RequireCompleteType(
-  KeyLoc, RhsT, diag::err_incomplete_type_used_in_type_trait_expr))
+  Rhs->getTypeLoc().getBeginLoc(), RhsT, 
diag::err_incomplete_type_used_in_type_trait_expr))
 return false;
 
   return BaseInterface->isSuperClassOf(DerivedInterface);
@@ -5866,7 +5866,7 @@ static bool EvaluateBinaryTypeTrait(Sema , TypeTrait 
BTT, const TypeSourceI
 //   If Base and Derived are class types and are different types
 //   (ignoring possible cv-qualifiers) then Derived shall be a
 //   complete type.
-if (Self.RequireCompleteType(KeyLoc, RhsT,
+if (Self.RequireCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT,
   diag::err_incomplete_type_used_in_type_trait_expr))
   return false;
 
@@ -5919,7 +5919,7 @@ static bool EvaluateBinaryTypeTrait(Sema , TypeTrait 
BTT, const TypeSourceI
   return LhsT->isVoidType();
 
 // A function definition requires a complete, non-abstract return type.
-if (!Self.isCompleteType(KeyLoc, RhsT) || Self.isAbstractType(KeyLoc, 
RhsT))
+if (!Self.isCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT) || 
Self.isAbstractType(Rhs->getTypeLoc().getBeginLoc(), RhsT))
   return false;
 
 // Compute the result of add_rvalue_reference.
@@ -5969,11 +5969,11 @@ static bool EvaluateBinaryTypeTrait(Sema , 
TypeTrait BTT, const TypeSourceI
 //   For both, T and U shall be complete types, (possibly cv-qualified)
 //   void, or arrays of unknown bound.
 if (!LhsT->isVoidType() && !LhsT->isIncompleteArrayType() &&
-Self.RequireCompleteType(KeyLoc, LhsT,
+Self.RequireCompleteType(Lhs->getTypeLoc().getBeginLoc(), LhsT,
   diag::err_incomplete_type_used_in_type_trait_expr))
   return false;
 if (!RhsT->isVoidType() && !RhsT->isIncompleteArrayType() &&
-Self.RequireCompleteType(KeyLoc, RhsT,
+Self.RequireCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT,
   diag::err_incomplete_type_used_in_type_trait_expr))
   return false;
 
@@ -6029,12 +6029,15 @@ static bool EvaluateBinaryTypeTrait(Sema , 
TypeTrait BTT, const TypeSourceI
   }
   case BTT_IsLayoutCompatible: {
 if (!LhsT->isVoidType() && !LhsT->isIncompleteArrayType())
-  Self.RequireCompleteType(KeyLoc, LhsT, diag::err_incomplete_type);
+  Self.RequireCompleteType(Lhs->getTypeLoc().getBeginLoc(), LhsT, 
diag::err_incomplete_type);
 if (!RhsT->isVoidType() && !RhsT->isIncompleteArrayType())
-  Self.RequireCompleteType(KeyLoc, RhsT, diag::err_incomplete_type);
+  Self.RequireCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT, 
diag::err_incomplete_type);
 
-if (LhsT->isVariableArrayType() || RhsT->isVariableArrayType())
-  Self.Diag(KeyLoc, diag::err_vla_unsupported)
+if (LhsT->isVariableArrayType())
+  Self.Diag(Lhs->getTypeLoc().getBeginLoc(), diag::err_vla_unsupported)
+  << 1 << tok::kw___is_layout_compatible;
+if (RhsT->isVariableArrayType())
+  Self.Diag(Rhs->getTypeLoc().getBeginLoc(), diag::err_vla_unsupported)
   << 1 << tok::kw___is_layout_compatible;
 return Self.IsLayoutCompatible(LhsT, RhsT);
   }
diff --git 

[clang] [clang] Improve source location in binary type traits diagnostics (PR #88097)

2024-04-09 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/88097

This patch takes advantage of a recent NFC change that refactored 
`EvaluateBinaryTypeTrait()` to accept `TypeSourceInfo` instead of `QualType` 
c7db450e5c1a83ea768765dcdedfd50f3358d418.
Before:
```
test2.cpp:105:55: error: variable length arrays are not supported in 
'__is_layout_compatible'
  105 |   static_assert(!__is_layout_compatible(int[n], int[n]));
  |   ^
test2.cpp:125:76: error: incomplete type 'CStructIncomplete' where a complete 
type is required
  125 |   static_assert(__is_layout_compatible(CStructIncomplete, 
CStructIncomplete));
  | 
   ^
``` 
After:
```
test2.cpp:105:41: error: variable length arrays are not supported in 
'__is_layout_compatible'
  105 |   static_assert(!__is_layout_compatible(int[n], int[n]));
  | ^
test2.cpp:125:40: error: incomplete type 'CStructIncomplete' where a complete 
type is required
  125 |   static_assert(__is_layout_compatible(CStructIncomplete, 
CStructIncomplete));
  |^
```

>From 3bc2d71cbe5e5613b430968fe84023a736072e54 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 9 Apr 2024 10:20:10 +0300
Subject: [PATCH] [clang] Improve source location in binary type traits
 diagnostics

---
 clang/lib/Sema/SemaExprCXX.cpp | 21 -
 clang/test/SemaCXX/type-traits.cpp |  1 +
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index dee6b658cd0054..7d7be27a862c2a 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -5843,7 +5843,7 @@ static bool EvaluateBinaryTypeTrait(Sema , TypeTrait 
BTT, const TypeSourceI
 return false;
 
   if (Self.RequireCompleteType(
-  KeyLoc, RhsT, diag::err_incomplete_type_used_in_type_trait_expr))
+  Rhs->getTypeLoc().getBeginLoc(), RhsT, 
diag::err_incomplete_type_used_in_type_trait_expr))
 return false;
 
   return BaseInterface->isSuperClassOf(DerivedInterface);
@@ -5866,7 +5866,7 @@ static bool EvaluateBinaryTypeTrait(Sema , TypeTrait 
BTT, const TypeSourceI
 //   If Base and Derived are class types and are different types
 //   (ignoring possible cv-qualifiers) then Derived shall be a
 //   complete type.
-if (Self.RequireCompleteType(KeyLoc, RhsT,
+if (Self.RequireCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT,
   diag::err_incomplete_type_used_in_type_trait_expr))
   return false;
 
@@ -5919,7 +5919,7 @@ static bool EvaluateBinaryTypeTrait(Sema , TypeTrait 
BTT, const TypeSourceI
   return LhsT->isVoidType();
 
 // A function definition requires a complete, non-abstract return type.
-if (!Self.isCompleteType(KeyLoc, RhsT) || Self.isAbstractType(KeyLoc, 
RhsT))
+if (!Self.isCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT) || 
Self.isAbstractType(Rhs->getTypeLoc().getBeginLoc(), RhsT))
   return false;
 
 // Compute the result of add_rvalue_reference.
@@ -5969,11 +5969,11 @@ static bool EvaluateBinaryTypeTrait(Sema , 
TypeTrait BTT, const TypeSourceI
 //   For both, T and U shall be complete types, (possibly cv-qualified)
 //   void, or arrays of unknown bound.
 if (!LhsT->isVoidType() && !LhsT->isIncompleteArrayType() &&
-Self.RequireCompleteType(KeyLoc, LhsT,
+Self.RequireCompleteType(Lhs->getTypeLoc().getBeginLoc(), LhsT,
   diag::err_incomplete_type_used_in_type_trait_expr))
   return false;
 if (!RhsT->isVoidType() && !RhsT->isIncompleteArrayType() &&
-Self.RequireCompleteType(KeyLoc, RhsT,
+Self.RequireCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT,
   diag::err_incomplete_type_used_in_type_trait_expr))
   return false;
 
@@ -6029,12 +6029,15 @@ static bool EvaluateBinaryTypeTrait(Sema , 
TypeTrait BTT, const TypeSourceI
   }
   case BTT_IsLayoutCompatible: {
 if (!LhsT->isVoidType() && !LhsT->isIncompleteArrayType())
-  Self.RequireCompleteType(KeyLoc, LhsT, diag::err_incomplete_type);
+  Self.RequireCompleteType(Lhs->getTypeLoc().getBeginLoc(), LhsT, 
diag::err_incomplete_type);
 if (!RhsT->isVoidType() && !RhsT->isIncompleteArrayType())
-  Self.RequireCompleteType(KeyLoc, RhsT, diag::err_incomplete_type);
+  Self.RequireCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT, 
diag::err_incomplete_type);
 
-if (LhsT->isVariableArrayType() || RhsT->isVariableArrayType())
-  Self.Diag(KeyLoc, diag::err_vla_unsupported)
+if (LhsT->isVariableArrayType())
+  Self.Diag(Lhs->getTypeLoc().getBeginLoc(), diag::err_vla_unsupported)
+  << 1 << tok::kw___is_layout_compatible;
+if (RhsT->isVariableArrayType())
+