diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst --- a/clang/docs/LanguageExtensions.rst +++ b/clang/docs/LanguageExtensions.rst @@ -1429,15 +1429,15 @@ 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 @@ -1457,10 +1457,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 ===================== diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -254,6 +254,9 @@ Deprecated Compiler Flags ------------------------- +- ``-fdouble-square-bracket-attributes`` has been deprecated. It is ignored now + and will be removed in CLang 18. + Modified Compiler Flags ----------------------- diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -719,8 +719,17 @@ def warn_cxx98_compat_alignas : Warning<"'alignas' is incompatible with C++98">, InGroup, 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, DefaultIgnore; +def warn_ext_cxx11_attributes : Extension< + "[[]] attributes are a C++11 extension">, + InGroup; +def warn_pre_c2x_compat_attributes : Warning< + "[[]] attributes are incompatible with C standards before C2x">, + DefaultIgnore, InGroup; +def warn_ext_c2x_attributes : Extension< + "[[]] attributes are a C2x extension">, + InGroup; def err_cxx11_attribute_forbids_arguments : Error< "attribute %0 cannot have an argument list">; def err_attribute_requires_arguments : Error< diff --git a/clang/include/clang/Basic/Features.def b/clang/include/clang/Basic/Features.def --- a/clang/include/clang/Basic/Features.def +++ b/clang/include/clang/Basic/Features.def @@ -245,6 +245,8 @@ 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_deleted_functions, LangOpts.CPlusPlus) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1257,9 +1257,7 @@ def fasynchronous_unwind_tables : Flag<["-"], "fasynchronous-unwind-tables">, Group; defm double_square_bracket_attributes : BoolFOption<"double-square-bracket-attributes", - LangOpts<"DoubleSquareBracketAttributes">, Default, - PosFlag, NegFlag, - BothFlags<[NoXarchOption, CC1Option], " '[[]]' attributes in all C and C++ language modes">>; + LangOpts<"DoubleSquareBracketAttributes">, DefaultTrue, PosFlag, NegFlag>; defm autolink : BoolFOption<"autolink", CodeGenOpts<"Autolink">, DefaultTrue, diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -2702,12 +2702,6 @@ 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 @@ -2716,15 +2710,14 @@ 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(); } @@ -2732,13 +2725,10 @@ 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, diff --git a/clang/lib/Basic/Attributes.cpp b/clang/lib/Basic/Attributes.cpp --- a/clang/lib/Basic/Attributes.cpp +++ b/clang/lib/Basic/Attributes.cpp @@ -33,8 +33,7 @@ // 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); diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -4222,9 +4222,7 @@ 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 { @@ -4441,8 +4439,7 @@ 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( diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -4503,7 +4503,13 @@ "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); @@ -4618,8 +4624,6 @@ /// 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; diff --git a/clang/test/AST/ast-dump-attr.m b/clang/test/AST/ast-dump-attr.m --- a/clang/test/AST/ast-dump-attr.m +++ b/clang/test/AST/ast-dump-attr.m @@ -1,12 +1,12 @@ // 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/ //" -e "s/ imported//" \ // RUN: | FileCheck --strict-whitespace %s diff --git a/clang/test/AST/ast-dump-c-attr.c b/clang/test/AST/ast-dump-c-attr.c --- a/clang/test/AST/ast-dump-c-attr.c +++ b/clang/test/AST/ast-dump-c-attr.c @@ -1,12 +1,12 @@ // 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/ //" -e "s/ imported//" \ // RUN: | FileCheck --strict-whitespace %s diff --git a/clang/test/AST/attr-annotate-type.c b/clang/test/AST/attr-annotate-type.c --- a/clang/test/AST/attr-annotate-type.c +++ b/clang/test/AST/attr-annotate-type.c @@ -1,4 +1,4 @@ -// 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 diff --git a/clang/test/CodeGen/attr-btf_type_tag-func.c b/clang/test/CodeGen/attr-btf_type_tag-func.c --- a/clang/test/CodeGen/attr-btf_type_tag-func.c +++ b/clang/test/CodeGen/attr-btf_type_tag-func.c @@ -1,5 +1,5 @@ // 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")]] diff --git a/clang/test/CodeGen/attr-btf_type_tag-var.c b/clang/test/CodeGen/attr-btf_type_tag-var.c --- a/clang/test/CodeGen/attr-btf_type_tag-var.c +++ b/clang/test/CodeGen/attr-btf_type_tag-var.c @@ -1,5 +1,5 @@ // 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")]] diff --git a/clang/test/Frontend/noderef.c b/clang/test/Frontend/noderef.c --- a/clang/test/Frontend/noderef.c +++ b/clang/test/Frontend/noderef.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -Wno-unused-value -fdouble-square-bracket-attributes -verify %s +// RUN: %clang_cc1 -Wno-unused-value -verify %s #define NODEREF __attribute__((noderef)) diff --git a/clang/test/OpenMP/assumes_messages_attr.c b/clang/test/OpenMP/assumes_messages_attr.c --- a/clang/test/OpenMP/assumes_messages_attr.c +++ b/clang/test/OpenMP/assumes_messages_attr.c @@ -1,5 +1,5 @@ -// 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}} diff --git a/clang/test/OpenMP/openmp_attribute_compat.cpp b/clang/test/OpenMP/openmp_attribute_compat.cpp --- a/clang/test/OpenMP/openmp_attribute_compat.cpp +++ b/clang/test/OpenMP/openmp_attribute_compat.cpp @@ -7,13 +7,12 @@ // 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}} - diff --git a/clang/test/Parser/asm.c b/clang/test/Parser/asm.c --- a/clang/test/Parser/asm.c +++ b/clang/test/Parser/asm.c @@ -1,4 +1,4 @@ -// 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 diff --git a/clang/test/Parser/c2x-attributes.c b/clang/test/Parser/c2x-attributes.c --- a/clang/test/Parser/c2x-attributes.c +++ b/clang/test/Parser/c2x-attributes.c @@ -1,4 +1,4 @@ -// 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 { diff --git a/clang/test/Parser/c2x-attributes.m b/clang/test/Parser/c2x-attributes.m --- a/clang/test/Parser/c2x-attributes.m +++ b/clang/test/Parser/c2x-attributes.m @@ -1,4 +1,4 @@ -// 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 diff --git a/clang/test/Parser/cxx-decl.cpp b/clang/test/Parser/cxx-decl.cpp --- a/clang/test/Parser/cxx-decl.cpp +++ b/clang/test/Parser/cxx-decl.cpp @@ -196,12 +196,9 @@ } // 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 { diff --git a/clang/test/Parser/objc-attr.m b/clang/test/Parser/objc-attr.m --- a/clang/test/Parser/objc-attr.m +++ b/clang/test/Parser/objc-attr.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -fdouble-square-bracket-attributes -triple x86_64-apple-macosx10.10.0 -verify %s +// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.10.0 -verify %s // expected-no-diagnostics @interface NSObject diff --git a/clang/test/ParserHLSL/group_shared.hlsl b/clang/test/ParserHLSL/group_shared.hlsl --- a/clang/test/ParserHLSL/group_shared.hlsl +++ b/clang/test/ParserHLSL/group_shared.hlsl @@ -8,9 +8,6 @@ // 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; diff --git a/clang/test/Preprocessor/has_c_attribute.c b/clang/test/Preprocessor/has_c_attribute.c --- a/clang/test/Preprocessor/has_c_attribute.c +++ b/clang/test/Preprocessor/has_c_attribute.c @@ -1,4 +1,4 @@ -// 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) diff --git a/clang/test/Sema/annotate-type.c b/clang/test/Sema/annotate-type.c --- a/clang/test/Sema/annotate-type.c +++ b/clang/test/Sema/annotate-type.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -fsyntax-only -fdouble-square-bracket-attributes -verify +// RUN: %clang_cc1 %s -fsyntax-only -verify const char *some_function(); diff --git a/clang/test/Sema/annotate.c b/clang/test/Sema/annotate.c --- a/clang/test/Sema/annotate.c +++ b/clang/test/Sema/annotate.c @@ -1,4 +1,4 @@ -// 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; diff --git a/clang/test/Sema/attr-availability-square-brackets.c b/clang/test/Sema/attr-availability-square-brackets.c --- a/clang/test/Sema/attr-availability-square-brackets.c +++ b/clang/test/Sema/attr-availability-square-brackets.c @@ -1,4 +1,4 @@ -// 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}} diff --git a/clang/test/Sema/attr-external-source-symbol-cxx.cpp b/clang/test/Sema/attr-external-source-symbol-cxx.cpp --- a/clang/test/Sema/attr-external-source-symbol-cxx.cpp +++ b/clang/test/Sema/attr-external-source-symbol-cxx.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -fblocks -verify -fdouble-square-bracket-attributes %s +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s template class Class { diff --git a/clang/test/Sema/attr-external-source-symbol.c b/clang/test/Sema/attr-external-source-symbol.c --- a/clang/test/Sema/attr-external-source-symbol.c +++ b/clang/test/Sema/attr-external-source-symbol.c @@ -1,4 +1,4 @@ -// 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))); diff --git a/clang/test/Sema/attr-likelihood.c b/clang/test/Sema/attr-likelihood.c --- a/clang/test/Sema/attr-likelihood.c +++ b/clang/test/Sema/attr-likelihood.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -fsyntax-only -fdouble-square-bracket-attributes -verify +// RUN: %clang_cc1 %s -fsyntax-only -verify void g(void) { if (1) diff --git a/clang/test/Sema/attr-objc-bridge-related.m b/clang/test/Sema/attr-objc-bridge-related.m --- a/clang/test/Sema/attr-objc-bridge-related.m +++ b/clang/test/Sema/attr-objc-bridge-related.m @@ -1,4 +1,4 @@ -// 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; diff --git a/clang/test/Sema/attr-regparm.c b/clang/test/Sema/attr-regparm.c --- a/clang/test/Sema/attr-regparm.c +++ b/clang/test/Sema/attr-regparm.c @@ -1,4 +1,4 @@ -// 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}} diff --git a/clang/test/Sema/attr-type-safety.c b/clang/test/Sema/attr-type-safety.c --- a/clang/test/Sema/attr-type-safety.c +++ b/clang/test/Sema/attr-type-safety.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -fdouble-square-bracket-attributes -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s struct A {}; diff --git a/clang/test/Sema/c2x-attr.c b/clang/test/Sema/c2x-attr.c new file mode 100644 --- /dev/null +++ b/clang/test/Sema/c2x-attr.c @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c2x -Wc2x-compat -verify=c2x %s +// RUN: %clang_cc1 -fsyntax-only -std=c17 -Wc2x-extensions -verify=pre-c2x %s + +[[]] void func(); // c2x-warning {{[[]] attributes are incompatible with C standards before C2x}} + // pre-c2x-warning@-1 {{[[]] attributes are a C2x extension}} diff --git a/clang/test/Sema/c2x-noreturn.c b/clang/test/Sema/c2x-noreturn.c --- a/clang/test/Sema/c2x-noreturn.c +++ b/clang/test/Sema/c2x-noreturn.c @@ -1,7 +1,7 @@ // 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. diff --git a/clang/test/Sema/internal_linkage.c b/clang/test/Sema/internal_linkage.c --- a/clang/test/Sema/internal_linkage.c +++ b/clang/test/Sema/internal_linkage.c @@ -1,4 +1,4 @@ -// 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}} \ diff --git a/clang/test/Sema/matrix-type-builtins.c b/clang/test/Sema/matrix-type-builtins.c --- a/clang/test/Sema/matrix-type-builtins.c +++ b/clang/test/Sema/matrix-type-builtins.c @@ -1,4 +1,4 @@ -// 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))); @@ -8,17 +8,17 @@ // 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) { diff --git a/clang/test/Sema/neon-vector-types.c b/clang/test/Sema/neon-vector-types.c --- a/clang/test/Sema/neon-vector-types.c +++ b/clang/test/Sema/neon-vector-types.c @@ -1,5 +1,5 @@ -// 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; diff --git a/clang/test/Sema/overload-arm-mve.c b/clang/test/Sema/overload-arm-mve.c --- a/clang/test/Sema/overload-arm-mve.c +++ b/clang/test/Sema/overload-arm-mve.c @@ -1,5 +1,5 @@ -// 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; diff --git a/clang/test/Sema/overloadable.c b/clang/test/Sema/overloadable.c --- a/clang/test/Sema/overloadable.c +++ b/clang/test/Sema/overloadable.c @@ -1,4 +1,4 @@ -// 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}} diff --git a/clang/test/Sema/vector-gcc-compat.c b/clang/test/Sema/vector-gcc-compat.c --- a/clang/test/Sema/vector-gcc-compat.c +++ b/clang/test/Sema/vector-gcc-compat.c @@ -1,4 +1,4 @@ -// 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. @@ -20,17 +20,14 @@ // 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 @@ -38,10 +35,10 @@ 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); diff --git a/clang/test/SemaCXX/attr-cxx-disabled.cpp b/clang/test/SemaCXX/attr-cxx-disabled.cpp deleted file mode 100644 --- a/clang/test/SemaCXX/attr-cxx-disabled.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// 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 - diff --git a/clang/test/SemaCXX/cxx98-compat.cpp b/clang/test/SemaCXX/cxx98-compat.cpp --- a/clang/test/SemaCXX/cxx98-compat.cpp +++ b/clang/test/SemaCXX/cxx98-compat.cpp @@ -24,7 +24,7 @@ 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}} @@ -104,7 +104,7 @@ 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 diff --git a/clang/test/SemaCXX/warn-c++11-extensions.cpp b/clang/test/SemaCXX/warn-c++11-extensions.cpp --- a/clang/test/SemaCXX/warn-c++11-extensions.cpp +++ b/clang/test/SemaCXX/warn-c++11-extensions.cpp @@ -7,3 +7,5 @@ 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}} diff --git a/clang/test/SemaObjC/attr-objc-gc.m b/clang/test/SemaObjC/attr-objc-gc.m --- a/clang/test/SemaObjC/attr-objc-gc.m +++ b/clang/test/SemaObjC/attr-objc-gc.m @@ -1,4 +1,4 @@ -// 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; diff --git a/clang/unittests/AST/AttrTest.cpp b/clang/unittests/AST/AttrTest.cpp --- a/clang/unittests/AST/AttrTest.cpp +++ b/clang/unittests/AST/AttrTest.cpp @@ -157,7 +157,7 @@ AST = buildASTFromCodeWithArgs(R"c( __auto_type [[clang::annotate_type("auto")]] auto_var = 1; )c", - {"-fdouble-square-bracket-attributes"}, + {}, "input.c"); { diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp --- a/clang/utils/TableGen/ClangAttrEmitter.cpp +++ b/clang/utils/TableGen/ClangAttrEmitter.cpp @@ -3394,14 +3394,10 @@ // 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" diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -575,7 +575,6 @@ // 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.