aboutsummaryrefslogtreecommitdiff
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/AST/Interp/ByteCodeExprGen.cpp3
-rw-r--r--clang/test/AST/Interp/functions.cpp6
2 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 568a929..0a93a6a 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1114,6 +1114,9 @@ bool ByteCodeExprGen<Emitter>::visitArrayElemInit(unsigned ElemIndex,
template <class Emitter>
bool ByteCodeExprGen<Emitter>::VisitInitListExpr(const InitListExpr *E) {
+ if (E->getType()->isVoidType())
+ return this->emitInvalid(E);
+
// Handle discarding first.
if (DiscardResult) {
for (const Expr *Init : E->inits()) {
diff --git a/clang/test/AST/Interp/functions.cpp b/clang/test/AST/Interp/functions.cpp
index a4ae73e4..a5bb9f1 100644
--- a/clang/test/AST/Interp/functions.cpp
+++ b/clang/test/AST/Interp/functions.cpp
@@ -611,3 +611,9 @@ namespace {
static_assert((g<int>(), true), "");
}
+
+namespace {
+ /// The InitListExpr here is of void type.
+ void bir [[clang::annotate("B", {1, 2, 3, 4})]] (); // both-error {{'annotate' attribute requires parameter 1 to be a constant expression}} \
+ // both-note {{subexpression not valid in a constant expression}}
+}