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

2025-04-30 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/137829 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-04-30 Thread Aaron Ballman via cfe-commits
@@ -5024,3 +5024,9 @@ def OpenACCRoutineDecl :InheritableAttr { void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const; }]; } + +def NonString : InheritableAttr { + let Spellings = [GCC<"nonstring">]; AaronBallman wrote: We don't t

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

2025-04-30 Thread Erich Keane via cfe-commits
@@ -5024,3 +5024,9 @@ def OpenACCRoutineDecl :InheritableAttr { void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const; }]; } + +def NonString : InheritableAttr { + let Spellings = [GCC<"nonstring">]; erichkeane wrote: No interest

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

2025-04-30 Thread Erich Keane via cfe-commits
https://github.com/erichkeane approved this pull request. https://github.com/llvm/llvm-project/pull/137829 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-04-29 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/137829 >From 7ed11d01dfda559f16ee823d6274ada321621466 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Tue, 29 Apr 2025 11:43:53 -0400 Subject: [PATCH 1/4] [C] Add diagnostic + attr for unterminated strings Thi

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

2025-04-29 Thread Erich Keane via cfe-commits
@@ -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 declara

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

2025-04-29 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman updated https://github.com/llvm/llvm-project/pull/137829 >From 7ed11d01dfda559f16ee823d6274ada321621466 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Tue, 29 Apr 2025 11:43:53 -0400 Subject: [PATCH 1/3] [C] Add diagnostic + attr for unterminated strings Thi

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

2025-04-29 Thread Aaron Ballman via cfe-commits
@@ -9294,3 +9294,18 @@ Declares that a function potentially allocates heap memory, and prevents any pot of ``nonallocating`` by the compiler. }]; } + +def NonStringDocs : Documentation { + let Category = DocCatDecl; + let Content = [{ +The ``nonstring`` attribute can be ap

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

2025-04-29 Thread Aaron Ballman via cfe-commits
@@ -3804,6 +3804,9 @@ def err_attribute_weakref_without_alias : Error< "weakref declaration of %0 must also have an alias attribute">; def err_alias_not_supported_on_darwin : Error < "aliases are not supported on darwin">; +def warn_attribute_non_character_array : Warning<

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

2025-04-29 Thread Aaron Ballman via cfe-commits
@@ -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 declara

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

2025-04-29 Thread Erich Keane via cfe-commits
@@ -3804,6 +3804,9 @@ def err_attribute_weakref_without_alias : Error< "weakref declaration of %0 must also have an alias attribute">; def err_alias_not_supported_on_darwin : Error < "aliases are not supported on darwin">; +def warn_attribute_non_character_array : Warning<

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

2025-04-29 Thread Erich Keane via cfe-commits
@@ -9294,3 +9294,18 @@ Declares that a function potentially allocates heap memory, and prevents any pot of ``nonallocating`` by the compiler. }]; } + +def NonStringDocs : Documentation { + let Category = DocCatDecl; + let Content = [{ +The ``nonstring`` attribute can be ap

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

2025-04-29 Thread Erich Keane via cfe-commits
@@ -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 declara

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

2025-04-29 Thread Erich Keane via cfe-commits
@@ -3804,6 +3804,9 @@ def err_attribute_weakref_without_alias : Error< "weakref declaration of %0 must also have an alias attribute">; def err_alias_not_supported_on_darwin : Error < "aliases are not supported on darwin">; +def warn_attribute_non_character_array : Warning<

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

2025-04-29 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Aaron Ballman (AaronBallman) Changes This introduces three things related to intialization like: char buf[3] = "foo"; where the array does not declare enough space for the null terminator but otherwise can represent the array contents ex

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

2025-04-29 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/137829 This introduces three things related to intialization like: char buf[3] = "foo"; where the array does not declare enough space for the null terminator but otherwise can represent the array contents exactl