[llvm-bugs] [Bug 47842] New: "Broken nested name specifier"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Oct 14 05:42:19 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47842

            Bug ID: 47842
           Summary: "Broken nested name specifier"' failed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tangyixuan at mail.dlut.edu.cn
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Hi, the following code is ill-formed. Besides error diagnostics, clang also
crashes. However, I suffer two questions:
1. If the user-defined name 'NamespaceDeclA' is replaced with other name, such
as a simple name 'A', clang would not crash.
2. Following the suggestions of the error diagnostics, the error in code would
not be fixed while other error diagnostics would appear.

$ cat s.cpp
namespace NamespaceDeclA { 
  struct S {} S ;
} 
struct NamespaceDeclA :: S :: NamespaceDeclB :: S {};

$ clang++ -c s.cpp

s.cpp:4:8: error: no member named 'NamespaceDeclB' in 'NamespaceDeclA::S'; did
you mean 'NamespaceDeclA'?
struct NamespaceDeclA :: S :: NamespaceDeclB :: S {};
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       NamespaceDeclA
s.cpp:1:11: note: 'NamespaceDeclA' declared here
namespace NamespaceDeclA { 
          ^
clang++:
/home/oscar/compiler/llvm-project/clang/lib/AST/NestedNameSpecifier.cpp:79:
static clang::NestedNameSpecifier* clang::NestedNameSpecifier::Create(const
clang::ASTContext&, clang::NestedNameSpecifier*, const clang::NamespaceDecl*):
Assertion `(!Prefix || (Prefix->getAsType() == nullptr &&
Prefix->getAsIdentifier() == nullptr)) && "Broken nested name specifier"'
failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /usr/local/bin/clang++ -std=c++2a -c 502-14-1.C 
1.      502-14-1.C:4:49: current parser token 'S'
 #0 0x00005641af7729e0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
/home/oscar/compiler/llvm-project/llvm/lib/Support/Unix/Signals.inc:563:0
 #1 0x00005641af772a84 PrintStackTraceSignalHandler(void*)
/home/oscar/compiler/llvm-project/llvm/lib/Support/Unix/Signals.inc:627:0
 #2 0x00005641af77083b llvm::sys::RunSignalHandlers()
/home/oscar/compiler/llvm-project/llvm/lib/Support/Signals.cpp:70:0

-- 
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/20201014/6f5a7737/attachment.html>


More information about the llvm-bugs mailing list