From: Aaron Ballman Date: Sat, 21 Oct 2017 20:28:58 +0000 (+0000) Subject: Fix a typo with -fno-double-square-bracket-attributes and add a test to demonstrate... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=59611f54fa88ba639661d2e0e2e8b607bd48d4a7;p=clang Fix a typo with -fno-double-square-bracket-attributes and add a test to demonstrate that it works as expected in C++11 mode. Additionally corrected the handling of -fdouble-square-bracket-attributes to be properly passed down to the cc1 option. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316275 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 526b72f792..9f61521408 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -613,8 +613,8 @@ def fasynchronous_unwind_tables : Flag<["-"], "fasynchronous-unwind-tables">, Gr def fdouble_square_bracket_attributes : Flag<[ "-" ], "fdouble-square-bracket-attributes">, Group, Flags<[DriverOption, CC1Option]>, HelpText<"Enable '[[]]' attributes in all C and C++ language modes">; -def fno_double_square_bracket_attributes : Flag<[ "-" ], "fno-fdouble-square-bracket-attributes">, - Group, Flags<[DriverOption]>, +def fno_double_square_bracket_attributes : Flag<[ "-" ], "fno-double-square-bracket-attributes">, + Group, Flags<[DriverOption, CC1Option]>, HelpText<"Disable '[[]]' attributes in all C and C++ language modes">; def fautolink : Flag <["-"], "fautolink">, Group; diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp index 8e5f3b9573..adaf39abc5 100644 --- a/lib/Driver/ToolChains/Clang.cpp +++ b/lib/Driver/ToolChains/Clang.cpp @@ -4010,6 +4010,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-fcoroutines-ts"); } + Args.AddLastArg(CmdArgs, options::OPT_fdouble_square_bracket_attributes, + options::OPT_fno_double_square_bracket_attributes); + bool HaveModules = false; RenderModulesOptions(C, D, Args, Input, Output, CmdArgs, HaveModules); diff --git a/test/SemaCXX/attr-cxx-disabled.cpp b/test/SemaCXX/attr-cxx-disabled.cpp new file mode 100644 index 0000000000..a1a7533bd8 --- /dev/null +++ b/test/SemaCXX/attr-cxx-disabled.cpp @@ -0,0 +1,12 @@ +// 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 +