Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Standalone View
clang/test/SemaCXX/PR28101.cpp
- This file was added.
// RUN: %clang_cc1 -fsyntax-only -verify -DCASE_1 %s | |||||
// RUN: %clang_cc1 -fsyntax-only -verify -DCASE_2 %s | |||||
// RUN: %clang_cc1 -fsyntax-only -verify -DCASE_3 %s | |||||
// RUN: %clang_cc1 -fsyntax-only -verify -DCASE_4 -std=c++17 %s | |||||
// Don't crash. | |||||
#ifdef CASE_1 | |||||
erichkeane: This isn't necessary, the compiler in verify mode should see all errors. I see above at most 2… | |||||
Instantiation of each of the 4 classes could crash on its own, so I thought I'd separate them into 4 invocations. rZhBoYao: Instantiation of each of the 4 classes could crash on its own, so I thought I'd separate them… | |||||
They shouldn't crash afterwards, right? So this shouldn't be a problem. erichkeane: They shouldn't crash afterwards, right? So this shouldn't be a problem. | |||||
template <typename T> struct A { | |||||
A(void *) {} | |||||
T(A<T>){}; // expected-error{{member 'A' cannot have template arguments}} | |||||
}; | |||||
Not Done ReplyInline ActionsThis second error here is strange, I don't see it as particularly useful here. I see gcc at least gives the full name (int A<int>::A), perhaps that makes this more useful? erichkeane: This second error here is strange, I don't see it as particularly useful here.
I see gcc at… | |||||
A<int> instantiate() { return {nullptr}; } | |||||
#elifdef CASE_2 | |||||
How come there are no notes in this test that say 'in instantiation of...'? I would expect those in at least some of these cases, right? erichkeane: How come there are no notes in this test that say 'in instantiation of...'? I would expect… | |||||
Because it was caught before instantiation and when instantiating the FieldDecl is gone after calling D.setInvalidType();. If I set the identifier for the FieldDecl and let CheckCompletedCXXClass handle the "has the same name as its class" error, there will be the "in instantiation of..." note. rZhBoYao: Because it was caught before instantiation and when instantiating the FieldDecl is gone after… | |||||
I think we definitely need to do so there, the instantiation trace not being here makes this a much less useful diagnostic. erichkeane: I think we definitely need to do so there, the instantiation trace not being here makes this a… | |||||
template <typename T> struct A { | |||||
A(void *) {} | |||||
T A<T>{}; // expected-error{{member 'A' cannot have template arguments}} | |||||
}; | |||||
A<int> instantiate() { return {nullptr}; } | |||||
#elifdef CASE_3 | |||||
template <typename T> struct S {}; | |||||
template <typename T> struct A { | |||||
A(void *) {} | |||||
T S<T>{}; // expected-error{{member 'S' cannot have template arguments}} | |||||
}; | |||||
A<int> instantiate() { return {nullptr}; } | |||||
#elifdef CASE_4 | |||||
template <typename T, template <typename> typename U> class A { | |||||
public: | |||||
A(void *) {} | |||||
T(A<T, U<T>>) {} // expected-error{{member 'A' cannot have template arguments}}\ | |||||
// expected-error{{expected ';' at end of declaration list}} | |||||
}; | |||||
template <typename T> struct S {}; | |||||
A<int, S> foo() { return A<int, S>(nullptr); } | |||||
#endif |
This isn't necessary, the compiler in verify mode should see all errors. I see above at most 2 invocations of the compiler as necessary.