[cfe-commits] r45989 - in /cfe/trunk: Sema/SemaType.cpp test/Sema/complex-int.c test/Sema/illegal-types.c
Steve Naroff
snaroff at apple.com
Mon Jan 14 15:33:21 PST 2008
Author: snaroff
Date: Mon Jan 14 17:33:18 2008
New Revision: 45989
URL: http://llvm.org/viewvc/llvm-project?rev=45989&view=rev
Log:
Make sure Sema::GetTypeForDeclarator() deals with abstract declarators when diagnosing incorrect code.
Bug submitted by Eli.
Added:
cfe/trunk/test/Sema/illegal-types.c
Modified:
cfe/trunk/Sema/SemaType.cpp
cfe/trunk/test/Sema/complex-int.c
Modified: cfe/trunk/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaType.cpp?rev=45989&r1=45988&r2=45989&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaType.cpp (original)
+++ cfe/trunk/Sema/SemaType.cpp Mon Jan 14 17:33:18 2008
@@ -164,7 +164,7 @@
if (T->isReferenceType()) {
// C++ 8.3.2p4: There shall be no ... pointers to references ...
Diag(D.getIdentifierLoc(), diag::err_illegal_decl_pointer_to_reference,
- D.getIdentifier()->getName());
+ D.getIdentifier() ? D.getIdentifier()->getName() : "type name");
D.setInvalidType(true);
T = Context.IntTy;
}
@@ -177,7 +177,7 @@
// C++ 8.3.2p4: There shall be no references to references ...
Diag(D.getIdentifierLoc(),
diag::err_illegal_decl_reference_to_reference,
- D.getIdentifier()->getName());
+ D.getIdentifier() ? D.getIdentifier()->getName() : "type name");
D.setInvalidType(true);
T = RT->getReferenceeType();
}
@@ -204,13 +204,13 @@
D.setInvalidType(true);
} else if (T->isFunctionType()) {
Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_of_functions,
- D.getIdentifier()->getName());
+ D.getIdentifier() ? D.getIdentifier()->getName() : "type name");
T = Context.getPointerType(T);
D.setInvalidType(true);
} else if (const ReferenceType *RT = T->getAsReferenceType()) {
// C++ 8.3.2p4: There shall be no ... arrays of references ...
Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_of_references,
- D.getIdentifier()->getName());
+ D.getIdentifier() ? D.getIdentifier()->getName() : "type name");
T = RT->getReferenceeType();
D.setInvalidType(true);
} else if (const RecordType *EltTy = T->getAsRecordType()) {
Modified: cfe/trunk/test/Sema/complex-int.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/complex-int.c?rev=45989&r1=45988&r2=45989&view=diff
==============================================================================
--- cfe/trunk/test/Sema/complex-int.c (original)
+++ cfe/trunk/test/Sema/complex-int.c Mon Jan 14 17:33:18 2008
@@ -3,8 +3,12 @@
void a() {
__complex__ int arr;
__complex__ short brr;
+__complex__ unsigned xx;
+__complex__ signed yy;
+
__complex__ int result;
result = arr*brr;
+result = xx*yy;
}
Added: cfe/trunk/test/Sema/illegal-types.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/illegal-types.c?rev=45989&view=auto
==============================================================================
--- cfe/trunk/test/Sema/illegal-types.c (added)
+++ cfe/trunk/test/Sema/illegal-types.c Mon Jan 14 17:33:18 2008
@@ -0,0 +1,7 @@
+// RUN: clang -fsyntax-only -verify -std=c++98 %s
+
+void a (void []()); // expected-error{{'type name' declared as array of functions}}
+void b (void p[]()); // expected-error{{'p' declared as array of functions}}
+void c (int &[]); // expected-error{{'type name' declared as array of references}}
+void d (int &p[]); // expected-error{{'p' declared as array of references}}
+
More information about the cfe-commits
mailing list