[cfe-commits] r168410 - /cfe/trunk/lib/AST/Decl.cpp

Enea Zaffanella zaffanella at cs.unipr.it
Sat Dec 15 00:29:00 PST 2012


On 11/27/2012 01:24 AM, Daniel Dunbar wrote:
> Hi Rafael,
>
> This code doesn't appear to be redundant, one of either this or the next
> commit broke gcc.dg/debug/redecl-1.c in the GCC test suite.
>
> You can repro with:
> --
> $ curl -s
> http://llvm.org/svn/llvm-project/clang-tests/trunk/gcc-4_2-testsuite/src/gcc.dg/debug/redecl-1.c
> | daclang -w -fsyntax-only -x c -
> <stdin>:338:9: error: invalid application of 'sizeof' to an incomplete
> type 'IA'
>        (aka 'int []')
>    sizeof(*c18());
>          ^~~~~~~~
> 1 error generated.
> --
>
>   - Daniel


Ping.

+1 for reverting this commit.

When parsing the following C code:

static int y;
void foo(void) {
   extern int y;
}

the second declaration of `y' is now getting external linkage, while it 
should be internal linkage (tested on r170126).

Enea.


> On Tue, Nov 20, 2012 at 6:47 PM, Rafael Espindola
> <rafael.espindola at gmail.com <mailto:rafael.espindola at gmail.com>> wrote:
>
>     Author: rafael
>     Date: Tue Nov 20 20:47:19 2012
>     New Revision: 168410
>
>     URL: http://llvm.org/viewvc/llvm-project?rev=168410&view=rev
>     Log:
>     Remove redundant code.
>
>     Modified:
>          cfe/trunk/lib/AST/Decl.cpp
>
>     Modified: cfe/trunk/lib/AST/Decl.cpp
>     URL:
>     http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=168410&r1=168409&r2=168410&view=diff
>     ==============================================================================
>     --- cfe/trunk/lib/AST/Decl.cpp (original)
>     +++ cfe/trunk/lib/AST/Decl.cpp Tue Nov 20 20:47:19 2012
>     @@ -355,30 +355,9 @@
>           if (Function->getStorageClass() == SC_PrivateExtern)
>             LV.mergeVisibility(HiddenVisibility, true);
>
>     -    // C99 6.2.2p5:
>     -    //   If the declaration of an identifier for a function has no
>     -    //   storage-class specifier, its linkage is determined exactly
>     -    //   as if it were declared with the storage-class specifier
>     -    //   extern.
>     -    if (!Context.getLangOpts().CPlusPlus &&
>     -        (Function->getStorageClass() == SC_Extern ||
>     -         Function->getStorageClass() == SC_PrivateExtern ||
>     -         Function->getStorageClass() == SC_None)) {
>     -      // C99 6.2.2p4:
>     -      //   For an identifier declared with the storage-class specifier
>     -      //   extern in a scope in which a prior declaration of that
>     -      //   identifier is visible, if the prior declaration specifies
>     -      //   internal or external linkage, the linkage of the identifier
>     -      //   at the later declaration is the same as the linkage
>     -      //   specified at the prior declaration. If no prior declaration
>     -      //   is visible, or if the prior declaration specifies no
>     -      //   linkage, then the identifier has external linkage.
>     -      if (const FunctionDecl *PrevFunc = Function->getPreviousDecl()) {
>     -        LinkageInfo PrevLV = getLVForDecl(PrevFunc, OnlyTemplate);
>     -        if (PrevLV.linkage()) LV.setLinkage(PrevLV.linkage());
>     -        LV.mergeVisibility(PrevLV);
>     -      }
>     -    }
>     +    // Note that Sema::MergeCompatibleFunctionDecls already takes
>     care of
>     +    // merging storage classes and visibility attributes, so we
>     don't have to
>     +    // look at previous decls in here.
>
>           // In C++, then if the type of the function uses a type with
>           // unique-external linkage, it's not legally usable from outside
>
>
>     _______________________________________________
>     cfe-commits mailing list
>     cfe-commits at cs.uiuc.edu <mailto:cfe-commits at cs.uiuc.edu>
>     http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>




More information about the cfe-commits mailing list