r180263 - Fix a case in linkage computation that should check for single line extern "C".
Rafael EspĂndola
rafael.espindola at gmail.com
Thu Apr 25 17:36:27 PDT 2013
Thanks a lot. Bill also sent me a testcase. I have committed the
testcase and I am now debugging what went wrong with this patch.
On 25 April 2013 17:41, David Dean <david_dean at apple.com> wrote:
> I'm seeing a crash when building clang on darwin11 after this commit: you can view the builder here:
> http://lab.llvm.org:8013/builders/clang-x86_64-darwin11-RA/builds/1711
>
> I've also attached the output files from the crash to try and help you reproduce the issue.
>
>
>
> On 25 Apr 2013, at 6:10 AM, Rafael Espindola <rafael.espindola at gmail.com> wrote:
>
>> Author: rafael
>> Date: Thu Apr 25 08:10:46 2013
>> New Revision: 180263
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=180263&view=rev
>> Log:
>> Fix a case in linkage computation that should check for single line extern "C".
>>
>> Modified:
>> cfe/trunk/lib/AST/Decl.cpp
>> cfe/trunk/test/SemaCXX/undefined-internal.cpp
>>
>> Modified: cfe/trunk/lib/AST/Decl.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=180263&r1=180262&r2=180263&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/AST/Decl.cpp (original)
>> +++ cfe/trunk/lib/AST/Decl.cpp Thu Apr 25 08:10:46 2013
>> @@ -476,6 +476,13 @@ template <typename T> static bool isInEx
>> return First->getDeclContext()->isExternCContext();
>> }
>>
>> +static bool isSingleLineExternC(const Decl &D) {
>> + if (const LinkageSpecDecl *SD = dyn_cast<LinkageSpecDecl>(D.getDeclContext()))
>> + if (SD->getLanguage() == LinkageSpecDecl::lang_c && !SD->hasBraces())
>> + return true;
>> + return false;
>> +}
>> +
>> static LinkageInfo getLVForNamespaceScopeDecl(const NamedDecl *D,
>> LVComputationKind computation) {
>> assert(D->getDeclContext()->getRedeclContext()->isFileContext() &&
>> @@ -504,7 +511,8 @@ static LinkageInfo getLVForNamespaceScop
>> return PrevVar->getLinkageAndVisibility();
>>
>> if (Var->getStorageClass() != SC_Extern &&
>> - Var->getStorageClass() != SC_PrivateExtern)
>> + Var->getStorageClass() != SC_PrivateExtern &&
>> + !isSingleLineExternC(*Var))
>> return LinkageInfo::internal();
>> }
>>
>> @@ -1580,11 +1588,8 @@ VarDecl::DefinitionKind VarDecl::isThisD
>> // A declaration directly contained in a linkage-specification is treated
>> // as if it contains the extern specifier for the purpose of determining
>> // the linkage of the declared name and whether it is a definition.
>> - const DeclContext *DC = getDeclContext();
>> - if (const LinkageSpecDecl *SD = dyn_cast<LinkageSpecDecl>(DC)) {
>> - if (SD->getLanguage() == LinkageSpecDecl::lang_c && !SD->hasBraces())
>> - return DeclarationOnly;
>> - }
>> + if (isSingleLineExternC(*this))
>> + return DeclarationOnly;
>>
>> // C99 6.9.2p2:
>> // A declaration of an object that has file scope without an initializer,
>>
>> Modified: cfe/trunk/test/SemaCXX/undefined-internal.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/undefined-internal.cpp?rev=180263&r1=180262&r2=180263&view=diff
>> ==============================================================================
>> --- cfe/trunk/test/SemaCXX/undefined-internal.cpp (original)
>> +++ cfe/trunk/test/SemaCXX/undefined-internal.cpp Thu Apr 25 08:10:46 2013
>> @@ -323,3 +323,10 @@ namespace test13 {
>> }
>> }
>>
>> +namespace test14 {
>> + extern "C" const int foo;
>> +
>> + int f() {
>> + return foo;
>> + }
>> +}
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
> -David
>
>
>
More information about the cfe-commits
mailing list