Make sure to try instantiating a templated type which is used in an _Atomic

before complaining that it's incomplete.

llvm-svn: 150308
This commit is contained in:
Richard Smith 2012-02-11 18:03:45 +00:00
parent c6b4017ce2
commit 4c7b490d19
3 changed files with 20 additions and 6 deletions

View File

@ -4402,12 +4402,14 @@ QualType Sema::BuildUnaryTransformType(QualType BaseType,
QualType Sema::BuildAtomicType(QualType T, SourceLocation Loc) {
if (!T->isDependentType()) {
// FIXME: It isn't entirely clear whether incomplete atomic types
// are allowed or not; for simplicity, ban them for the moment.
if (RequireCompleteType(Loc, T,
PDiag(diag::err_atomic_specifier_bad_type) << 0))
return QualType();
int DisallowedKind = -1;
if (T->isIncompleteType())
// FIXME: It isn't entirely clear whether incomplete atomic types
// are allowed or not; for simplicity, ban them for the moment.
DisallowedKind = 0;
else if (T->isArrayType())
if (T->isArrayType())
DisallowedKind = 1;
else if (T->isFunctionType())
DisallowedKind = 2;

View File

@ -16,7 +16,7 @@ extern _Atomic(int (*)(int(*)[10], int(*)[])) mergetest;
extern _Atomic(int (*)(int(*)[10], int(*)[10])) mergetest;
_Atomic(int()) error1; // expected-error {{_Atomic cannot be applied to function type}}
_Atomic(struct ErrorS) error2; // expected-error {{_Atomic cannot be applied to incomplete type}}
_Atomic(struct ErrorS) error2; // expected-error {{_Atomic cannot be applied to incomplete type}} expected-note {{forward declaration}}
_Atomic(int[10]) error3; // expected-error {{_Atomic cannot be applied to array type}}
_Atomic(const int) error4; // expected-error {{_Atomic cannot be applied to qualified type}}
_Atomic(_Atomic(int)) error5; // expected-error {{_Atomic cannot be applied to atomic type}}

View File

@ -0,0 +1,12 @@
// RUN: %clang_cc1 -verify %s
template<typename T> struct atomic {
_Atomic(T) value;
};
template<typename T> struct user {
struct inner { char n[sizeof(T)]; };
atomic<inner> i;
};
user<int> u;