llvm-project/clang/test/SemaCXX/warn-explicit-specialization-storage-class.cpp
David Blaikie a1bce0b89e
Clang: Add warning flag for storage class specifiers on explicit specializations (#96699)
With the recent fix for this situation in class members (#93873) (for
which the fixed code is invalid prior to this patch - making migrating
code difficult as it must be in lock-step with the compiler migration,
if building with -Werror) it'd be really useful to be able to disable
this warning during the compiler migration/decouple the compiler
migration from the source fixes.

In theory this approach will regress the codebase to the previous
non-member cases of this issue that were already being held back by the
warning (as opposed to if we carved out the new cases into a separate
warning from the existing cases) but I think this'll be so rare and the
cleanup so simple, that the extra regressions of disabling the warning
broadly won't be too much of a problem. (but if folks disagree, I'm open
to making the warning more fine-grained)
2024-06-27 08:17:40 -07:00

19 lines
590 B
C++

// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify %s
// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-explicit-specialization-storage-class -verify=expnone %s
// expnone-no-diagnostics
struct A {
template<typename T>
static constexpr int x = 0;
template<>
static constexpr int x<void> = 1; // expected-warning{{explicit specialization cannot have a storage class}}
};
template<typename T>
static constexpr int x = 0;
template<>
static constexpr int x<void> = 1; // expected-warning{{explicit specialization cannot have a storage class}}