llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> Discard the subexpr. --- Full diff: https://github.com/llvm/llvm-project/pull/105640.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/Compiler.cpp (+1-1) - (modified) clang/test/AST/ByteCode/invalid.cpp (+7-2) ``````````diff diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 10f3222726fd43..9d376641f9c5a3 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -5145,7 +5145,7 @@ bool Compiler<Emitter>::VisitUnaryOperator(const UnaryOperator *E) { // We should already have a pointer when we get here. return this->delegate(SubExpr); case UO_Deref: // *x - if (DiscardResult) + if (DiscardResult || E->getType()->isVoidType()) return this->discard(SubExpr); return this->visit(SubExpr); case UO_Not: // ~x diff --git a/clang/test/AST/ByteCode/invalid.cpp b/clang/test/AST/ByteCode/invalid.cpp index 522ad02f71ce07..3c142481f78119 100644 --- a/clang/test/AST/ByteCode/invalid.cpp +++ b/clang/test/AST/ByteCode/invalid.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fcxx-exceptions -std=c++20 -fexperimental-new-constant-interpreter -verify %s -// RUN: %clang_cc1 -fcxx-exceptions -std=c++20 -verify=ref %s +// RUN: %clang_cc1 -fcxx-exceptions -std=c++20 -fexperimental-new-constant-interpreter -verify=expected,both %s +// RUN: %clang_cc1 -fcxx-exceptions -std=c++20 -verify=ref,both %s namespace Throw { @@ -65,4 +65,9 @@ namespace Casts { // ref-error {{must be initialized by a constant expression}} \ // ref-note {{reinterpret_cast is not allowed}} + void func() { + struct B {}; + B b; + (void)*reinterpret_cast<void*>(&b); // both-error {{indirection not permitted on operand of type 'void *'}} + } } `````````` </details> https://github.com/llvm/llvm-project/pull/105640 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits