From 61736556394148537bce1ee35c5a2b4e60239e14 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Sat, 21 Oct 2017 20:28:58 +0000 Subject: [PATCH] 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. llvm-svn: 316275 --- clang/include/clang/Driver/Options.td | 4 ++-- clang/lib/Driver/ToolChains/Clang.cpp | 3 +++ clang/test/SemaCXX/attr-cxx-disabled.cpp | 12 ++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 clang/test/SemaCXX/attr-cxx-disabled.cpp diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 526b72f792c0..9f6152140883 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/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/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 8e5f3b95735b..adaf39abc5fd 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/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/clang/test/SemaCXX/attr-cxx-disabled.cpp b/clang/test/SemaCXX/attr-cxx-disabled.cpp new file mode 100644 index 000000000000..a1a7533bd854 --- /dev/null +++ b/clang/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 +