[clang] 0daca80 - Fix issues with WG14 N3344 changes

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 8 04:46:14 PST 2024


Author: Aaron Ballman
Date: 2024-11-08T07:46:01-05:00
New Revision: 0daca808ce111f21db8c0ee9ea5d2509d6034557

URL: https://github.com/llvm/llvm-project/commit/0daca808ce111f21db8c0ee9ea5d2509d6034557
DIFF: https://github.com/llvm/llvm-project/commit/0daca808ce111f21db8c0ee9ea5d2509d6034557.diff

LOG: Fix issues with WG14 N3344 changes

This amends 24e2e259a06d9aa67dc278ac24dcb98da9dd63f6 with a fix for
'register void *', which is still okay as a function parameter.

Added: 
    

Modified: 
    clang/lib/Sema/SemaDecl.cpp
    clang/test/C/C2y/n3344.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index c9cd81a48fbe51..6b0b4840a1eb2c 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -15021,7 +15021,8 @@ Decl *Sema::ActOnParamDeclarator(Scope *S, Declarator &D,
                                             : diag::warn_deprecated_register)
           << FixItHint::CreateRemoval(DS.getStorageClassSpecLoc());
     } else if (!getLangOpts().CPlusPlus &&
-               DS.getTypeSpecType() == DeclSpec::TST_void) {
+               DS.getTypeSpecType() == DeclSpec::TST_void &&
+               D.getNumTypeObjects() == 0) {
       Diag(DS.getStorageClassSpecLoc(),
            diag::err_invalid_storage_class_in_func_decl)
           << FixItHint::CreateRemoval(DS.getStorageClassSpecLoc());

diff  --git a/clang/test/C/C2y/n3344.c b/clang/test/C/C2y/n3344.c
index b9c291d9f1dfa1..8123bb3ebae854 100644
--- a/clang/test/C/C2y/n3344.c
+++ b/clang/test/C/C2y/n3344.c
@@ -16,6 +16,7 @@
 void baz(volatile void);         // expected-error {{'void' as parameter must not have type qualifiers}}
 void bar(const void);            // expected-error {{'void' as parameter must not have type qualifiers}}
 void foo(register void);         // expected-error {{invalid storage class specifier in function declarator}}
+void foop(void register);        // expected-error {{invalid storage class specifier in function declarator}}
 void quux(static void);          // expected-error {{invalid storage class specifier in function declarator}}
 void quobble(auto void);         // expected-error {{invalid storage class specifier in function declarator}}
 void quubble(extern void);       // expected-error {{invalid storage class specifier in function declarator}}
@@ -28,3 +29,7 @@ void quabble(_Thread_local void); // expected-error {{'_Thread_local' is only al
 #endif
 void bing(void, ...);            // expected-error {{'void' must be the first and only parameter if specified}}
 
+// These declarations are fine.
+void one(register void *);
+void two(void register *);
+void three(register void * (*)[4]);


        


More information about the cfe-commits mailing list