llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> Some of them work just fine, even if the expression contains errors. --- Full diff: https://github.com/llvm/llvm-project/pull/180710.diff 3 Files Affected: - (modified) clang/lib/AST/ByteCode/Compiler.cpp (+6-3) - (modified) clang/test/AST/ByteCode/invalid.cpp (+5) - (modified) clang/test/SemaCXX/alignof-sizeof-reference.cpp (+1) ``````````diff diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 526e1aee9ce3d..7aa7a8d75c8e1 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -2256,9 +2256,6 @@ template <class Emitter> bool Compiler<Emitter>::VisitUnaryExprOrTypeTraitExpr( const UnaryExprOrTypeTraitExpr *E) { - if (E->containsErrors()) - return false; - UnaryExprOrTypeTrait Kind = E->getKind(); const ASTContext &ASTCtx = Ctx.getASTContext(); @@ -2333,6 +2330,9 @@ bool Compiler<Emitter>::VisitUnaryExprOrTypeTraitExpr( // Argument is an expression, not a type. const Expr *Arg = E->getArgumentExpr()->IgnoreParens(); + if (Arg->getType()->isDependentType()) + return false; + // The kinds of expressions that we have special-case logic here for // should be kept up to date with the special checks for those // expressions in Sema. @@ -2356,6 +2356,9 @@ bool Compiler<Emitter>::VisitUnaryExprOrTypeTraitExpr( } if (Kind == UETT_VectorElements) { + if (E->containsErrors()) + return false; + if (const auto *VT = E->getTypeOfArgument()->getAs<VectorType>()) return this->emitConst(VT->getNumElements(), E); assert(E->getTypeOfArgument()->isSizelessVectorType()); diff --git a/clang/test/AST/ByteCode/invalid.cpp b/clang/test/AST/ByteCode/invalid.cpp index 8c641a20a0bd4..20c37893c828b 100644 --- a/clang/test/AST/ByteCode/invalid.cpp +++ b/clang/test/AST/ByteCode/invalid.cpp @@ -170,3 +170,8 @@ constexpr int invalidUnaryOrTypeTrait() { } static_assert(invalidUnaryOrTypeTrait() == 11, ""); // both-error {{not an integral constant expression}} + +constexpr int invalidUnaryOrTypeTrait2() { + return alignof * 10; // both-error {{indirection requires pointer operand}} \ + // both-warning {{'alignof' applied to an expression is a GNU extension}} +} diff --git a/clang/test/SemaCXX/alignof-sizeof-reference.cpp b/clang/test/SemaCXX/alignof-sizeof-reference.cpp index 3e37d615bbcf5..c5de165d38c77 100644 --- a/clang/test/SemaCXX/alignof-sizeof-reference.cpp +++ b/clang/test/SemaCXX/alignof-sizeof-reference.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -fexperimental-new-constant-interpreter struct s0; // expected-note {{forward declaration}} char ar[sizeof(s0&)]; // expected-error {{invalid application of 'sizeof' to an incomplete type}} `````````` </details> https://github.com/llvm/llvm-project/pull/180710 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
