r235174 - Follow-up to r235046: selectany only causes a definition if it's not inherited.

Nico Weber thakis at chromium.org
Fri Apr 17 02:58:49 PDT 2015


Folks who did selectany codegen: Is it better to make SelectAnyAttr a
regular Attr instead of an InheritableAttr in include/clang/Basic/Attr.td
instead of checking this in code?

On Fri, Apr 17, 2015 at 2:50 AM, Nico Weber <nicolasweber at gmx.de> wrote:

> Author: nico
> Date: Fri Apr 17 04:50:28 2015
> New Revision: 235174
>
> URL: http://llvm.org/viewvc/llvm-project?rev=235174&view=rev
> Log:
> Follow-up to r235046: selectany only causes a definition if it's not
> inherited.
>
> (For example needed to parse system header inputscope.h, which first has
> an extern "C" selectany IID and then later an extern "C" declaration of
> that
> same IID.)
>
> Modified:
>     cfe/trunk/lib/AST/Decl.cpp
>     cfe/trunk/test/SemaCXX/attr-selectany.cpp
>
> Modified: cfe/trunk/lib/AST/Decl.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=235174&r1=235173&r2=235174&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/AST/Decl.cpp (original)
> +++ cfe/trunk/lib/AST/Decl.cpp Fri Apr 17 04:50:28 2015
> @@ -1915,7 +1915,8 @@ VarDecl::isThisDeclarationADefinition(AS
>    if (hasInit())
>      return Definition;
>
> -  if (hasAttr<AliasAttr>() || hasAttr<SelectAnyAttr>())
> +  if (hasAttr<AliasAttr>() ||
> +      (hasAttr<SelectAnyAttr>() &&
> !getAttr<SelectAnyAttr>()->isInherited()))
>      return Definition;
>
>    // A variable template specialization (other than a static data member
>
> Modified: cfe/trunk/test/SemaCXX/attr-selectany.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-selectany.cpp?rev=235174&r1=235173&r2=235174&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/attr-selectany.cpp (original)
> +++ cfe/trunk/test/SemaCXX/attr-selectany.cpp Fri Apr 17 04:50:28 2015
> @@ -42,5 +42,9 @@ __declspec(selectany) auto x8 = Internal
>  struct SomeStruct {};
>  extern const __declspec(selectany) SomeStruct some_struct; //
> expected-warning {{default initialization of an object of const type 'const
> SomeStruct' without a user-provided default constructor is a Microsoft
> extension}}
>
> +// It should be possible to redeclare variables that were defined
> +// __declspec(selectany) previously.
> +extern const SomeStruct some_struct;
> +
>  // Without selectany, this should stay an error.
>  const SomeStruct some_struct2; // expected-error {{default initialization
> of an object of const type 'const SomeStruct' without a user-provided
> default constructor}}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150417/3343f4d0/attachment.html>


More information about the cfe-commits mailing list