Only refuse decl extraction if ill-formed; add test; move KnownFail out.

This commit is contained in:
Axel Naumann 2016-07-21 15:43:16 +02:00 committed by sftnight
parent b7c739fe61
commit ffec1df67b
3 changed files with 43 additions and 18 deletions

View File

@ -276,7 +276,7 @@ namespace cling {
Sema::LookupTagName, Sema::ForRedeclaration
);
m_Sema->LookupName(Previous, S);
m_Sema->LookupQualifiedName(Previous, DC);
// There is no function diagnosing the redeclaration of tags (eg. enums).
// So either we have to do it by hand or we can call the top-most
@ -289,8 +289,7 @@ namespace cling {
LookupResult Previous(*m_Sema, ND->getDeclName(), ND->getLocation(),
Sema::LookupOrdinaryName, Sema::ForRedeclaration
);
m_Sema->LookupName(Previous, S);
m_Sema->LookupQualifiedName(Previous, DC);
m_Sema->CheckVariableDeclaration(VD, Previous);
if (VD->isInvalidDecl())
return true;

View File

@ -6,22 +6,24 @@
// LICENSE.TXT for details.
//------------------------------------------------------------------------------
// RUN: cat %s | %cling | FileCheck %s
// RUN: cat %s | %cling -Xclang -verify
// XFAIL:*
// The test exposes a weakness in the declaration extraction of types. As
// reported in issue ROOT-5248.
// Check that decl extraction doesn't complain about unrelated decls
.rawInput 1
namespace UNRELATED { void name(); }
using namespace UNRELATED;
.rawInput 0
int name = 12;
extern "C" int printf(const char* fmt, ...);
// Check that decl extraction doesn't complain about unrelated decls
.rawInput 1
namespace N { void injected(); } // expected-note {{target of using declaration}}
using N::injected; // expected-note {{using declaration}}
.rawInput 0
int injected = 13; // expected-error {{declaration conflicts with target of using declaration already in scope}}
// Check that decl extraction does complain about clashing decls
extern "C" double likeSin(double); // expected-note {{previous definition is here}}
int likeSin = 14; // expected-error {{redefinition of 'likeSin' as different kind of symbol}}
class MyClass;
extern MyClass* my;
class MyClass {
public: MyClass* getMyClass() {
printf("Works!\n");
return 0;
}
} cl;
MyClass* my = cl.getMyClass();
.q
//CHECK: Works!

View File

@ -0,0 +1,24 @@
//------------------------------------------------------------------------------
// CLING - the C++ LLVM-based InterpreterG :)
//
// This file is dual-licensed: you can choose to license it under the University
// of Illinois Open Source License or the GNU Lesser General Public License. See
// LICENSE.TXT for details.
//------------------------------------------------------------------------------
// RUN: cat %s | %cling -Xclang -verify
// XFAIL: *
// The test exposes a weakness in the declaration extraction of types. As
// reported in issue ROOT-5248.
class MyClass; //expected-note {{candidate found by name lookup is 'MyClass'}}
extern MyClass* my;
class MyClass { //expected-note {{candidate found by name lookup is 'MyClass'}}
public:
MyClass* getMyClass() {
return 0;
}
} cl;
// The next line should work without complaints!
MyClass* my = cl.getMyClass(); //expected-error {{reference to 'MyClass' is ambiguous}}