[clang] [C23] Implement N3018: The constexpr specifier for object definitions (PR #73099)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 22 02:36:08 PST 2023


================
@@ -8605,6 +8620,27 @@ static bool checkForConflictWithNonVisibleExternC(Sema &S, const T *ND,
   return false;
 }
 
+static bool CheckC23ConstexprVarTypeQualifiers(Sema &SemaRef,
+                                            SourceLocation VarLoc, QualType T) {
+  if (const auto *A = SemaRef.Context.getAsArrayType(T)) {
+    T = A->getElementType();
+  }
+
+  if (T->isAtomicType() || T.isVolatileQualified() || T.isRestrictQualified()) {
+    SemaRef.Diag(VarLoc, diag::err_c23_constexpr_invalid_type) << T;
+    return true;
+  }
+
+  if (T->isRecordType()) {
+    RecordDecl *RD = T->getAsRecordDecl();
----------------
tbaederr wrote:

```suggestion
    const RecordDecl *RD = T->getAsRecordDecl();
```

https://github.com/llvm/llvm-project/pull/73099


More information about the cfe-commits mailing list