[LLVMbugs] [Bug 15942] New: Assertion failure generating diagnostics for re-definitions of builtin typedefs

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu May 9 09:39:50 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=15942

            Bug ID: 15942
           Summary: Assertion failure generating diagnostics for
                    re-definitions of builtin typedefs
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: thonermann at coverity.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Below are a number of test cases, some of which cause assertion failures in
Clang 3.2 and 3.3rc1.  The assertion failure occurs when emitting a diagnostic
for the attempted re-definition of the builtin typedef.

These test cases all reference the builtin __int128 builtin type and __int128_t
builtin typedefs.  Similar test cases for __uint128 and __uint128_t result in
the same behavior.  The assertion failures will only occur for targets for
which these builtin typedefs are created.


# (1) This test case illustrates that an error is correctly emitted for a
conflicting re-definition of a builtin typedef.
$ cat test-redef-conflict-int128.c
/* error: typedef redefinition with different types ('int' vs '__int128') */
typedef int __int128_t;


# (2) This test case leads to an assertion failure when emitting a typedef
re-definition warning when compiling for C89 or C99.  The warning is not
emitted, and the assertion failure does not occur when compiling as C++ or with
the -std=c11 options.
$ cat test-redef-int128.c
/* clang: lib/Basic/SourceManager.cpp:1340: clang::SrcMgr::CharacteristicKind
clang::SourceManager::getFileCharacteristic(clang::SourceLocation) const:
Assertion `!Loc.isInvalid() && "Can't get file characteristic of invalid loc!"'
failed. */
typedef __int128 __int128_t;


# (3) This test case leads to an assertion failure when emitting a typedef
re-definition warning when compiling for C89 or C99.  The warning is not
emitted, and the assertion failure does not occur when compiling as C++ or with
the -std=c11 options.  The root cause is the same as for test (2) above and the
same behavior is expected.
$ cat test-redef-int128-with-attr.c
/* clang: lib/Basic/SourceManager.cpp:1340: clang::SrcMgr::CharacteristicKind
clang::SourceManager::getFileCharacteristic(clang::SourceLocation) const:
Assertion `!Loc.isInvalid() && "Can't get file characteristic of invalid loc!"'
failed. */
typedef int __int128_t __attribute__((mode(TI)));


An example invocation of Clang for case (2) above:

$ clang -v -c test-redef-int128.c
clang version 3.3 (tags/RELEASE_33/rc1)
Target: x86_64-unknown-linux-gnu
Thread model: posix
 "/nfs/thonermann/products/linux-x86/clang-3.3/bin/clang" -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
