[clang] cd9a241 - [clang] Fix the incorrect dependence bits for DependentExtIntType.

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 6 07:43:13 PDT 2020


Author: Haojian Wu
Date: 2020-07-06T16:42:56+02:00
New Revision: cd9a241f165013902fc060ace88c66e402c7767a

URL: https://github.com/llvm/llvm-project/commit/cd9a241f165013902fc060ace88c66e402c7767a
DIFF: https://github.com/llvm/llvm-project/commit/cd9a241f165013902fc060ace88c66e402c7767a.diff

LOG: [clang] Fix the incorrect dependence bits for DependentExtIntType.

The error-bit was missing, and the unexpandedpack bit seemed to be
set incorrectly.

Reviewed By: sammccall, erichkeane

Differential Revision: https://reviews.llvm.org/D83114

Added: 
    

Modified: 
    clang/lib/AST/Type.cpp
    clang/test/Sema/invalid-bitwidth-expr.mm

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 05962f34bbf1..10a6a2610130 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -347,15 +347,7 @@ ExtIntType::ExtIntType(bool IsUnsigned, unsigned NumBits)
 DependentExtIntType::DependentExtIntType(const ASTContext &Context,
                                          bool IsUnsigned, Expr *NumBitsExpr)
     : Type(DependentExtInt, QualType{},
-           ((NumBitsExpr->isValueDependent() || NumBitsExpr->isTypeDependent())
-                ? TypeDependence::Dependent
-                : TypeDependence::None) |
-               (NumBitsExpr->isInstantiationDependent()
-                    ? TypeDependence::Instantiation
-                    : TypeDependence::None) |
-               (NumBitsExpr->containsUnexpandedParameterPack()
-                    ? TypeDependence::VariablyModified
-                    : TypeDependence::None)),
+           toTypeDependence(NumBitsExpr->getDependence())),
       Context(Context), ExprAndUnsigned(NumBitsExpr, IsUnsigned) {}
 
 bool DependentExtIntType::isUnsigned() const {

diff  --git a/clang/test/Sema/invalid-bitwidth-expr.mm b/clang/test/Sema/invalid-bitwidth-expr.mm
index a38ebbbd6755..41ca9496de4f 100644
--- a/clang/test/Sema/invalid-bitwidth-expr.mm
+++ b/clang/test/Sema/invalid-bitwidth-expr.mm
@@ -32,3 +32,8 @@ auto func() {
   int X : func<int>(); // expected-note {{in instantiation of function template}}
 };
 constexpr int ssss = sizeof(Z);
+
+struct Z2 {
+  int X : sizeof(_ExtInt(invalid())); // expected-error {{use of undeclared identifier}}
+};
+constexpr int sssss = sizeof(Z2);


        


More information about the cfe-commits mailing list