[clang] [Clang][Sema] Treat explicit specializations of static data member templates declared without 'static' as static data members when diagnosing uses of 'auto' (PR #97425)

2024-07-03 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian closed 
https://github.com/llvm/llvm-project/pull/97425
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] Treat explicit specializations of static data member templates declared without 'static' as static data members when diagnosing uses of 'auto' (PR #97425)

2024-07-03 Thread Alexander Kornienko via cfe-commits

https://github.com/alexfh approved this pull request.


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


[clang] [Clang][Sema] Treat explicit specializations of static data member templates declared without 'static' as static data members when diagnosing uses of 'auto' (PR #97425)

2024-07-02 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov approved this pull request.


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


[clang] [Clang][Sema] Treat explicit specializations of static data member templates declared without 'static' as static data members when diagnosing uses of 'auto' (PR #97425)

2024-07-02 Thread Richard Smith via cfe-commits

https://github.com/zygoloid approved this pull request.


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


[clang] [Clang][Sema] Treat explicit specializations of static data member templates declared without 'static' as static data members when diagnosing uses of 'auto' (PR #97425)

2024-07-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Krystian Stasiowski (sdkrystian)


Changes

After #93873 clang no longer permits declarations of explicit 
specializations of static data member templates to use the `auto` 
_placeholder-type-specifier_:
```cpp
struct A {
  template
  static constexpr auto x = 0;

  template<>
  constexpr auto x<1> = 1; // error: 'auto' not allowed in non-static 
struct member
};
```
This patch fixes the issue.

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


2 Files Affected:

- (modified) clang/lib/Sema/SemaType.cpp (+1-2) 
- (added) clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5-cxx14.cpp 
(+12) 


``diff
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 50c15a1aa89e8..066003c47eb43 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -3194,8 +3194,7 @@ static QualType 
GetDeclSpecTypeForDeclarator(TypeProcessingState &state,
   break;
 }
 case DeclaratorContext::Member: {
-  if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_static ||
-  D.isFunctionDeclarator())
+  if (D.isStaticMember() || D.isFunctionDeclarator())
 break;
   bool Cxx = SemaRef.getLangOpts().CPlusPlus;
   if (isa(SemaRef.CurContext)) {
diff --git 
a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5-cxx14.cpp 
b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5-cxx14.cpp
new file mode 100644
index 0..8f3dac2426a30
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5-cxx14.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14
+
+struct A {
+  template
+  static constexpr auto x = N;
+
+  template<>
+  constexpr auto x<1> = 1;
+
+  template<>
+  static constexpr auto x<2> = 2; // expected-warning{{explicit specialization 
cannot have a storage class}}
+};

``




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


[clang] [Clang][Sema] Treat explicit specializations of static data member templates declared without 'static' as static data members when diagnosing uses of 'auto' (PR #97425)

2024-07-02 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian created 
https://github.com/llvm/llvm-project/pull/97425

After #93873 clang no longer permits declarations of explicit specializations 
of static data member templates to use the `auto` _placeholder-type-specifier_:
```cpp
struct A {
  template
  static constexpr auto x = 0;

  template<>
  constexpr auto x<1> = 1; // error: 'auto' not allowed in non-static struct 
member
};
```
This patch fixes the issue.

>From 57f2befbeb8b4d0e62903644e76b955384f73913 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Tue, 2 Jul 2024 11:18:17 -0400
Subject: [PATCH] [Clang][Sema] Treat explicit specializations of static data
 member templates declared without 'static' as static data members when
 diagnosing uses of 'auto'

---
 clang/lib/Sema/SemaType.cpp  |  3 +--
 .../dcl.spec/dcl.type/dcl.spec.auto/p5-cxx14.cpp | 12 
 2 files changed, 13 insertions(+), 2 deletions(-)
 create mode 100644 
clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5-cxx14.cpp

diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 50c15a1aa89e8..066003c47eb43 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -3194,8 +3194,7 @@ static QualType 
GetDeclSpecTypeForDeclarator(TypeProcessingState &state,
   break;
 }
 case DeclaratorContext::Member: {
-  if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_static ||
-  D.isFunctionDeclarator())
+  if (D.isStaticMember() || D.isFunctionDeclarator())
 break;
   bool Cxx = SemaRef.getLangOpts().CPlusPlus;
   if (isa(SemaRef.CurContext)) {
diff --git 
a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5-cxx14.cpp 
b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5-cxx14.cpp
new file mode 100644
index 0..8f3dac2426a30
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5-cxx14.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14
+
+struct A {
+  template
+  static constexpr auto x = N;
+
+  template<>
+  constexpr auto x<1> = 1;
+
+  template<>
+  static constexpr auto x<2> = 2; // expected-warning{{explicit specialization 
cannot have a storage class}}
+};

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits