This also ignores and deprecates the `-fdouble-square-bracket-attributes` command line flag, which seems to not be used anywhere. At least a code search exclusively found mentions of it in documentation: https://sourcegraph.com/search?q=context:global+-fdouble-square-bracket-attributes+-file:clang/*+-file:test/Sema/*+-file:test/Parser/*+-file:test/AST/*+-file:test/Preprocessor/*+-file:test/Misc/*+archived:yes&patternType=standard&sm=0&groupBy=repo
RFC: https://discourse.llvm.org/t/rfc-enable-c-11-c2x-attributes-in-all-standard-modes-as-an-extension-and-remove-fdouble-square-bracket-attributes
This enables `[[]]` attributes in all C and C++ language modes without warning by default. `-Wc++-extensions` does warn. GCC has enabled this extension in all C modes since GCC 10.
Reviewed By: aaron.ballman, MaskRay
Spies: #clang-vendors, beanz, JDevlieghere, Michael137, MaskRay, sstefan1, jplehr, cfe-commits, lldb-commits, dmgreen, jdoerfert, wenlei, wlei
Differential Revision: https://reviews.llvm.org/D151683
Language Extensions Back-ported to Previous Standards
=====================================================
-====================================== ================================ ============= ============= ==================================
-Feature Feature Test Macro Introduced In Backported To Required Flags
-====================================== ================================ ============= ============= ==================================
+====================================== ================================ ============= =============
+Feature Feature Test Macro Introduced In Backported To
+====================================== ================================ ============= =============
variadic templates __cpp_variadic_templates C++11 C++03
Alias templates __cpp_alias_templates C++11 C++03
Non-static data member initializers __cpp_nsdmi C++11 C++03
Range-based ``for`` loop __cpp_range_based_for C++11 C++03
RValue references __cpp_rvalue_references C++11 C++03
-Attributes __cpp_attributes C++11 C++03 -fdouble-square-bracket-attributes
+Attributes __cpp_attributes C++11 C++03
variable templates __cpp_variable_templates C++14 C++03
Binary literals __cpp_binary_literals C++14 C++03
Relaxed constexpr __cpp_constexpr C++14 C++11
``using enum`` __cpp_using_enum C++20 C++03
``if consteval`` __cpp_if_consteval C++23 C++20
``static operator()`` __cpp_static_call_operator C++23 C++03
--------------------------------------- -------------------------------- ------------- ------------- ----------------------------------
+-------------------------------------- -------------------------------- ------------- -------------
Designated initializers (N494) C99 C89
Array & element qualification (N2607) C2x C89
-====================================== ================================ ============= ============= ==================================
+Attributes (N2335) C2x C89
+====================================== ================================ ============= =============
Type Trait Primitives
=====================
Deprecated Compiler Flags
-------------------------
+- ``-fdouble-square-bracket-attributes`` has been deprecated. It is ignored now
+ and will be removed in Clang 18.
+
Modified Compiler Flags
-----------------------
def warn_cxx98_compat_alignas : Warning<"'alignas' is incompatible with C++98">,
InGroup<CXX98Compat>, DefaultIgnore;
def warn_cxx98_compat_attribute : Warning<
- "C++11 attribute syntax is incompatible with C++98">,
+ "[[]] attributes are incompatible with C++ standards before C++11">,
InGroup<CXX98Compat>, DefaultIgnore;
+def warn_ext_cxx11_attributes : Extension<
+ "[[]] attributes are a C++11 extension">,
+ InGroup<CXX11>;
+def warn_pre_c2x_compat_attributes : Warning<
+ "[[]] attributes are incompatible with C standards before C2x">,
+ DefaultIgnore, InGroup<CPre2xCompat>;
+def warn_ext_c2x_attributes : Extension<
+ "[[]] attributes are a C2x extension">,
+ InGroup<C2x>;
def err_cxx11_attribute_forbids_arguments : Error<
"attribute %0 cannot have an argument list">;
def err_attribute_requires_arguments : Error<
EXTENSION(c_generic_selection_with_controlling_type, true)
EXTENSION(c_static_assert, true)
EXTENSION(c_thread_local, PP.getTargetInfo().isTLSSupported())
+// C2x features supported by other languages as extensions
+EXTENSION(c_attributes, true)
// C++11 features supported by other languages as extensions.
EXTENSION(cxx_atomic, LangOpts.CPlusPlus)
EXTENSION(cxx_default_function_template_args, LangOpts.CPlusPlus)
def fasynchronous_unwind_tables : Flag<["-"], "fasynchronous-unwind-tables">, Group<f_Group>;
defm double_square_bracket_attributes : BoolFOption<"double-square-bracket-attributes",
- LangOpts<"DoubleSquareBracketAttributes">, Default<!strconcat(cpp11.KeyPath, "||", c2x.KeyPath)>,
- PosFlag<SetTrue, [], "Enable">, NegFlag<SetFalse, [], "Disable">,
- BothFlags<[NoXarchOption, CC1Option], " '[[]]' attributes in all C and C++ language modes">>;
+ LangOpts<"DoubleSquareBracketAttributes">, DefaultTrue, PosFlag<SetTrue>, NegFlag<SetFalse>>;
defm autolink : BoolFOption<"autolink",
CodeGenOpts<"Autolink">, DefaultTrue,
private:
void ParseBlockId(SourceLocation CaretLoc);
- /// Are [[]] attributes enabled?
- bool standardAttributesAllowed() const {
- const LangOptions &LO = getLangOpts();
- return LO.DoubleSquareBracketAttributes;
- }
-
/// Return true if the next token should be treated as a [[]] attribute,
/// or as a keyword that behaves like one. The former is only true if
/// [[]] attributes are enabled, whereas the latter is true whenever
bool isAllowedCXX11AttributeSpecifier(bool Disambiguate = false,
bool OuterMightBeMessageSend = false) {
return (Tok.isRegularKeywordAttribute() ||
- (standardAttributesAllowed() &&
- isCXX11AttributeSpecifier(Disambiguate, OuterMightBeMessageSend)));
+ isCXX11AttributeSpecifier(Disambiguate, OuterMightBeMessageSend));
}
// Check for the start of an attribute-specifier-seq in a context where an
// attribute is not allowed.
bool CheckProhibitedCXX11Attribute() {
assert(Tok.is(tok::l_square));
- if (!standardAttributesAllowed() || NextToken().isNot(tok::l_square))
+ if (NextToken().isNot(tok::l_square))
return false;
return DiagnoseProhibitedCXX11Attribute();
}
bool DiagnoseProhibitedCXX11Attribute();
void CheckMisplacedCXX11Attribute(ParsedAttributes &Attrs,
SourceLocation CorrectLocation) {
- if (!Tok.isRegularKeywordAttribute()) {
- if (!standardAttributesAllowed())
- return;
- if ((Tok.isNot(tok::l_square) || NextToken().isNot(tok::l_square)) &&
- Tok.isNot(tok::kw_alignas))
- return;
- }
+ if (!Tok.isRegularKeywordAttribute() &&
+ (Tok.isNot(tok::l_square) || NextToken().isNot(tok::l_square)) &&
+ Tok.isNot(tok::kw_alignas))
+ return;
DiagnoseMisplacedCXX11Attribute(Attrs, CorrectLocation);
}
void DiagnoseMisplacedCXX11Attribute(ParsedAttributes &Attrs,
// attributes. We support those, but not through the typical attribute
// machinery that goes through TableGen. We support this in all OpenMP modes
// so long as double square brackets are enabled.
- if (LangOpts.OpenMP && LangOpts.DoubleSquareBracketAttributes &&
- ScopeName == "omp")
+ if (LangOpts.OpenMP && ScopeName == "omp")
return (Name == "directive" || Name == "sequence") ? 1 : 0;
int res = hasAttributeImpl(Syntax, Name, ScopeName, Target, LangOpts);
if (LangOpts.Digraphs && Char == '>') {
Kind = tok::r_square; // ':>' -> ']'
CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
- } else if ((LangOpts.CPlusPlus ||
- LangOpts.DoubleSquareBracketAttributes) &&
- Char == ':') {
+ } else if (Char == ':') {
Kind = tok::coloncolon;
CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
} else {
Result.setLiteralData(TokPtr);
return true;
}
- if (Result.is(tok::colon) &&
- (LangOpts.CPlusPlus || LangOpts.DoubleSquareBracketAttributes)) {
+ if (Result.is(tok::colon)) {
// Convert consecutive colons to 'tok::coloncolon'.
if (*BufferPtr == ':') {
assert(DepDirectives.front().Tokens[NextDepDirectiveTokenIndex].is(
"Not a double square bracket attribute list");
SourceLocation OpenLoc = Tok.getLocation();
- Diag(OpenLoc, diag::warn_cxx98_compat_attribute);
+ if (getLangOpts().CPlusPlus) {
+ Diag(OpenLoc, getLangOpts().CPlusPlus11 ? diag::warn_cxx98_compat_attribute
+ : diag::warn_ext_cxx11_attributes);
+ } else {
+ Diag(OpenLoc, getLangOpts().C2x ? diag::warn_pre_c2x_compat_attributes
+ : diag::warn_ext_c2x_attributes);
+ }
ConsumeBracket();
checkCompoundToken(OpenLoc, tok::l_square, CompoundToken::AttrBegin);
/// attribute-specifier-seq:
/// attribute-specifier-seq[opt] attribute-specifier
void Parser::ParseCXX11Attributes(ParsedAttributes &Attrs) {
- assert(standardAttributesAllowed() || Tok.isRegularKeywordAttribute());
-
SourceLocation StartLoc = Tok.getLocation();
SourceLocation EndLoc = StartLoc;
// Test without serialization:
-// RUN: %clang_cc1 -fdouble-square-bracket-attributes -triple x86_64-apple-macosx10.10.0 \
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10.0 \
// RUN: -ast-dump -ast-dump-filter Test %s \
// RUN: | FileCheck --strict-whitespace %s
//
// Test with serialization:
-// RUN: %clang_cc1 -fdouble-square-bracket-attributes -triple x86_64-apple-macosx10.10.0 \
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10.0 \
// RUN: -emit-pch -o %t %s
-// RUN: %clang_cc1 -x objective-c -fdouble-square-bracket-attributes -triple x86_64-apple-macosx10.10.0 \
+// RUN: %clang_cc1 -x objective-c -triple x86_64-apple-macosx10.10.0 \
// RUN: -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \
// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
// RUN: | FileCheck --strict-whitespace %s
// Test without serialization:
-// RUN: %clang_cc1 -triple x86_64-pc-linux -fdouble-square-bracket-attributes \
+// RUN: %clang_cc1 -triple x86_64-pc-linux \
// RUN: -Wno-deprecated-declarations -ast-dump -ast-dump-filter Test %s \
// RUN: | FileCheck --strict-whitespace %s
//
// Test with serialization:
-// RUN: %clang_cc1 -triple x86_64-pc-linux -fdouble-square-bracket-attributes \
+// RUN: %clang_cc1 -triple x86_64-pc-linux \
// RUN: -Wno-deprecated-declarations -emit-pch -o %t %s
-// RUN: %clang_cc1 -x c -triple x86_64-pc-linux -fdouble-square-bracket-attributes \
+// RUN: %clang_cc1 -x c -triple x86_64-pc-linux \
// RUN: -Wno-deprecated-declarations -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \
// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
// RUN: | FileCheck --strict-whitespace %s
-// RUN: %clang_cc1 %s -ast-dump -fdouble-square-bracket-attributes | FileCheck %s
+// RUN: %clang_cc1 %s -ast-dump | FileCheck %s
// Verify that we print the [[clang::annotate_type]] attribute.
// FIXME: The arguments are currently not printed -- see also comments in
// RUN: %clang_cc1 -triple %itanium_abi_triple -debug-info-kind=limited -S -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple %itanium_abi_triple -DDOUBLE_BRACKET_ATTRS=1 -fdouble-square-bracket-attributes -debug-info-kind=limited -S -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -DDOUBLE_BRACKET_ATTRS=1 -debug-info-kind=limited -S -emit-llvm -o - %s | FileCheck %s
#if DOUBLE_BRACKET_ATTRS
#define __tag1 [[clang::btf_type_tag("tag1")]]
// RUN: %clang_cc1 -triple %itanium_abi_triple -debug-info-kind=limited -S -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple %itanium_abi_triple -DDOUBLE_BRACKET_ATTRS=1 -fdouble-square-bracket-attributes -debug-info-kind=limited -S -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -DDOUBLE_BRACKET_ATTRS=1 -debug-info-kind=limited -S -emit-llvm -o - %s | FileCheck %s
#if DOUBLE_BRACKET_ATTRS
#define __tag1 [[clang::btf_type_tag("tag1")]]
-// RUN: %clang_cc1 -Wno-unused-value -fdouble-square-bracket-attributes -verify %s
+// RUN: %clang_cc1 -Wno-unused-value -verify %s
#define NODEREF __attribute__((noderef))
-// RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp -std=c99 -fms-extensions -fdouble-square-bracket-attributes -Wno-pragma-pack %s
-// RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp-simd -std=c99 -fms-extensions -fdouble-square-bracket-attributes -Wno-pragma-pack %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp -std=c99 -fms-extensions -Wno-pragma-pack %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp-simd -std=c99 -fms-extensions -Wno-pragma-pack %s
[[omp::directive(assumes)]]; // expected-error {{expected at least one 'ext_', 'absent', 'contains', 'holds', 'no_openmp', 'no_openmp_routines', 'no_parallelism' clause for '#pragma omp assumes'}}
[[omp::directive(begin)]]; // expected-error {{expected an OpenMP directive}}
// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -fsyntax-only -verify=off -Wno-openmp %s
// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -fsyntax-only -verify=off -Wno-openmp-51-extensions %s
-// RUN: %clang_cc1 -fopenmp -fsyntax-only -verify=pre -Wpre-openmp-51-compat -x c -fdouble-square-bracket-attributes %s
-// RUN: %clang_cc1 -fopenmp -fsyntax-only -verify=off -x c -std=c2x %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -fsyntax-only -verify=ext -Wopenmp -x c -std=c2x %s
+// RUN: %clang_cc1 -fopenmp -fsyntax-only -verify=pre -Wpre-openmp-51-compat -x c -std=c2x %s
+// RUN-: %clang_cc1 -fopenmp -fsyntax-only -verify=off -x c -std=c2x %s
+// RUN-: %clang_cc1 -fopenmp -fopenmp-version=50 -fsyntax-only -verify=ext -Wopenmp -x c -std=c2x %s
// off-no-diagnostics
int x;
[[omp::directive(threadprivate(x))]]; // pre-warning {{specifying OpenMP directives with [[]] is incompatible with OpenMP standards before OpenMP 5.1}} \
// ext-warning {{specifying OpenMP directives with [[]] is an OpenMP 5.1 extension}}
-
-// RUN: %clang_cc1 -fsyntax-only -fdouble-square-bracket-attributes -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
#if !__has_extension(gnu_asm)
#error Extension 'gnu_asm' should be available by default
-// RUN: %clang_cc1 -fsyntax-only -fdouble-square-bracket-attributes -verify=expected,notc2x -Wno-strict-prototypes %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,notc2x -Wno-strict-prototypes %s
// RUN: %clang_cc1 -fsyntax-only -std=gnu2x -verify=expected,c2x %s
enum [[]] E {
-// RUN: %clang_cc1 -fsyntax-only -fdouble-square-bracket-attributes -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-no-diagnostics
enum __attribute__((deprecated)) E1 : int; // ok
}
// Ensure we produce at least some diagnostic for attributes in C++98.
-[[]] struct S;
-#if __cplusplus <= 199711L
-// expected-error@-2 {{expected expression}}
-// expected-error@-3 {{expected unqualified-id}}
-#else
-// expected-error@-5 {{misplaced attributes}}
+[[]] struct S; // expected-error {{misplaced attributes}}
+#if __cplusplus < 201103L
+// expected-error@-2 {{[[]] attributes are a C++11 extension}}
#endif
namespace test7 {
-// RUN: %clang_cc1 -fsyntax-only -fdouble-square-bracket-attributes -triple x86_64-apple-macosx10.10.0 -verify %s\r
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.10.0 -verify %s\r
// expected-no-diagnostics\r
\r
@interface NSObject\r
// expected-warning@+1 {{'auto' type specifier is a C++11 extension}}
auto l = []() groupshared {};
-
-// NOTE: remove this error once [[]] attribute is supported except for hlsl202x.
-// expected-error@+1 {{expected expression}}
float groupshared [[]] i = 12;
float groupshared const i2 = 12;
-// RUN: %clang_cc1 -fdouble-square-bracket-attributes -std=c11 -E -P %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c11 -E -P %s -o - | FileCheck %s
// RUN: %clang_cc1 -std=c2x -E -P %s -o - | FileCheck %s
#define C2x(x) x: __has_c_attribute(x)
-// RUN: %clang_cc1 %s -fsyntax-only -fdouble-square-bracket-attributes -verify
+// RUN: %clang_cc1 %s -fsyntax-only -verify
const char *some_function();
-// RUN: %clang_cc1 %s -fsyntax-only -fdouble-square-bracket-attributes -verify
+// RUN: %clang_cc1 %s -fsyntax-only -verify
void __attribute__((annotate("foo"))) foo(float *a) {
__attribute__((annotate("bar"))) int x;
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -fdouble-square-bracket-attributes -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -verify %s
[[clang::availability(macosx,introduced=10.4,deprecated=10.2)]] void f0(void); // expected-warning{{feature cannot be deprecated in macOS version 10.2 before it was introduced in version 10.4; attribute ignored}}
[[clang::availability(ios,obsoleted=2.1,deprecated=3.0)]] void f1(void); // expected-warning{{feature cannot be obsoleted in iOS version 2.1 before it was deprecated in version 3.0; attribute ignored}}
-// RUN: %clang_cc1 -fsyntax-only -fblocks -verify -fdouble-square-bracket-attributes %s
+// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
template<class T>
class Class {
-// RUN: %clang_cc1 -fsyntax-only -fblocks -verify -fdouble-square-bracket-attributes %s
+// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
void threeClauses(void) __attribute__((external_source_symbol(language="Swift", defined_in="module", generated_declaration)));
-// RUN: %clang_cc1 %s -fsyntax-only -fdouble-square-bracket-attributes -verify
+// RUN: %clang_cc1 %s -fsyntax-only -verify
void g(void) {
if (1)
-// RUN: %clang_cc1 -verify -fsyntax-only -fdouble-square-bracket-attributes %s
+// RUN: %clang_cc1 -verify -fsyntax-only %s
struct [[clang::objc_bridge_related(NSParagraphStyle,,)]] TestBridgedRef;
-// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -fdouble-square-bracket-attributes -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
__attribute((regparm(2))) int x0(void);
__attribute((regparm(1.0))) int x1(void); // expected-error{{'regparm' attribute requires an integer constant}}
-// RUN: %clang_cc1 -fsyntax-only -fdouble-square-bracket-attributes -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
struct A {};
--- /dev/null
+// RUN: %clang_cc1 -fsyntax-only -std=c2x -Wpre-c2x-compat -verify=pre-c2x %s
+// RUN: %clang_cc1 -fsyntax-only -std=c17 -Wc2x-extensions -verify=c2x-ext %s
+
+[[]] void func(); // pre-c2x-warning {{[[]] attributes are incompatible with C standards before C2x}}
+ // c2x-ext-warning@-1 {{[[]] attributes are a C2x extension}}
// RUN: %clang_cc1 -verify=all,c2x -std=c2x -fsyntax-only %s
-// RUN: %clang_cc1 -verify=all -std=c17 -fdouble-square-bracket-attributes -fsyntax-only %s
+// RUN: %clang_cc1 -verify=all -std=c17 -fsyntax-only %s
// RUN: %clang_cc1 -verify=none -Wno-deprecated-attributes -D_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS -std=c2x -fsyntax-only %s
-// RUN: %clang_cc1 -verify=none -Wno-deprecated-attributes -D_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS -std=c17 -fdouble-square-bracket-attributes -fsyntax-only %s
+// RUN: %clang_cc1 -verify=none -Wno-deprecated-attributes -D_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS -std=c17 -fsyntax-only %s
// none-no-diagnostics
// Test preprocessor functionality.
-// RUN: %clang_cc1 -fsyntax-only -verify -fdouble-square-bracket-attributes %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
int var __attribute__((internal_linkage));
int var2 __attribute__((internal_linkage,common)); // expected-error{{'common' and 'internal_linkage' attributes are not compatible}} \
-// RUN: %clang_cc1 %s -fenable-matrix -fdouble-square-bracket-attributes -pedantic -verify -triple=x86_64-apple-darwin9
+// RUN: %clang_cc1 %s -fenable-matrix -pedantic -verify -triple=x86_64-apple-darwin9
typedef float sx5x10_t __attribute__((matrix_type(5, 10)));
typedef int ix3x2_t __attribute__((matrix_type(3, 2)));
// Verify that we can use the [[]] spelling of the attribute.
// We intentionally use the same type alias name to check that both versions
// define the same type.
-typedef float [[clang::matrix_type(5, 10)]] sx5x10_t;
-typedef int [[clang::matrix_type(3, 2)]] ix3x2_t;
-[[clang::matrix_type(5, 10)]] typedef float sx5x10_t;
+typedef float [[clang::matrix_type(5, 10)]] sx5x10_t; // expected-warning {{[[]] attributes are a C2x extension}}
+typedef int [[clang::matrix_type(3, 2)]] ix3x2_t; // expected-warning {{[[]] attributes are a C2x extension}}
+[[clang::matrix_type(5, 10)]] typedef float sx5x10_t; // expected-warning {{[[]] attributes are a C2x extension}}
// expected-warning@-1 {{applying attribute 'matrix_type' to a declaration is deprecated; apply it to the type instead}}
-[[clang::matrix_type(3, 2)]] typedef int ix3x2_t;
+[[clang::matrix_type(3, 2)]] typedef int ix3x2_t; // expected-warning {{[[]] attributes are a C2x extension}}
// expected-warning@-1 {{applying attribute 'matrix_type' to a declaration is deprecated; apply it to the type instead}}
// Attribute may not be used outside typedefs.
-[[clang::matrix_type(3, 2)]] int ix3x2_var;
+[[clang::matrix_type(3, 2)]] int ix3x2_var; // expected-warning {{[[]] attributes are a C2x extension}}
// expected-error@-1 {{'matrix_type' attribute only applies to typedefs}}
-int [[clang::matrix_type(3, 2)]] ix3x2_var;
+int [[clang::matrix_type(3, 2)]] ix3x2_var; // expected-warning {{[[]] attributes are a C2x extension}}
// expected-error@-1 {{'matrix_type' attribute only applies to typedefs}}
void transpose(sx5x10_t a, ix3x2_t b, dx3x3 c, int *d, int e) {
-// RUN: %clang_cc1 %s -triple armv7 -target-feature +neon -fsyntax-only -fdouble-square-bracket-attributes -verify
-// RUN: %clang_cc1 %s -triple armv8 -target-feature +neon -fsyntax-only -fdouble-square-bracket-attributes -verify
+// RUN: %clang_cc1 %s -triple armv7 -target-feature +neon -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple armv8 -target-feature +neon -fsyntax-only -verify
typedef float float32_t;
typedef signed char poly8_t;
-// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -flax-vector-conversions=all -fdouble-square-bracket-attributes -Werror -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -flax-vector-conversions=all -fdouble-square-bracket-attributes -verify -fsyntax-only -DERROR_CHECK %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -flax-vector-conversions=all -Werror -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-none-none-eabi -target-feature +mve.fp -flax-vector-conversions=all -verify -fsyntax-only -DERROR_CHECK %s
typedef signed short int16_t;
typedef signed int int32_t;
-// RUN: %clang_cc1 -fsyntax-only -fdouble-square-bracket-attributes -verify %s -Wincompatible-pointer-types -Wno-strict-prototypes
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wincompatible-pointer-types -Wno-strict-prototypes
int var __attribute__((overloadable)); // expected-error{{'overloadable' attribute only applies to functions}}
void bad_attr_target(int) [[clang::overloadable]]; // expected-error{{'overloadable' attribute cannot be applied to types}}
-// RUN: %clang_cc1 %s -verify -fsyntax-only -fdouble-square-bracket-attributes -Weverything -Wno-unused-but-set-variable -triple x86_64-apple-darwin10
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Weverything -Wno-unused-but-set-variable -triple x86_64-apple-darwin10
// Test the compatibility of clang's vector extensions with gcc's vector
// extensions for C. Notably &&, ||, ?: and ! are not available.
// Verify that we can use the [[]] spelling of the attribute.
// We intentionally use the same type alias name to check that both versions
// define the same type.
-// FIXME: Warnings are nuisance warnings due to the `-Weverything` flag, but
-// we shouldn't really be emitting them in C mode with the
-// `-fdouble-square-bracket-attributes` flag.
-typedef long long v2i64 [[gnu::vector_size(16)]]; // expected-warning{{C++11 attribute syntax is incompatible with C++98}}
-typedef int v2i32 [[gnu::vector_size(8)]]; // expected-warning{{C++11 attribute syntax is incompatible with C++98}}
+typedef long long v2i64 [[gnu::vector_size(16)]]; // expected-warning{{[[]] attributes are a C2x extension}}
+typedef int v2i32 [[gnu::vector_size(8)]]; // expected-warning{{[[]] attributes are a C2x extension}}
// Check various positions where the [[]] spelling can or cannot be used.
-[[gnu::vector_size(16)]] typedef long long v2i64; // expected-warning{{C++11 attribute syntax is incompatible with C++98}}
+[[gnu::vector_size(16)]] typedef long long v2i64; // expected-warning{{[[]] attributes are a C2x extension}}
typedef long long [[gnu::vector_size(16)]] v2i64_ignored;
// expected-warning@-1{{'vector_size' attribute ignored}}
- // expected-warning@-2{{C++11 attribute syntax is incompatible with C++98}}
+ // expected-warning@-2{{[[]] attributes are a C2x extension}}
// FIXME: Contrary to the error message that we emit, GCC does actually allow
// the attribute in the following position. Somewhat surprisingly, the attribute
// is applied not to the pointer but to the base type, i.e. this declaration has
typedef long long *[[gnu::vector_size(16)]] v2i64_doesnt_work;
// expected-error@-1{{invalid vector element type 'long long *'}}
// expected-warning@-2{{GCC does not allow the 'vector_size' attribute to be written on a type}}
- // expected-warning@-3{{C++11 attribute syntax is incompatible with C++98}}
+ // expected-warning@-3{{[[]] attributes are a C2x extension}}
// Verify that we can use the attribute outside of a typedef.
-static int v2i32_var [[gnu::vector_size(8)]]; // expected-warning{{C++11 attribute syntax is incompatible with C++98}}
+static int v2i32_var [[gnu::vector_size(8)]]; // expected-warning{{[[]] attributes are a C2x extension}}
void arithmeticTest(void);
void logicTest(void);
+++ /dev/null
-// RUN: %clang_cc1 -fsyntax-only -fno-double-square-bracket-attributes -verify -pedantic -std=c++11 -DERRORS %s
-// RUN: %clang_cc1 -fsyntax-only -fdouble-square-bracket-attributes -verify -pedantic -std=c++11 %s
-
-struct [[]] S {};
-
-#ifdef ERRORS
-// expected-error@-3 {{declaration of anonymous struct must be a definition}}
-// expected-warning@-4 {{declaration does not declare anything}}
-#else
-// expected-no-diagnostics
-#endif
-
class Variadic3 {};
alignas(8) int with_alignas; // expected-warning {{'alignas' is incompatible with C++98}}
-int with_attribute [[ ]]; // expected-warning {{C++11 attribute syntax is incompatible with C++98}}
+int with_attribute [[ ]]; // expected-warning {{[[]] attributes are incompatible with C++ standards before C++11}}
void Literals() {
(void)u8"str"; // expected-warning {{unicode literals are incompatible with C++98}}
auto f() -> int; // expected-warning {{trailing return types are incompatible with C++98}}
#ifdef CXX14COMPAT
-auto ff() { return 5; } // expected-warning {{'auto' type specifier is incompatible with C++98}}
+auto ff() { return 5; } // expected-warning {{'auto' type specifier is incompatible with C++98}}
// expected-warning@-1 {{return type deduction is incompatible with C++ standards before C++14}}
#endif
enum struct E1 { A, B }; // expected-warning {{scoped enumerations are a C++11 extension}}
enum class E2 { C, D }; // expected-warning {{scoped enumerations are a C++11 extension}}
+
+[[]] void func(); // expected-warning {{[[]] attributes are a C++11 extension}}
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fdouble-square-bracket-attributes -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
static id __attribute((objc_gc(weak))) a;
static id __attribute((objc_gc(strong))) b;
AST = buildASTFromCodeWithArgs(R"c(
__auto_type [[clang::annotate_type("auto")]] auto_var = 1;
)c",
- {"-fdouble-square-bracket-attributes"},
+ {},
"input.c");
{
// If this is the C++11 variety, also add in the LangOpts test.
if (Variety == "CXX11")
Test += " && LangOpts.CPlusPlus11";
- else if (Variety == "C2x")
- Test += " && LangOpts.DoubleSquareBracketAttributes";
} else if (Variety == "CXX11")
// C++11 mode should be checked against LangOpts, which is presumed to be
// present in the caller.
Test = "LangOpts.CPlusPlus11";
- else if (Variety == "C2x")
- Test = "LangOpts.DoubleSquareBracketAttributes";
std::string TestStr = !Test.empty()
? Test + " ? " + llvm::itostr(Version) + " : 0"
// FIXME: We should ask the driver for the appropriate default flags.
lang_opts.GNUMode = true;
lang_opts.GNUKeywords = true;
- lang_opts.DoubleSquareBracketAttributes = true;
lang_opts.CPlusPlus11 = true;
// The Darwin libc expects this macro to be set.