llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

We need to call FFDiag() to get the usual "invalid subexpression" diagnostic.

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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Interp.cpp (+4-2) 
- (modified) clang/test/Sema/annotate-type.c (+1) 


``````````diff
diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 17cf3ccdeb6a94..d8e9fa838abaa8 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -90,10 +90,12 @@ static bool diagnoseUnknownDecl(InterpState &S, CodePtr 
OpPC,
 
 static void diagnoseNonConstVariable(InterpState &S, CodePtr OpPC,
                                      const ValueDecl *VD) {
-  if (!S.getLangOpts().CPlusPlus)
+  const SourceInfo &Loc = S.Current->getSource(OpPC);
+  if (!S.getLangOpts().CPlusPlus) {
+    S.FFDiag(Loc);
     return;
+  }
 
-  const SourceInfo &Loc = S.Current->getSource(OpPC);
   if (const auto *VarD = dyn_cast<VarDecl>(VD);
       VarD && VarD->getType().isConstQualified() &&
       !VarD->getAnyInitializer()) {
diff --git a/clang/test/Sema/annotate-type.c b/clang/test/Sema/annotate-type.c
index 901cef7ffa8b3a..bf1632d302e554 100644
--- a/clang/test/Sema/annotate-type.c
+++ b/clang/test/Sema/annotate-type.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 %s -fsyntax-only -verify 
-fexperimental-new-constant-interpreter
 
 const char *some_function();
 

``````````

</details>


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

Reply via email to