[cfe-commits] r150308 - in /cfe/trunk: lib/Sema/SemaType.cpp test/Sema/atomic-type.c test/SemaCXX/atomic-type.cxx
Richard Smith
richard-llvm at metafoo.co.uk
Sat Feb 11 10:03:45 PST 2012
Author: rsmith
Date: Sat Feb 11 12:03:45 2012
New Revision: 150308
URL: http://llvm.org/viewvc/llvm-project?rev=150308&view=rev
Log:
Make sure to try instantiating a templated type which is used in an _Atomic
before complaining that it's incomplete.
Added:
cfe/trunk/test/SemaCXX/atomic-type.cxx
Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/Sema/atomic-type.c
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=150308&r1=150307&r2=150308&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Sat Feb 11 12:03:45 2012
@@ -4402,12 +4402,14 @@
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;
Modified: cfe/trunk/test/Sema/atomic-type.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/atomic-type.c?rev=150308&r1=150307&r2=150308&view=diff
==============================================================================
--- cfe/trunk/test/Sema/atomic-type.c (original)
+++ cfe/trunk/test/Sema/atomic-type.c Sat Feb 11 12:03:45 2012
@@ -16,7 +16,7 @@
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}}
Added: cfe/trunk/test/SemaCXX/atomic-type.cxx
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/atomic-type.cxx?rev=150308&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/atomic-type.cxx (added)
+++ cfe/trunk/test/SemaCXX/atomic-type.cxx Sat Feb 11 12:03:45 2012
@@ -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;
More information about the cfe-commits
mailing list