[clang] [C] Add diagnostic + attr for unterminated strings (PR #137829)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 29 09:05:05 PDT 2025


================
@@ -4907,6 +4907,20 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo &CI,
   D->addAttr(::new (Context) ModeAttr(Context, CI, Name));
 }
 
+static void handleNonStringAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  // This only applies to fields and variable declarations which have an array
+  // type.
+  QualType QT = cast<ValueDecl>(D)->getType();
+  if (!QT->isArrayType() ||
+      !QT->getBaseElementTypeUnsafe()->isAnyCharacterType()) {
----------------
erichkeane wrote:

Interestingly, GCC allows this in C++ mode (https://godbolt.org/z/o7veGEfs5) and we never do.  Not sure if that is something we need to do in the future.

But that means we don't really have to check now.

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


More information about the cfe-commits mailing list