test-redef-int128.c -mrelocation-model static -mdisable-fp-elim -fmath-errno
-masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64
-target-linker-version 2.22 -v -coverage-file
/nfs/thonermann/test/clang/test-redef-builtin-typedef/test-redef-int128.o
-resource-dir /nfs/thonermann/products/linux-x86/clang-3.3/bin/../lib/clang/3.3
-internal-isystem /usr/local/include -internal-isystem
/nfs/thonermann/products/linux-x86/clang-3.3/bin/../lib/clang/3.3/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdebug-compilation-dir /nfs/thonermann/test/clang/test-redef-builtin-typedef
-ferror-limit 19 -fmessage-length 197 -mstackrealign -fobjc-runtime=gcc
-fobjc-default-synthesize-properties -fdiagnostics-show-option
-fcolor-diagnostics -backend-option -vectorize-loops -o test-redef-int128.o -x
c test-redef-int128.c
clang -cc1 version 3.3 based upon LLVM 3.3svn default target
x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /nfs/thonermann/products/linux-x86/clang-3.3/bin/../lib/clang/3.3/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
clang:
/nfs/thonermann/src/llvm-3.3/tools/clang/lib/Basic/SourceManager.cpp:1340:
clang::SrcMgr::CharacteristicKind
clang::SourceManager::getFileCharacteristic(clang::SourceLocation) const:
Assertion `!Loc.isInvalid() && "Can't get file characteristic of invalid loc!"'
failed.
0  clang           0x000000000308334e llvm::sys::PrintStackTrace(_IO_FILE*) +
38
1  clang           0x00000000030835d5
2  clang           0x0000000003083024
3  libpthread.so.0 0x00007fb7ad6f0cb0
4  libc.so.6       0x00007fb7ac946445 gsignal + 53
5  libc.so.6       0x00007fb7ac949bab abort + 379
6  libc.so.6       0x00007fb7ac93f10e
7  libc.so.6       0x00007fb7ac93f1b2
8  clang           0x0000000001fdee5a
clang::SourceManager::getFileCharacteristic(clang::SourceLocation) const + 62
9  clang           0x00000000011debb2
10 clang           0x00000000012c57a7
clang::Sema::MergeTypedefNameDecl(clang::TypedefNameDecl*,
clang::LookupResult&) + 1547
11 clang           0x00000000012d0e44
clang::Sema::ActOnTypedefNameDecl(clang::Scope*, clang::DeclContext*,
clang::TypedefNameDecl*, clang::LookupResult&, bool&) + 144
12 clang           0x00000000012d0acb
clang::Sema::ActOnTypedefDeclarator(clang::Scope*, clang::Declarator&,
clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&) + 747
13 clang           0x00000000012cf91e
clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&,
llvm::MutableArrayRef<clang::TemplateParameterList*>) + 2704
14 clang           0x00000000012ce724
clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&) + 80
15 clang           0x00000000011b29ee
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&) + 148
16 clang           0x00000000011b23f6
clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int, bool,
clang::SourceLocation*, clang::Parser::ForRangeInit*) + 1428
17 clang           0x00000000011b18b2
clang::Parser::ParseSimpleDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&,
unsigned int, clang::SourceLocation&,
clang::Parser::ParsedAttributesWithRange&, bool, clang::Parser::ForRangeInit*)
+ 506
18 clang           0x00000000011b166a
clang::Parser::ParseDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, unsigned
int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) + 736
19 clang           0x000000000119f614
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) + 1680
20 clang           0x000000000119ef53
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 415
21 clang           0x000000000119b75b clang::ParseAST(clang::Sema&, bool, bool)
+ 387
22 clang           0x0000000000d75b96 clang::ASTFrontendAction::ExecuteAction()
+ 298
23 clang           0x0000000000fb378c clang::CodeGenAction::ExecuteAction() +
1414
24 clang           0x0000000000d75718 clang::FrontendAction::Execute() + 200
25 clang           0x0000000000d48c14
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 720
26 clang           0x0000000000d182ac
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1018
27 clang           0x0000000000d080fb cc1_main(char const**, char const**, char
const*, void*) + 717
28 clang           0x0000000000d12857 main + 496
29 libc.so.6       0x00007fb7ac93176d __libc_start_main + 237
30 clang           0x0000000000d077d9
Stack dump:
0.      Program arguments:
/nfs/thonermann/products/linux-x86/clang-3.3/bin/clang -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
test-redef-int128.c -mrelocation-model static -mdisable-fp-elim -fmath-errno
-masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64
-target-linker-version 2.22 -v -coverage-file
/nfs/thonermann/test/clang/test-redef-builtin-typedef/test-redef-int128.o
-resource-dir /nfs/thonermann/products/linux-x86/clang-3.3/bin/../lib/clang/3.3
-internal-isystem /usr/local/include -internal-isystem
/nfs/thonermann/products/linux-x86/clang-3.3/bin/../lib/clang/3.3/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdebug-compilation-dir /nfs/thonermann/test/clang/test-redef-builtin-typedef
-ferror-limit 19 -fmessage-length 197 -mstackrealign -fobjc-runtime=gcc
-fobjc-default-synthesize-properties -fdiagnostics-show-option
-fcolor-diagnostics -backend-option -vectorize-loops -o test-redef-int128.o -x
c test-redef-int128.c 
1.      test-redef-int128.c:2:28: current parser token ';'
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.3 (tags/RELEASE_33/rc1)
Target: x86_64-unknown-linux-gnu
Thread model: posix

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130509/2e287df5/attachment.html>


More information about the llvm-bugs mailing list